【发布时间】:2009-10-23 05:51:48
【问题描述】:
我有一个 application_controller 规范失败,因为我从 routes.rb 中删除了控制器/操作路由。我收到以下错误:
No route matches {:controller=>"application", :action=>"index"}
我有许多测试以同样的方式失败,但能够通过在 get 调用中包含正确的参数来修复它们。因此,例如,如果我想获得规范中帖子的标准显示路线,我必须进行更改
get :show to get :show, :id => '1'
不幸的是,我现在不确定应该为应用程序控制器规范传递什么。我在下面包含了我的测试。
describe ApplicationController do
it "should find the latest published posts and assign them for the view" do
Post.should_receive(:latest).and_return(@posts)
get :index
assigns[:posts].should == @posts
end
it "should find the latest approved comments and assign them for the view" do
Comment.should_receive(:latest).and_return(@comments)
get :index
assigns[:comments].should == @comments
end
end
【问题讨论】:
标签: ruby-on-rails rspec