No route matches error with application_controller spec

Posted by Eric M. on Stack Overflow See other posts from Stack Overflow or by Eric M.
Published on 2009-10-23T05:51:48Z Indexed on 2010/06/17 12:03 UTC
Read the original article Hit count: 264

Filed under:

I have an application_controller spec that is failing since I removed the controller/action route from routes.rb. I get the following error:

No route matches {:controller=>"application", :action=>"index"}

I had many tests fail in the same way, but was able to fix them by including the correct parameters in the get call. So for instance, if I wanted to get the standard show route for posts in my spec, I had to change

get :show to get :show, :id => '1'

Unfortunately, I'm not sure now what to pass along for the application controller specs. I've included my test below.

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

© Stack Overflow or respective owner

Related posts about rspec