2012-03-11 10 views
2

私はCapybara/Cucumber on Rails 3.2を使用しています。私は奇妙なルーティングエラーに直面しています。Capybara/Cucumber:ネームスペース内のネストされたリソースのRoutingError

私は定義された以下の路線があります。イベントページ(EventsController#show)はinvites#newアクションへのリンクが含まれてい

@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]" 
    ... 

#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 %> 

#routes.rb 
    namespace :super_user do 
    ... 
    resources :events do 
     resources :invites 
    end 
    end 
    ... 
    resources :invites 

と、次のキュウリ機能を

テストするとすべて正常に動作しています/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) 

EDIT

サイドノート:InvitesControllerクラスは、スーパーユーザモジュールではありませんが、私が以前言ったように、手動でテストするとき、それは動作します。

答えて

1

私はRails 3(3.2ではない)、2.3から来て、新しいルーティングDSLにジャンプしています。私は、Cucumber/Capybaraの内部からではなく、直接的に命名されたときのリソース・イン・ア・ネームスペースのルートが動作する、非常に似た問題に遭遇しました。 map.connectが古いの一部である(

# Cucumber doesn't understand the Rails 3 default route, above, so use the old way to make that work 
# TODO remove this when we can/must, and hope that Cucumber is smarter by then 
if File.basename($0) == "cucumber" 
    map.connect ':controller/:action/:id.:format' 
    map.connect ':controller/:action/:id' 
end 

がわからないことは、あなたのためのオプションです:

最後に

、私はRailsの2.3からデフォルトルートを引っ張っのみ動作しているようですキュウリ、内部彼らがアクティブになりますAPI、私は3.1で消えると思うが)、私は見ている人のためにどこかにインターネット上に置いたかった。

+0

回答ありがとうございます(+1)。あなたが言ったように 'map.connect'は廃止されました。私が見つけた唯一の解決策は、ベースコントローラ(InvitesControllerBase')を作成し、それを名前空間の 'SuperUser :: InvitesController'クラスに拡張することでした。 – Jef

関連する問題