Deleting a resource in a Cucumber (Capybara) step doesn't work
- by Josiah Kiehl
Here is my Scenario:
Scenario: Delete a match
Given pojo is logged in
And there is a match with the following:
| game_id | 1 |
| name | Game del Pojo |
| date_and_time | 2010-02-23 17:52:00 |
| players | 2 |
| teams | 2 |
| comment | This is an awesome comment |
| user_id | 1 |
And I am on the show match 1 page
And show me the page
When I follow "Delete"
And I follow "Yes, delete it"
Then there should not be a match with the following:
| game_id | 1 |
| name | Game del Pojo |
| date_and_time | 2010-02-23 17:52:00 |
| players | 2 |
| teams | 2 |
| comment | This is an awesome comment |
| user_id | 1 |
If I walk through these steps manually, they work. When I click the confirmation: Yes, delete it, then the match is deleted. Cucumber, however, fails to delete the record and the last step fails.
And I follow "Yes, delete it" # features/step_definitions/web_steps.rb:32
Then there should not be a match with the following: # features/step_definitions/match_steps.rb:8
| game_id | 1 |
| name | Game del Pojo |
| date_and_time | 2010-02-23 17:52:00 |
| players | 2 |
| teams | 2 |
| comment | This is an awesome comment |
| user_id | 1 |
<nil> expected but was
<#<Match id: 1, name: "Game del Pojo", date_and_time: "2010-02-23 17:52:00", teams: 2, created_at: "2010-03-02 23:06:33", updated_at: "2010-03-02 23:06:33", comment: "This is an awesome comment", players: 2, game_id: 1, user_id: 1>>. (Test::Unit::AssertionFailedError)
/usr/lib/ruby/1.8/test/unit/assertions.rb:48:in `assert_block'
/usr/lib/ruby/1.8/test/unit/assertions.rb:495:in `_wrap_assertion'
/usr/lib/ruby/1.8/test/unit/assertions.rb:46:in `assert_block'
/usr/lib/ruby/1.8/test/unit/assertions.rb:83:in `assert_equal'
/usr/lib/ruby/1.8/test/unit/assertions.rb:172:in `assert_nil'
./features/step_definitions/match_steps.rb:22:in `/^there should (not)? be a match with the following:$/'
features/matches.feature:124:in `Then there should not be a match with the following:'
Any clue how to debug this?
Thanks!