Forum: RSpec undefined method `route_for' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:

Posted by sleepwalker (Guest)
on 2010-08-31 01:44
(Received via mailing list)
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!
Posted by David Chelimsky (Guest)
on 2010-08-31 01:58
(Received via mailing list)
On Aug 30, 2010, at 9:36 AM, sleepwalker wrote:

> after all, test is:
>      route_for(:controller => "posts", :action => "show", :id =>
> 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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.