我在Rails 3.2上使用Capybara/Cucumber,並且我面臨一個奇怪的路由錯誤。水豚/黃瓜:命名空間中嵌套資源的RoutingError
我有以下途徑定義:
#routes.rb
namespace :super_user do
...
resources :events do
resources :invites
end
end
...
resources :invites
和下面的黃瓜功能:
@in_progress @current
Scenario: I can invite a USER by email
Given the following event exists:
| Name |
| The Event |
And I go to the event page for "The Event"
And I follow "Invite new user"
And I fill in "invite_email" with "[email protected]"
...
活動頁面(EventsController#show
)包含一個鏈接到invites#new
行動:
#app/views/super_user/events/show.html.erb
...
<%= content_for :button_bar do %>
<%= link_to('Invite new user', new_super_user_event_invite_path(@event)) %>
<% end %>
一切工作正常,當我測試手動/super_user/events/1
行爲,但每當我跑黃瓜,我得到:
And I follow "Invite new user" # features/step_definitions/web_steps.rb:45
uninitialized constant SuperUser::InvitesController (ActionController::RoutingError)
(eval):2:in `click_link'
./features/step_definitions/web_steps.rb:46:in `/^(?:|I)follow "([^"]*)"$/'
features/create_casino_super_user.feature:24:in `And I follow "Invite new user"'
爲什麼路由不同的表現用黃瓜/水豚是什麼時候?我怎樣才能解決這個功能?
的bundle list
相關部分:
* cucumber (1.0.6)
* cucumber-rails (1.0.2)
* capybara (1.0.1)
* capybara-webkit (0.6.1 dfa0624)
* rails (3.2.1)
編輯
邊注:該InvitesController類不是超級用戶模塊中,但正如我以前說過它手動測試時的作品。
感謝您的回答(+1)。正如你所說'map.connect'現在已被棄用。我找到的唯一解決方案是創建一個基本控制器('InvitesControllerBase')並將其擴展到名稱空間的'SuperUser :: InvitesController'類中。 – Jef 2012-04-15 14:49:46