[rspec-users] undefined method `route_for' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:

David Chelimsky dchelimsky at gmail.com
Mon Aug 30 19:49:58 EDT 2010


On Aug 30, 2010, at 9:36 AM, sleepwalker wrote:

> Hello, all, I have this error with my rspec - controller - test, and
> yes, I do found the thread with the same error here, but it isn't
> helped me, think it's not my case.
> 
> i have rails -v = Rails 3.0.0.rc, rspec -v = 2.0.0.beta.18 (hope they
> should match each other).
> 
> my test is here: spec/controllers/posts_controller_spec.rb and i ran
> it with command: rspec spec/controllers/posts_controller_spec.rb.
> 
> after all, test is:
> 
> require 'spec_helper'
> 
> describe PostsController do
>  render_views
>  describe "route generation" do
> 
>    it "should be successful" do
>      @post = Post.new(:title => 'blalbla', :name => 'adfsdfsdf')
>      @post.save
>      route_for(:controller => "posts", :action => "show", :id =>
> @post.id, :method => 'GET').should == "/posts/show" + @post.id.to_s
>    end
>  end
> end
> 
> I have Post model and it works just fine (rspec tested fine as well).
> And the route is (from rake routes):
> GET    /posts/:id(.:format)
> {:controller=>"posts", :action=>"show"}
> 
> Can anybody tell me, where the things going wrong for a such answer
> (undefined method...) Thanks!

route_for is gone

See the section on Routing specs on http://github.com/rspec/rspec-rails for how to do routing specs. I'll add a note that route_for is gone.

Cheers,
David


More information about the rspec-users mailing list