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

sleepwalker krivich.ekaterina at gmail.com
Mon Aug 30 10:36:13 EDT 2010

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
  describe "route generation" do

    it "should be successful" do
      @post = Post.new(:title => 'blalbla', :name => 'adfsdfsdf')
      route_for(:controller => "posts", :action => "show", :id =>
@post.id, :method => 'GET').should == "/posts/show" + @post.id.to_s

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!

More information about the rspec-users mailing list