【发布时间】:2011-05-21 19:16:18
【问题描述】:
我在为我的某些路线编写规范时遇到了一些麻烦。我几乎在任何轨道匹配路线上都遇到了这个问题。代码如下:
在 routes.rb 中
match "/:id" => "home#order"
在 home_controller.rb 中
def order
respond_to do |format|
format.html { render :layout => 'order' }
end
end
在 home_controller_spec.rb 中:
it "should render the order layout" do
get :order
response.layout.should == 'layouts/order'
end
rake 路线有:
/:id(.:format) {:controller=>"home", :action=>"order"}
但是,规范抛出了这个异常:
1) HomeController when not signed in should render the order layout
Failure/Error: get :order
ActionController::RoutingError:
No route matches {:controller=>"home", :action=>"order"}
我做错了什么?
【问题讨论】:
标签: ruby-on-rails rspec routes