I have a strange problem. rspec created a class called menus_routing_spec.rb in spec / routing
tests fail because the menu is a restaurant’s embedded resource.
this is my test:
describe MenusController do
before :each do
@restaurant = FactoryGirl.create(:random_restaurant)
@menu = FactoryGirl.create(:menu)
end
describe 'routing' do
it 'routes to #index' do
params = {}
params['restaurant_id'] = @restaurant
get restaurant_menus_path, { :restaurant_id => @restaurant.to_param }
expect(response).should route_to('menus#index')
end
the path in the routing of the rake is as follows:
restaurant_menus_path GET (/:locale)/restaurants/:restaurant_id/menus(.:format) menus
I always get the error message:
Failure/Error: get restaurant_menus_path, @restaurant.to_param
ActionController::UrlGenerationError:
No route matches {:action=>"index", :controller=>"menus"} missing required keys: [:restaurant_id]
I tried others ... but the same mistake .. can anyone see where I am making the mistake?
this is a test in spec / controllers / menus_controller_spec.rb that works fine
it 'renders the index template' do
get :index, { :restaurant_id => @restaurant }
expect(response).to render_template('index')
end
Many thanks for the help
damir source
share