- Коректно
- 9 успешни тест(а)
- 0 неуспешни тест(а)
......... Finished in 0.22587 seconds 9 examples, 0 failures
Срокът за предаване на решения е отминал
Понеже ви казахме, че Monkey patching-а е нещо, което трябва да се избягва по принцип, решихме отново да ви накараме да го приложите. :-)
С цел да не ви става навик, отново ви даваме Monkey patching :-)
Дефинирайте метод Enumerable#split_up, който приема следните keyword аргументи:
length: - задължителен.step: - по подразбиране равен на стойността на параметъра length.pad: - по подразбиране празен списък.Връща Array, съдържащ списъци (парчета) от по length елемента всеки:
1.upto(10).split_up(length: 3)
=> [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]
Ако step е подаден, то елементите за всяко следващо парче започват да се
взимат от позиция със стъпка step. По подразбиране step е равно на length:
1.upto(10).split_up(length: 2, step: 4)
=> [[1, 2], [5, 6], [9, 10]]
Ако се подаде списък pad, то елементите му се използват за плънка към
последното парче, ако не му достигат елементи. В случай, че в pad няма
достатъчно елементи, се връща парче с по-малко от length елемента:
1.upto(10).split_up(length: 3, pad: [:a, :b, :c])
=> [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :a, :b]]
Ако pad не е подаден и последното парче е с по-малко от length елемента,
то парчето остава както си е.
1.upto(10).split_up(length: 2, step: 3)
=> [[1, 2], [4, 5], [7, 8], [10]]
Методът трябва да работи и ако му бъде подаден блок, като на блока се
yield-ва всяко парче от резултатната последователност. В този случай, върнатата стойност от split_up не се променя по никакъв начин, освен ако съзнателно не мутирате yield-нато парче в блока. Например, ако го извикаме
по следния начин:
1.upto(5).split_up(length: 2) { |slice| puts 'Got ' + slice.inspect }
Ще очакваме целият израз да изведе на екрана следното, като след това
върне [[1, 2], [3, 4], [5]]:
Got [1, 2]
Got [3, 4]
Got [5]
Понеже е в Enumerable, методът ще се вика върху колекции. Ще тестваме за
хеш и списък.
Методът няма да се вика с length > step.
1.upto(10).split_up(length: 2, step: 3, pad: [:a, :b, :c])
=> [[1, 2], [4, 5], [7, 8], [10, :a]]
1.upto(10).split_up(length: 2)
=> [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
{ one: 1, two: 2, three: 3, four: 4 }.split_up(length: 2)
=> [[[:one, 1], [:two, 2]], [[:three, 3], [:four, 4]]]
......... Finished in 0.22587 seconds 9 examples, 0 failures
......... Finished in 0.19513 seconds 9 examples, 0 failures
......... Finished in 0.1958 seconds 9 examples, 0 failures
......... Finished in 0.21105 seconds 9 examples, 0 failures
...F.....
Failures:
1) Enumerable#split_up does not mutate the input enumerable
Failure/Error: numbers_list.should eq [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
expected: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
got: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, :a]
(compared using ==)
# /tmp/d20131106-4393-1hfopiy/spec.rb:25:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.25602 seconds
9 examples, 1 failure
Failed examples:
rspec /tmp/d20131106-4393-1hfopiy/spec.rb:23 # Enumerable#split_up does not mutate the input enumerable
.F.F.....
Failures:
1) Enumerable#split_up returns the processed input when a block is passed
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad) {}.should eq [[1, 2],
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: nil
(compared using ==)
# /tmp/d20131106-4393-3neixb/spec.rb:13:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) Enumerable#split_up does not mutate the input enumerable
Failure/Error: numbers_list.should eq [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
expected: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
got: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, :a]
(compared using ==)
# /tmp/d20131106-4393-3neixb/spec.rb:25:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.27556 seconds
9 examples, 2 failures
Failed examples:
rspec /tmp/d20131106-4393-3neixb/spec.rb:12 # Enumerable#split_up returns the processed input when a block is passed
rspec /tmp/d20131106-4393-3neixb/spec.rb:23 # Enumerable#split_up does not mutate the input enumerable
......... Finished in 0.24213 seconds 9 examples, 0 failures
......... Finished in 0.24961 seconds 9 examples, 0 failures
......... Finished in 0.24351 seconds 9 examples, 0 failures
........F
Failures:
1) Enumerable#split_up leaves the last partition with less than n items if not enough padding elements
Failure/Error: numbers_list.split_up(length: 3, pad: not_enough).should eq [[1, 2, 3],
expected: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :not_enough]]
got: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :not_enough, nil]]
(compared using ==)
# /tmp/d20131106-4393-1a8ynhv/spec.rb:76:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.01325 seconds
9 examples, 1 failure
Failed examples:
rspec /tmp/d20131106-4393-1a8ynhv/spec.rb:74 # Enumerable#split_up leaves the last partition with less than n items if not enough padding elements
......... Finished in 0.09587 seconds 9 examples, 0 failures
......... Finished in 0.06783 seconds 9 examples, 0 failures
..FF.....
Failures:
1) Enumerable#split_up requires the length: keyword argument
Failure/Error: expect { numbers_list.split_up }.to raise_error(ArgumentError)
expected ArgumentError but nothing was raised
# /tmp/d20131106-4393-94q5wr/spec.rb:20:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) Enumerable#split_up does not mutate the input enumerable
Failure/Error: numbers_list.should eq [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
expected: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
got: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, :a]
(compared using ==)
# /tmp/d20131106-4393-94q5wr/spec.rb:25:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.07702 seconds
9 examples, 2 failures
Failed examples:
rspec /tmp/d20131106-4393-94q5wr/spec.rb:19 # Enumerable#split_up requires the length: keyword argument
rspec /tmp/d20131106-4393-94q5wr/spec.rb:23 # Enumerable#split_up does not mutate the input enumerable
........F
Failures:
1) Enumerable#split_up leaves the last partition with less than n items if not enough padding elements
Failure/Error: numbers_list.split_up(length: 3, pad: not_enough).should eq [[1, 2, 3],
expected: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :not_enough]]
got: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :not_enough, nil]]
(compared using ==)
# /tmp/d20131106-4393-1ng9i4/spec.rb:76:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.27262 seconds
9 examples, 1 failure
Failed examples:
rspec /tmp/d20131106-4393-1ng9i4/spec.rb:74 # Enumerable#split_up leaves the last partition with less than n items if not enough padding elements
......... Finished in 0.27866 seconds 9 examples, 0 failures
FF.FFFFFF
Failures:
1) Enumerable#split_up iterates a block (if given) for each slice
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad) { |slice| slices << slice }
ArgumentError:
wrong number of arguments (3 for 1..2)
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `slice'
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `block in split_up'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `each'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `split_up'
# /tmp/d20131106-4393-1eia9jh/spec.rb:8:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) Enumerable#split_up returns the processed input when a block is passed
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad) {}.should eq [[1, 2],
ArgumentError:
wrong number of arguments (3 for 1..2)
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `slice'
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `block in split_up'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `each'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `split_up'
# /tmp/d20131106-4393-1eia9jh/spec.rb:13:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
3) Enumerable#split_up does not mutate the input enumerable
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: [:a])
ArgumentError:
wrong number of arguments (3 for 1..2)
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `slice'
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `block in split_up'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `each'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `split_up'
# /tmp/d20131106-4393-1eia9jh/spec.rb:24:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
4) Enumerable#split_up splits up a collection in slices
Failure/Error: numbers_list.split_up(length: 3).should eq [[1, 2, 3],
ArgumentError:
wrong number of arguments (3 for 1..2)
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `slice'
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `block in split_up'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `each'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `split_up'
# /tmp/d20131106-4393-1eia9jh/spec.rb:29:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
5) Enumerable#split_up splits up a collection in slices with step
Failure/Error: numbers_list.split_up(length: 2, step: 3).should eq [[1, 2],
ArgumentError:
wrong number of arguments (3 for 1..2)
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `slice'
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `block in split_up'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `each'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `split_up'
# /tmp/d20131106-4393-1eia9jh/spec.rb:45:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
6) Enumerable#split_up splits up a collection in slices with pad
Failure/Error: numbers_list.split_up(length: 3, pad: pad).should eq [[1, 2, 3],
ArgumentError:
wrong number of arguments (3 for 1..2)
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `slice'
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `block in split_up'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `each'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `split_up'
# /tmp/d20131106-4393-1eia9jh/spec.rb:55:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
7) Enumerable#split_up splits up a collection in slices with step and pad
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad).should eq [[1, 2],
ArgumentError:
wrong number of arguments (3 for 1..2)
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `slice'
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `block in split_up'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `each'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `split_up'
# /tmp/d20131106-4393-1eia9jh/spec.rb:65:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
8) Enumerable#split_up leaves the last partition with less than n items if not enough padding elements
Failure/Error: numbers_list.split_up(length: 3, pad: not_enough).should eq [[1, 2, 3],
ArgumentError:
wrong number of arguments (3 for 1..2)
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `slice'
# /tmp/d20131106-4393-1eia9jh/solution.rb:11:in `block in split_up'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `each'
# /tmp/d20131106-4393-1eia9jh/solution.rb:10:in `split_up'
# /tmp/d20131106-4393-1eia9jh/spec.rb:76:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.19447 seconds
9 examples, 8 failures
Failed examples:
rspec /tmp/d20131106-4393-1eia9jh/spec.rb:6 # Enumerable#split_up iterates a block (if given) for each slice
rspec /tmp/d20131106-4393-1eia9jh/spec.rb:12 # Enumerable#split_up returns the processed input when a block is passed
rspec /tmp/d20131106-4393-1eia9jh/spec.rb:23 # Enumerable#split_up does not mutate the input enumerable
rspec /tmp/d20131106-4393-1eia9jh/spec.rb:28 # Enumerable#split_up splits up a collection in slices
rspec /tmp/d20131106-4393-1eia9jh/spec.rb:44 # Enumerable#split_up splits up a collection in slices with step
rspec /tmp/d20131106-4393-1eia9jh/spec.rb:54 # Enumerable#split_up splits up a collection in slices with pad
rspec /tmp/d20131106-4393-1eia9jh/spec.rb:64 # Enumerable#split_up splits up a collection in slices with step and pad
rspec /tmp/d20131106-4393-1eia9jh/spec.rb:74 # Enumerable#split_up leaves the last partition with less than n items if not enough padding elements
......... Finished in 0.14654 seconds 9 examples, 0 failures
......... Finished in 0.17025 seconds 9 examples, 0 failures
.F.......
Failures:
1) Enumerable#split_up returns the processed input when a block is passed
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad) {}.should eq [[1, 2],
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: nil
(compared using ==)
# /tmp/d20131106-4393-6446se/spec.rb:13:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.23896 seconds
9 examples, 1 failure
Failed examples:
rspec /tmp/d20131106-4393-6446se/spec.rb:12 # Enumerable#split_up returns the processed input when a block is passed
......... Finished in 0.22263 seconds 9 examples, 0 failures
......... Finished in 0.20599 seconds 9 examples, 0 failures
FF....FF.
Failures:
1) Enumerable#split_up iterates a block (if given) for each slice
Failure/Error: slices.should eq [[1, 2], [4, 5], [7, 8], [10, :a]]
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [[1, 2], [4, 5], [7, 8], [10, :a], [:c]]
(compared using ==)
# /tmp/d20131106-4393-gavcgf/spec.rb:9:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) Enumerable#split_up returns the processed input when a block is passed
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad) {}.should eq [[1, 2],
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [[1, 2], [4, 5], [7, 8], [10, :a], [:c]]
(compared using ==)
# /tmp/d20131106-4393-gavcgf/spec.rb:13:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
3) Enumerable#split_up splits up a collection in slices with pad
Failure/Error: numbers_list.split_up(length: 3, pad: pad).should eq [[1, 2, 3],
expected: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :a, :b]]
got: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :a, :b], [:c]]
(compared using ==)
# /tmp/d20131106-4393-gavcgf/spec.rb:55:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
4) Enumerable#split_up splits up a collection in slices with step and pad
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad).should eq [[1, 2],
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [[1, 2], [4, 5], [7, 8], [10, :a], [:c]]
(compared using ==)
# /tmp/d20131106-4393-gavcgf/spec.rb:65:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.10295 seconds
9 examples, 4 failures
Failed examples:
rspec /tmp/d20131106-4393-gavcgf/spec.rb:6 # Enumerable#split_up iterates a block (if given) for each slice
rspec /tmp/d20131106-4393-gavcgf/spec.rb:12 # Enumerable#split_up returns the processed input when a block is passed
rspec /tmp/d20131106-4393-gavcgf/spec.rb:54 # Enumerable#split_up splits up a collection in slices with pad
rspec /tmp/d20131106-4393-gavcgf/spec.rb:64 # Enumerable#split_up splits up a collection in slices with step and pad
......... Finished in 0.19056 seconds 9 examples, 0 failures
FF.....F.
Failures:
1) Enumerable#split_up iterates a block (if given) for each slice
Failure/Error: slices.should eq [[1, 2], [4, 5], [7, 8], [10, :a]]
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [[1, 2], [4, 5], [7, 8], [10]]
(compared using ==)
# /tmp/d20131106-4393-1ora9e8/spec.rb:9:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) Enumerable#split_up returns the processed input when a block is passed
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad) {}.should eq [[1, 2],
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [[1, 2], [4, 5], [7, 8], [10]]
(compared using ==)
# /tmp/d20131106-4393-1ora9e8/spec.rb:13:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
3) Enumerable#split_up splits up a collection in slices with step and pad
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad).should eq [[1, 2],
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [[1, 2], [4, 5], [7, 8], [10]]
(compared using ==)
# /tmp/d20131106-4393-1ora9e8/spec.rb:65:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.20109 seconds
9 examples, 3 failures
Failed examples:
rspec /tmp/d20131106-4393-1ora9e8/spec.rb:6 # Enumerable#split_up iterates a block (if given) for each slice
rspec /tmp/d20131106-4393-1ora9e8/spec.rb:12 # Enumerable#split_up returns the processed input when a block is passed
rspec /tmp/d20131106-4393-1ora9e8/spec.rb:64 # Enumerable#split_up splits up a collection in slices with step and pad
FF.......
Failures:
1) Enumerable#split_up iterates a block (if given) for each slice
Failure/Error: slices.should eq [[1, 2], [4, 5], [7, 8], [10, :a]]
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [[1, 2], [4, 5], [7, 8], [10, :a], [:c]]
(compared using ==)
# /tmp/d20131106-4393-13pzes8/spec.rb:9:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) Enumerable#split_up returns the processed input when a block is passed
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad) {}.should eq [[1, 2],
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [nil, nil, nil, nil]
(compared using ==)
# /tmp/d20131106-4393-13pzes8/spec.rb:13:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.18826 seconds
9 examples, 2 failures
Failed examples:
rspec /tmp/d20131106-4393-13pzes8/spec.rb:6 # Enumerable#split_up iterates a block (if given) for each slice
rspec /tmp/d20131106-4393-13pzes8/spec.rb:12 # Enumerable#split_up returns the processed input when a block is passed
......... Finished in 0.10471 seconds 9 examples, 0 failures
.F.......
Failures:
1) Enumerable#split_up returns the processed input when a block is passed
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad) {}.should eq [[1, 2],
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [nil, nil, nil, nil]
(compared using ==)
# /tmp/d20131106-4393-rgteqk/spec.rb:13:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.194 seconds
9 examples, 1 failure
Failed examples:
rspec /tmp/d20131106-4393-rgteqk/spec.rb:12 # Enumerable#split_up returns the processed input when a block is passed
......... Finished in 0.17674 seconds 9 examples, 0 failures
.F.......
Failures:
1) Enumerable#split_up returns the processed input when a block is passed
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad) {}.should eq [[1, 2],
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [nil, nil, nil, nil]
(compared using ==)
# /tmp/d20131106-4393-11l6672/spec.rb:13:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.30412 seconds
9 examples, 1 failure
Failed examples:
rspec /tmp/d20131106-4393-11l6672/spec.rb:12 # Enumerable#split_up returns the processed input when a block is passed
......... Finished in 0.26814 seconds 9 examples, 0 failures
......... Finished in 0.26925 seconds 9 examples, 0 failures
..F......
Failures:
1) Enumerable#split_up requires the length: keyword argument
Failure/Error: expect { numbers_list.split_up }.to raise_error(ArgumentError)
expected ArgumentError, got #<TypeError: nil can't be coerced into Fixnum> with backtrace:
# /tmp/d20131106-4393-h5hkw6/solution.rb:5:in `%'
# /tmp/d20131106-4393-h5hkw6/solution.rb:5:in `block in split_up'
# /tmp/d20131106-4393-h5hkw6/solution.rb:5:in `each_index'
# /tmp/d20131106-4393-h5hkw6/solution.rb:5:in `each'
# /tmp/d20131106-4393-h5hkw6/solution.rb:5:in `select'
# /tmp/d20131106-4393-h5hkw6/solution.rb:5:in `split_up'
# /tmp/d20131106-4393-h5hkw6/spec.rb:20:in `block (3 levels) in <top (required)>'
# /tmp/d20131106-4393-h5hkw6/spec.rb:20:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
# /tmp/d20131106-4393-h5hkw6/spec.rb:20:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.01507 seconds
9 examples, 1 failure
Failed examples:
rspec /tmp/d20131106-4393-h5hkw6/spec.rb:19 # Enumerable#split_up requires the length: keyword argument
......... Finished in 0.23677 seconds 9 examples, 0 failures
...F.....
Failures:
1) Enumerable#split_up does not mutate the input enumerable
Failure/Error: numbers_list.should eq [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
expected: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
got: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, :a]
(compared using ==)
# /tmp/d20131106-4393-128qidz/spec.rb:25:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.18786 seconds
9 examples, 1 failure
Failed examples:
rspec /tmp/d20131106-4393-128qidz/spec.rb:23 # Enumerable#split_up does not mutate the input enumerable
[[1, 2], [4, 5], [7, 8], [10, :a]]
.[[1, 2], [4, 5], [7, 8], [10, :a]]
..[[1, 2], [4, 5], [7, 8], [10, :a]]
.[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]
[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
[[[:one, 1], [:two, 2]], [[:three, 3], [:four, 4]]]
.[[1, 2], [4, 5], [7, 8], [10]]
[[[:one, 1], [:two, 2]], [[:four, 4]]]
.[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :a, :b]]
[[[:one, 1], [:two, 2], [:three, 3]], [[:four, 4], :a, :b]]
.[[1, 2], [4, 5], [7, 8], [10, :a]]
[[[:one, 1], [:two, 2]], [[:four, 4], :a]]
.[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :not_enough, nil]]
F
Failures:
1) Enumerable#split_up leaves the last partition with less than n items if not enough padding elements
Failure/Error: numbers_list.split_up(length: 3, pad: not_enough).should eq [[1, 2, 3],
expected: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :not_enough]]
got: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :not_enough, nil]]
(compared using ==)
# /tmp/d20131106-4393-1xldf4x/spec.rb:76:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.20339 seconds
9 examples, 1 failure
Failed examples:
rspec /tmp/d20131106-4393-1xldf4x/spec.rb:74 # Enumerable#split_up leaves the last partition with less than n items if not enough padding elements
......... Finished in 0.19732 seconds 9 examples, 0 failures
.F.......
Failures:
1) Enumerable#split_up returns the processed input when a block is passed
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad) {}.should eq [[1, 2],
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [nil, nil, nil, nil]
(compared using ==)
# /tmp/d20131106-4393-zo74jz/spec.rb:13:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.18751 seconds
9 examples, 1 failure
Failed examples:
rspec /tmp/d20131106-4393-zo74jz/spec.rb:12 # Enumerable#split_up returns the processed input when a block is passed
......... Finished in 0.2132 seconds 9 examples, 0 failures
F........
Failures:
1) Enumerable#split_up iterates a block (if given) for each slice
Failure/Error: slices.should eq [[1, 2], [4, 5], [7, 8], [10, :a]]
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [[1, 2], [4, 5], [7, 8], [10]]
(compared using ==)
# /tmp/d20131106-4393-om4nsl/spec.rb:9:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.18586 seconds
9 examples, 1 failure
Failed examples:
rspec /tmp/d20131106-4393-om4nsl/spec.rb:6 # Enumerable#split_up iterates a block (if given) for each slice
......... Finished in 0.01742 seconds 9 examples, 0 failures
FF..FFFF.
Failures:
1) Enumerable#split_up iterates a block (if given) for each slice
Failure/Error: slices.should eq [[1, 2], [4, 5], [7, 8], [10, :a]]
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [[1, 2], [4, 5], [7, 8], [10, :a, :b]]
(compared using ==)
# /tmp/d20131106-4393-7gmku3/spec.rb:9:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) Enumerable#split_up returns the processed input when a block is passed
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad) {}.should eq [[1, 2],
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [[1, 2], [4, 5], [7, 8], [10, :a, :b]]
(compared using ==)
# /tmp/d20131106-4393-7gmku3/spec.rb:13:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
3) Enumerable#split_up splits up a collection in slices
Failure/Error: numbers_hash.split_up(length: 2).should eq [[[:one, 1], [:two, 2]],
expected: [[[:one, 1], [:two, 2]], [[:three, 3], [:four, 4]]]
got: [[:one, 1], [:two, 2], [:three, 3], [:four, 4]]
(compared using ==)
# /tmp/d20131106-4393-7gmku3/spec.rb:40:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
4) Enumerable#split_up splits up a collection in slices with step
Failure/Error: numbers_hash.split_up(length: 2, step: 3).should eq [[[:one, 1], [:two, 2]],
expected: [[[:one, 1], [:two, 2]], [[:four, 4]]]
got: [[:one, 1], [2, :three], [:four, 4]]
(compared using ==)
# /tmp/d20131106-4393-7gmku3/spec.rb:50:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
5) Enumerable#split_up splits up a collection in slices with pad
Failure/Error: numbers_list.split_up(length: 3, pad: pad).should eq [[1, 2, 3],
expected: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :a, :b]]
got: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :a, :b, :c]]
(compared using ==)
# /tmp/d20131106-4393-7gmku3/spec.rb:55:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
6) Enumerable#split_up splits up a collection in slices with step and pad
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad).should eq [[1, 2],
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [[1, 2], [4, 5], [7, 8], [10, :a, :b]]
(compared using ==)
# /tmp/d20131106-4393-7gmku3/spec.rb:65:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.01489 seconds
9 examples, 6 failures
Failed examples:
rspec /tmp/d20131106-4393-7gmku3/spec.rb:6 # Enumerable#split_up iterates a block (if given) for each slice
rspec /tmp/d20131106-4393-7gmku3/spec.rb:12 # Enumerable#split_up returns the processed input when a block is passed
rspec /tmp/d20131106-4393-7gmku3/spec.rb:28 # Enumerable#split_up splits up a collection in slices
rspec /tmp/d20131106-4393-7gmku3/spec.rb:44 # Enumerable#split_up splits up a collection in slices with step
rspec /tmp/d20131106-4393-7gmku3/spec.rb:54 # Enumerable#split_up splits up a collection in slices with pad
rspec /tmp/d20131106-4393-7gmku3/spec.rb:64 # Enumerable#split_up splits up a collection in slices with step and pad
.F....FF.
Failures:
1) Enumerable#split_up returns the processed input when a block is passed
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad) {}.should eq [[1, 2],
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: nil
(compared using ==)
# /tmp/d20131106-4393-1264cp/spec.rb:13:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) Enumerable#split_up splits up a collection in slices with pad
Failure/Error: numbers_hash.split_up(length: 3, pad: pad).should eq [[[:one, 1], [:two, 2], [:three, 3]],
expected: [[[:one, 1], [:two, 2], [:three, 3]], [[:four, 4], :a, :b]]
got: [[:one, 1, :two], [:four, 4, :a]]
(compared using ==)
# /tmp/d20131106-4393-1264cp/spec.rb:60:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
3) Enumerable#split_up splits up a collection in slices with step and pad
Failure/Error: numbers_hash.split_up(length: 2, step: 3, pad: pad).should eq [[[:one, 1], [:two, 2]],
expected: [[[:one, 1], [:two, 2]], [[:four, 4], :a]]
got: [[:one, 1], [:four, 4]]
(compared using ==)
# /tmp/d20131106-4393-1264cp/spec.rb:70:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.01398 seconds
9 examples, 3 failures
Failed examples:
rspec /tmp/d20131106-4393-1264cp/spec.rb:12 # Enumerable#split_up returns the processed input when a block is passed
rspec /tmp/d20131106-4393-1264cp/spec.rb:54 # Enumerable#split_up splits up a collection in slices with pad
rspec /tmp/d20131106-4393-1264cp/spec.rb:64 # Enumerable#split_up splits up a collection in slices with step and pad
......... Finished in 0.01313 seconds 9 examples, 0 failures
......... Finished in 0.30886 seconds 9 examples, 0 failures
......... Finished in 0.01338 seconds 9 examples, 0 failures
...F.....
Failures:
1) Enumerable#split_up does not mutate the input enumerable
Failure/Error: numbers_list.should eq [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
expected: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
got: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, :a]
(compared using ==)
# /tmp/d20131106-4393-19epdm3/spec.rb:25:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.01333 seconds
9 examples, 1 failure
Failed examples:
rspec /tmp/d20131106-4393-19epdm3/spec.rb:23 # Enumerable#split_up does not mutate the input enumerable
F...FFFFF
Failures:
1) Enumerable#split_up iterates a block (if given) for each slice
Failure/Error: slices.should eq [[1, 2], [4, 5], [7, 8], [10, :a]]
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: []
(compared using ==)
# /tmp/d20131106-4393-vd1qfi/spec.rb:9:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) Enumerable#split_up splits up a collection in slices
Failure/Error: numbers_list.split_up(length: 3).should eq [[1, 2, 3],
expected: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]
got: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, nil, nil]]
(compared using ==)
# /tmp/d20131106-4393-vd1qfi/spec.rb:29:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
3) Enumerable#split_up splits up a collection in slices with step
Failure/Error: numbers_list.split_up(length: 2, step: 3).should eq [[1, 2],
expected: [[1, 2], [4, 5], [7, 8], [10]]
got: [[1, 2], [4, 5], [7, 8], [10, nil]]
(compared using ==)
# /tmp/d20131106-4393-vd1qfi/spec.rb:45:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
4) Enumerable#split_up splits up a collection in slices with pad
Failure/Error: numbers_hash.split_up(length: 3, pad: pad).should eq [[[:one, 1], [:two, 2], [:three, 3]],
expected: [[[:one, 1], [:two, 2], [:three, 3]], [[:four, 4], :a, :b]]
got: [[[:one, 1], [:two, 2], [:three, 3]], [[:four, 4], :c, nil]]
(compared using ==)
# /tmp/d20131106-4393-vd1qfi/spec.rb:60:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
5) Enumerable#split_up splits up a collection in slices with step and pad
Failure/Error: numbers_hash.split_up(length: 2, step: 3, pad: pad).should eq [[[:one, 1], [:two, 2]],
expected: [[[:one, 1], [:two, 2]], [[:four, 4], :a]]
got: [[[:one, 1], [:two, 2]], [[:four, 4], :b]]
(compared using ==)
# /tmp/d20131106-4393-vd1qfi/spec.rb:70:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
6) Enumerable#split_up leaves the last partition with less than n items if not enough padding elements
Failure/Error: numbers_list.split_up(length: 3, pad: not_enough).should eq [[1, 2, 3],
expected: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :not_enough]]
got: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, :not_enough, nil]]
(compared using ==)
# /tmp/d20131106-4393-vd1qfi/spec.rb:76:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.01475 seconds
9 examples, 6 failures
Failed examples:
rspec /tmp/d20131106-4393-vd1qfi/spec.rb:6 # Enumerable#split_up iterates a block (if given) for each slice
rspec /tmp/d20131106-4393-vd1qfi/spec.rb:28 # Enumerable#split_up splits up a collection in slices
rspec /tmp/d20131106-4393-vd1qfi/spec.rb:44 # Enumerable#split_up splits up a collection in slices with step
rspec /tmp/d20131106-4393-vd1qfi/spec.rb:54 # Enumerable#split_up splits up a collection in slices with pad
rspec /tmp/d20131106-4393-vd1qfi/spec.rb:64 # Enumerable#split_up splits up a collection in slices with step and pad
rspec /tmp/d20131106-4393-vd1qfi/spec.rb:74 # Enumerable#split_up leaves the last partition with less than n items if not enough padding elements
F.....FF.
Failures:
1) Enumerable#split_up iterates a block (if given) for each slice
Failure/Error: slices.should eq [[1, 2], [4, 5], [7, 8], [10, :a]]
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [[1, 2], [4, 5], [7, 8], [10]]
(compared using ==)
# /tmp/d20131106-4393-1r0eb76/spec.rb:9:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) Enumerable#split_up splits up a collection in slices with pad
Failure/Error: numbers_hash.split_up(length: 3, pad: pad).should eq [[[:one, 1], [:two, 2], [:three, 3]],
expected: [[[:one, 1], [:two, 2], [:three, 3]], [[:four, 4], :a, :b]]
got: [[[:one, 1], [:two, 2], [:three, 3]], [[:four, 4], :c]]
(compared using ==)
# /tmp/d20131106-4393-1r0eb76/spec.rb:60:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
3) Enumerable#split_up splits up a collection in slices with step and pad
Failure/Error: numbers_hash.split_up(length: 2, step: 3, pad: pad).should eq [[[:one, 1], [:two, 2]],
expected: [[[:one, 1], [:two, 2]], [[:four, 4], :a]]
got: [[[:one, 1], [:two, 2]], [[:four, 4], :b]]
(compared using ==)
# /tmp/d20131106-4393-1r0eb76/spec.rb:70:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.01423 seconds
9 examples, 3 failures
Failed examples:
rspec /tmp/d20131106-4393-1r0eb76/spec.rb:6 # Enumerable#split_up iterates a block (if given) for each slice
rspec /tmp/d20131106-4393-1r0eb76/spec.rb:54 # Enumerable#split_up splits up a collection in slices with pad
rspec /tmp/d20131106-4393-1r0eb76/spec.rb:64 # Enumerable#split_up splits up a collection in slices with step and pad
F........
Failures:
1) Enumerable#split_up iterates a block (if given) for each slice
Failure/Error: slices.should eq [[1, 2], [4, 5], [7, 8], [10, :a]]
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: []
(compared using ==)
# /tmp/d20131106-4393-ih9zmq/spec.rb:9:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.01312 seconds
9 examples, 1 failure
Failed examples:
rspec /tmp/d20131106-4393-ih9zmq/spec.rb:6 # Enumerable#split_up iterates a block (if given) for each slice
FF.......
Failures:
1) Enumerable#split_up iterates a block (if given) for each slice
Failure/Error: slices.should eq [[1, 2], [4, 5], [7, 8], [10, :a]]
expected: [[1, 2], [4, 5], [7, 8], [10, :a]]
got: [[1, 2], [4, 5], [7, 8], [10]]
(compared using ==)
# /tmp/d20131106-4393-1sm1v5t/spec.rb:9:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) Enumerable#split_up returns the processed input when a block is passed
Failure/Error: numbers_list.split_up(length: 2, step: 3, pad: pad) {}.should eq [[1, 2],
NoMethodError:
undefined method `length' for nil:NilClass
# /tmp/d20131106-4393-1sm1v5t/solution.rb:6:in `split_up'
# /tmp/d20131106-4393-1sm1v5t/spec.rb:13:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.01359 seconds
9 examples, 2 failures
Failed examples:
rspec /tmp/d20131106-4393-1sm1v5t/spec.rb:6 # Enumerable#split_up iterates a block (if given) for each slice
rspec /tmp/d20131106-4393-1sm1v5t/spec.rb:12 # Enumerable#split_up returns the processed input when a block is passed