Решение на Втора задача от Александър Антов
Обратно към всички решения
Към профила на Александър Антов
Резултати
- 3 точки от тестове
- 0 бонус точки
- 3 точки общо
- 10 успешни тест(а)
- 12 неуспешни тест(а)
Код
Лог от изпълнението
....FFFFFFFF....F.FF.F
Failures:
1) TodoList filtering by multiple tags matches only tasks with all the tags
Failure/Error: todo_list.filter(Criteria.tags %w[development FMI]).map(&:description).should =~ ['Do the 5th Ruby challenge.']
expected collection contained: ["Do the 5th Ruby challenge."]
actual collection contained: ["Do the 5th Ruby challenge.", "Grok Ruby."]
the extra elements were: ["Grok Ruby."]
# /tmp/d20131107-4393-1avjb79/spec.rb:47: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) TodoList supports a conjuction of filters
Failure/Error: filtered = todo_list.filter Criteria.status(:todo) & Criteria.priority(:high)
NoMethodError:
undefined method `&' for #<Proc:0xb9706ac0>
# /tmp/d20131107-4393-1avjb79/spec.rb:51: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) TodoList supports a disjunction of filters
Failure/Error: filtered = todo_list.filter Criteria.status(:done) | Criteria.priority(:low)
NoMethodError:
undefined method `|' for #<Proc:0xb970407c>
# /tmp/d20131107-4393-1avjb79/spec.rb:56: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) TodoList supports a negation of filters
Failure/Error: filtered = todo_list.filter !Criteria.status(:todo)
TypeError:
wrong argument type FalseClass (expected Proc)
# /tmp/d20131107-4393-1avjb79/solution.rb:51:in `filter'
# /tmp/d20131107-4393-1avjb79/spec.rb:66: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) TodoList supports simple filters combination
Failure/Error: filtered = todo_list.filter Criteria.priority(:high) & !Criteria.tags(['development'])
NoMethodError:
undefined method `&' for #<Proc:0xb976bd1c>
# /tmp/d20131107-4393-1avjb79/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)>'
6) TodoList supports complex filters combination
Failure/Error: Criteria.priority(:high) |
NoMethodError:
undefined method `&' for #<Proc:0xb9769ea4>
# /tmp/d20131107-4393-1avjb79/spec.rb:82: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) TodoList can be adjoined with another to-do list
Failure/Error: adjoined.count.should eq 3
expected: 3
got: 0
(compared using ==)
# /tmp/d20131107-4393-1avjb79/spec.rb:101: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) TodoList constructs an object for each task
Failure/Error: task.status.should eq :todo
expected: :todo
got: "TODO"
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-:todo
+"TODO"
# /tmp/d20131107-4393-1avjb79/spec.rb:112: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)>'
9) TodoList doesn't modify the to-do list when filtering
Failure/Error: todo_list.should have(text_input.lines.count).items
expected 9 items, got 5
# /tmp/d20131107-4393-1avjb79/spec.rb:137: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)>'
10) TodoList contains tasks with the neccessary interface
Failure/Error: task.should respond_to :tags
expected #<TodoItem:0xb95cb994 @status="TODO", @description="Eat spaghetti.", @priority="High", @categories=["food", "happiness"]> to respond to :tags
# /tmp/d20131107-4393-1avjb79/spec.rb:151: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)>'
11) TodoList tasks have an array of tags
Failure/Error: todo_list.first.tags.should be_an Array
NoMethodError:
undefined method `tags' for #<TodoItem:0xb95c9e28>
# /tmp/d20131107-4393-1avjb79/spec.rb:155: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)>'
12) TodoList creates a new object on filter
Failure/Error: todo_list.filter(Criteria.tags %w[wtf]).should_not equal todo_list
expected not #<TodoList:-592570538> => #<TodoList:0xb95c2eac @enum=[]>
got #<TodoList:-592570538> => #<TodoList:0xb95c2eac @enum=[]>
Compared using equal?, which compares object identity.
Diff:
# /tmp/d20131107-4393-1avjb79/spec.rb:173: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.0387 seconds
22 examples, 12 failures
Failed examples:
rspec /tmp/d20131107-4393-1avjb79/spec.rb:46 # TodoList filtering by multiple tags matches only tasks with all the tags
rspec /tmp/d20131107-4393-1avjb79/spec.rb:50 # TodoList supports a conjuction of filters
rspec /tmp/d20131107-4393-1avjb79/spec.rb:55 # TodoList supports a disjunction of filters
rspec /tmp/d20131107-4393-1avjb79/spec.rb:65 # TodoList supports a negation of filters
rspec /tmp/d20131107-4393-1avjb79/spec.rb:75 # TodoList supports simple filters combination
rspec /tmp/d20131107-4393-1avjb79/spec.rb:80 # TodoList supports complex filters combination
rspec /tmp/d20131107-4393-1avjb79/spec.rb:96 # TodoList can be adjoined with another to-do list
rspec /tmp/d20131107-4393-1avjb79/spec.rb:109 # TodoList constructs an object for each task
rspec /tmp/d20131107-4393-1avjb79/spec.rb:135 # TodoList doesn't modify the to-do list when filtering
rspec /tmp/d20131107-4393-1avjb79/spec.rb:145 # TodoList contains tasks with the neccessary interface
rspec /tmp/d20131107-4393-1avjb79/spec.rb:154 # TodoList tasks have an array of tags
rspec /tmp/d20131107-4393-1avjb79/spec.rb:172 # TodoList creates a new object on filter
История (1 версия и 0 коментара)
Александър обнови решението на 06.11.2013 00:37 (преди около 11 години)