No route matches on shared example in a rails engine

61 views
Skip to first unread message

Vell

unread,
Mar 15, 2015, 10:50:26 PM3/15/15
to rs...@googlegroups.com
Hello all,

I am trying to get my shared examples to pass in a rails 4.2 engine that I have created. All was working fine till I changed from using use_route in my controller test to assigning @routes.

When things were working I had something like

get :index use_route AppEngine::Engine.routes

Now that shared examples aren't working I have this:

before {@routes =  AppEngine::Engine.routes}

or

routes {AppEngine::Engine.routes}

How can I make it so that I can get the shared examples know about engines routes?

Here is a backtrace for one of the tests

   1) AppEngine::UsersController PUT update behaves like requires admin privilege redirects to main app root if user is not an admin
     Failure/Error: action
     ActionController::UrlGenerationError:
       No route matches {:action=>"update", :controller=>"app_engine/users"}
     Shared Example Group: "requires admin privilege" called from ./spec/controllers/app_engine/users_controller_spec.rb:114
     # /Users/vmcilwain/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/journey/formatter.rb:46:in `generate'
     # /Users/vmcilwain/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:710:in `generate'
     # /Users/vmcilwain/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:741:in `generate'
     # /Users/vmcilwain/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:736:in `generate_extras'
     # /Users/vmcilwain/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:731:in `extra_keys'
     # /Users/vmcilwain/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_controller/test_case.rb:205:in `assign_parameters'
     # /Users/vmcilwain/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_controller/test_case.rb:616:in `process'
     # /Users/vmcilwain/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_controller/test_case.rb:65:in `process'
     # /Users/vmcilwain/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_controller/test_case.rb:523:in `put'
     # ./spec/controllers/app_engine/users_controller_spec.rb:115:in `block (4 levels) in <module:AppEngine>'
     # ./spec/support/shared_examples.rb:4:in `block (2 levels) in <top (required)>'

and the corresponding example

shared_examples "requires admin privilege" do
  it
'redirects to main app root if user is not an admin' do
    session
[:user_id] = FactoryGirl.create(:user)
    action
    expect
(response).to redirect_to main_app.root_path
 
end
end

Any help is greatly appreciated. I'm baffled by this :)
Reply all
Reply to author
Forward
0 new messages