I have a path defined:
when /the admin home\s?page/
"/admin/"
I have scenario that is passing:
Scenario: Let admins see the admin homepage
Given "pojo" is logged in
And "pojo" is an "admin"
And I am on the admin home page
Then I should see "Hi there."
And I have a scenario that is failing:
Scenario: Review flagged photo
Given "pojo" is logged in
And "pojo" is an "admin"
...bunch of steps that create stuff in the database...
And I am on the admin home page
Then ... the rest of the steps
The step that fails in the second one is "And I am on the admin home page" which passes just fine in the first scenario.
Here's the error I get:
And I am on the admin home page # features/step_definitions/web_steps.rb:18
undefined method `add' for {}:Hash (NoMethodError)
./app/controllers/admin_controller.rb:13:in `index'
./app/controllers/admin_controller.rb:11:in `each'
./app/controllers/admin_controller.rb:11:in `index'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
./features/step_definitions/web_steps.rb:19:in `/^(?:|I )am on (.+)$/'
features/admin.feature:52:in `And I am on the admin home page'
This is very odd... why would it be fine in the first case, and not in the second where the only difference are a bunch of steps that create records in the db?
[edit]
Here's the add stuff to database step:
Given /^there is a "([^\"]*)" with the following:$/ do |model, table|
model.constantize.create!(table.rows_hash)
end