LoginSignup
6
5

More than 5 years have passed since last update.

rspecでActionController::UrlGenerationError

Posted at

環境

  • Rails engineを利用
  • Rails 4.2

Controllerのテストを追加したら発生

エラー

  1) EngineName::HogeController GET #index
     Failure/Error: get :index
     ActionController::UrlGenerationError:
       No route matches {:action=>"index", :controller=>"engine_name/hoge"}

対応

hoge_controller_spec.rbに下記を追加

hoge_controller_spec.rb
routes { EngineName::Engine.routes }

参考

http://pivotallabs.com/writing-rails-engine-rspec-controller-tests/
解決方法が3つ載っています

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5