Решение на Втора задача - хешове, масиви и структура от Константин Нецов
Обратно към всички решения
Към профила на Константин Нецов
Резултати
- 2 точки от тестове
- 0 бонус точки
- 2 точки общо
- 6 успешни тест(а)
- 9 неуспешни тест(а)
Код
Лог от изпълнението
F.FF.F.F.FF.F.F
Failures:
1) Task 2 README works for all examples
Failure/Error: expect(dessert.fetch_deep('variant')).to eq('chocolate')
expected: "chocolate"
got: nil
(compared using ==)
# /tmp/d20161024-13689-1c29py8/spec.rb:25:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'
2) Task 2 Hash#fetch_deep can look up deeply nested values
Failure/Error: expect(input.fetch_deep('order.meal.type')).to eq 'dessert'
expected: "dessert"
got: {:type=>"dessert"}
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-"dessert"
+:type => "dessert"
# /tmp/d20161024-13689-1c29py8/spec.rb:70:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'
3) Task 2 Hash#fetch_deep can find values in arrays by index
Failure/Error: expect(input.fetch_deep('orders.0.meal')).to eq 'cake'
expected: "cake"
got: nil
(compared using ==)
# /tmp/d20161024-13689-1c29py8/spec.rb:81:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'
4) Task 2 Hash#fetch_deep is indifferent to symbols and strings
Failure/Error: expect(input.fetch_deep('dessert')).to eq 'ice cream'
expected: "ice cream"
got: nil
(compared using ==)
# /tmp/d20161024-13689-1c29py8/spec.rb:96:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'
5) Task 2 Hash#fetch_deep can fetch integer-like keys from hashes
Failure/Error: expect(input.fetch_deep('nested.1')).to eq :a
expected: :a
got: nil
(compared using ==)
# /tmp/d20161024-13689-1c29py8/spec.rb:111:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'
6) Task 2 Hash#reshape can extract fields to nested objects
Failure/Error: expect(input.reshape(shape)).to eq output
NameError:
undefined local variable or method `c' for {:profile=>{:name=>"Georgi"}}:Hash
# /tmp/d20161024-13689-1c29py8/solution.rb:41:in `block in f1'
# /tmp/d20161024-13689-1c29py8/solution.rb:37:in `each'
# /tmp/d20161024-13689-1c29py8/solution.rb:37:in `f1'
# /tmp/d20161024-13689-1c29py8/solution.rb:15:in `reshape'
# /tmp/d20161024-13689-1c29py8/spec.rb:133:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'
7) Task 2 Hash#reshape can create nested objects
Failure/Error: expect(input.reshape(shape)).to eq output
NameError:
undefined local variable or method `c' for {:name=>"Georgi"}:Hash
# /tmp/d20161024-13689-1c29py8/solution.rb:41:in `block in f1'
# /tmp/d20161024-13689-1c29py8/solution.rb:37:in `each'
# /tmp/d20161024-13689-1c29py8/solution.rb:37:in `f1'
# /tmp/d20161024-13689-1c29py8/solution.rb:15:in `reshape'
# /tmp/d20161024-13689-1c29py8/spec.rb:146:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'
8) Task 2 Hash#reshape can extract fields from arrays by index
Failure/Error: expect(input.reshape(shape)).to eq output
NameError:
undefined local variable or method `c' for {:users=>[{:name=>"Georgi"}, {:name=>"Ivan"}]}:Hash
# /tmp/d20161024-13689-1c29py8/solution.rb:41:in `block in f1'
# /tmp/d20161024-13689-1c29py8/solution.rb:37:in `each'
# /tmp/d20161024-13689-1c29py8/solution.rb:37:in `f1'
# /tmp/d20161024-13689-1c29py8/solution.rb:15:in `reshape'
# /tmp/d20161024-13689-1c29py8/spec.rb:177:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'
9) Task 2 Array#reshape maps each element with the result of Hash#fetch_deep
Failure/Error: expect(input.reshape(shape)).to eq [
expected: [{:type=>"meal"}, {:type=>"dessert"}]
got: [{:type=>"dessert"}, {:type=>"dessert"}]
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-[{:type=>"meal"}, {:type=>"dessert"}]
+[{:type=>"dessert"}, {:type=>"dessert"}]
# /tmp/d20161024-13689-1c29py8/spec.rb:213:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'
Finished in 0.00954 seconds
15 examples, 9 failures
Failed examples:
rspec /tmp/d20161024-13689-1c29py8/spec.rb:3 # Task 2 README works for all examples
rspec /tmp/d20161024-13689-1c29py8/spec.rb:63 # Task 2 Hash#fetch_deep can look up deeply nested values
rspec /tmp/d20161024-13689-1c29py8/spec.rb:73 # Task 2 Hash#fetch_deep can find values in arrays by index
rspec /tmp/d20161024-13689-1c29py8/spec.rb:92 # Task 2 Hash#fetch_deep is indifferent to symbols and strings
rspec /tmp/d20161024-13689-1c29py8/spec.rb:108 # Task 2 Hash#fetch_deep can fetch integer-like keys from hashes
rspec /tmp/d20161024-13689-1c29py8/spec.rb:125 # Task 2 Hash#reshape can extract fields to nested objects
rspec /tmp/d20161024-13689-1c29py8/spec.rb:136 # Task 2 Hash#reshape can create nested objects
rspec /tmp/d20161024-13689-1c29py8/spec.rb:156 # Task 2 Hash#reshape can extract fields from arrays by index
rspec /tmp/d20161024-13689-1c29py8/spec.rb:205 # Task 2 Array#reshape maps each element with the result of Hash#fetch_deep
История (1 версия и 0 коментара)
Константин обнови решението на 24.10.2016 14:30 (преди около 8 години)