Rspec-rails 2.0.0.beta.12 showing undefined method error for route_to

First of all, I’ve been trying to find an answer for this problem all
over the internet without luck.

The thing is that I am using RVM with ruby 1.9.2-head and I created a
new empty gemset. Then I installed bundler gem with:

gem bundler install

That installed the library into the /Users/damselem/.rvm/gems/
ruby-1.9.2-head@rails3/gems directory. Then I went to my rails 3 app
directory and I ran “bundle install” which showed this:

http://gist.github.com/446011

and when I ran gem list I got:

http://gist.github.com/446005

Everything seems perfect, but when running some route specs I got an
undefined method error for route_to method. I’ve checked in the github
repository and it actually exists. So I decided to look inside the
library but I couldn’t find the /rspec/rails/matchers/
routing_spec_matchers.rb directory and either the matchers directory.
So, my question is: Why is not the file in there? Why is not the
matchers directory either?

Then I found under /Users/damselem/.rvm/gems/ruby-1.9.2-head@rails3/ a
bundler directory with some gems, and with folder names like:

devise-d498cf3a4e1a3fef3f4f071d4feec6a489efe480-master
formtastic-8ab93b34c3a97eee21e38185e14bed2f769c81e5-rails3
shoulda-b78dbf514bbce3272023d3a4742474857c2eb3c3-master

Why is that? Why there are two different directories for gems? Why are
devise, formtastic and shoulda not in the gems directory?

Thank you very much, and sorry for asking so many questions, but I’m
quite lost with all this.

I forgot to add the error:

  1. AccountsController Routes should route to new action with GET
    Failure/Error: { :get => “/accounts/new” }.should
    route_to(:controller => “accounts”, :action => “new”)
    undefined method `route_to’ for
    #RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x000001088836c8

    /Users/damselem/.rvm/gems/ruby-1.9.1-p378@rails3/gems/

actionpack-3.0.0.beta4/lib/action_dispatch/testing/assertions/
routing.rb:175:in method_missing' # ./spec/controllers/accounts_controller_spec.rb:8:in block (3
levels) in <top (required)>’

On Jun 20, 8:58 pm, Daniel Salmeron A. [email protected]

Daniel, your post saved my day!

I got the same undefined method `route_to’ error with rspec-rails
v2.0.0.beta.12 and did not understand why …

Seems like this method has been added after the v2.0.0.beta.12 tag.
You’ll have to use the tip of the repo to get that working, until
v2.0.0.beta.13 or RC is out

Daniel A. wrote:

Hmm… So what do you have in your gemfile? Just gem rspec-rails,
without the version? Do you know why there are some gems that are
installed in the bundler directory? Thank you very much !

In my gem file, for rspec-rails
gem ‘rspec-rails’, :git => ‘GitHub - rspec/rspec-rails: RSpec for Rails 5+

what you see in the bundler dir are, AFAIK, gem specified with git
repos, just like the line above. (ie : gems build from source by
bundler)

Hmm… So what do you have in your gemfile? Just gem rspec-rails,
without the version? Do you know why there are some gems that are
installed in the bundler directory? Thank you very much !

On Jun 23, 2010, at 8:16 AM, Julien P. wrote:

bundler)
Keep a couple of things in mind that when you use this approach:

  1. You are using unreleased software. Expect additional headaches, but
    please report them so we know what’s broken.
  2. You have to run ‘bundle install’ or ‘bundle update’ to get the latest
    code.

Cheers,
David

Ok, thanks!

That would make sense if I installed some gems via “gem install” and
other using “bundle install”, right? In my case I installed all gems
using bundler. Don’t know…

Anyways, thanks.

One of the problems could be that your routing specs is in the wrong
directory. Make sure all your routing specs go into ‘spec/routing’
directory. Hope that helps.