Reputation: 735
I am having some trouble writing a spec for some of my routes. I run into this problem with pretty much any rails match route. Here's the code:
in routes.rb
match "/:id" => "home#order"
in home_controller.rb
def order
respond_to do |format|
format.html { render :layout => 'order' }
end
end
in home_controller_spec.rb:
it "should render the order layout" do
get :order
response.layout.should == 'layouts/order'
end
rake routes has:
/:id(.:format) {:controller=>"home", :action=>"order"}
However, the spec is throwing this exception:
1) HomeController when not signed in should render the order layout
Failure/Error: get :order
ActionController::RoutingError:
No route matches {:controller=>"home", :action=>"order"}
What am I doing wrong?
Upvotes: 2
Views: 948
Reputation: 11076
I think
get :order
would only work if you were using named routes. Try just
get "/1"
Upvotes: 2