1
我定義的路徑添加」:未定義的方法`對黃瓜的步驟,通常工作
when /the admin home\s?page/
"/admin/"
我有一個是通過情景:
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."
而且我有一個失敗的場景:
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
第二個失敗的步驟是「我在管理員主頁」,它在第一個場景中傳遞得很好ARIO。
這是我得到的錯誤:
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'
這是非常奇怪......爲什麼會被罰款在第一種情況下,而不是在第二,唯一的區別是創建的步驟一堆記錄在數據庫中?
[編輯]
這裏的添加內容數據庫的步驟:
Given /^there is a "([^\"]*)" with the following:$/ do |model, table|
model.constantize.create!(table.rows_hash)
end
只是爲了完整起見:如果我不包括「添加數據庫」步驟,則步驟通過。 –
admin_controller從第11行到第13行做了什麼? – ajmurmann
...哦.... 好吧,從來沒有。 :P 這是漫長的一天。 –