アプリケーションが使用しているエンジン内にあるコントローラーをテストしようとしています。仕様はエンジン内ではなく、アプリケーション自体にあります (エンジン内でテストしようとしましたが、問題もありました)。
私のエンジンには次のroutes.rbがあります:
Revision::Engine.routes.draw do
resources :steps, only: [] do
collection { get :first }
end
end
エンジンは通常、アプリケーション routes.rb にマウントされます。
mount Revision::Engine => "revision"
を実行するrake routes
と、最後の行で次のようになります。
Routes for Revision::Engine:
first_steps GET /steps/first(.:format) revision/steps#first
root / revision/steps#first
エンジンのコントローラー ( lib/revision/app/controllers/revision/steps_controller.rb
) には、次のものがあります。
module Revision
class StepsController < ApplicationController
def first
end
end
end
Rspec では、このコントローラーを次のようにテストします。
require 'spec_helper'
describe Revision::StepsController do
it "should work" do
get :first
response.should be_success
end
end
次に、この仕様を実行すると、次のようになります。
ActionController::RoutingError:
No route matches {:controller=>"revision/steps", :action=>"first"}
ルートが実際には存在しないことを確認するために、これを仕様に追加しました。
before do
puts @routes.set.to_a.map(&:defaults)
end
結果は次のとおりです。
[...]
{:action=>"show", :controller=>"devise/unlocks"}
{:action=>"revision"}
パラメーターのみがあり:action
ます。
何が間違っている可能性がありますか?