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 :)
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/129f1020-9d76-4764-afbe-0749127874fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.