# Getting weird "no route matches" error, using rspec2 and rails3 (just migrated) but app works

**URL:** <https://www.ruby-forum.com/t/getting-weird-no-route-matches-error-using-rspec2-and-rails3-just-migrated-but-app-works/205493>\
**Category:** RSpec\
**Created:** [April 7, 2011, 4:48pm UTC](https://www.ruby-forum.com/t/getting-weird-no-route-matches-error-using-rspec2-and-rails3-just-migrated-but-app-works/205493 "2011-04-07T16:48:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 7, 2011, 4:48pm UTC](https://www.ruby-forum.com/t/getting-weird-no-route-matches-error-using-rspec2-and-rails3-just-migrated-but-app-works/205493/1 "2011-04-07T16:48:54Z")

</div>

Hi there,

in my main view i have a link to the root\_path, which converts to

```
{:controller => "home", :action => :index}

```

In every spec i run, i get the error:

```
No route matches {:controller=>"home"}

```

While if i run the application in development, everything renders  
without any problem and is clickable correctly.

Does anybody have any clues as to what i did wrong?

I should add that the rails application is in the process of being  
migrated from rails 2.3.11 to rails 3.  
I must have overlooked something, but i can’t see what.

Does anybody have any tips?

---

<div class="post-metadata">

**Author:** ![nathanvda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/57b2e6/32.png) [@nathanvda](https://www.ruby-forum.com/u/nathanvda)\
**Post date:** [April 8, 2011, 9:12am UTC](https://www.ruby-forum.com/t/getting-weird-no-route-matches-error-using-rspec2-and-rails3-just-migrated-but-app-works/205493/2 "2011-04-08T09:12:05Z")

</div>

More information:

If i run

```
rspec spec/**/*_spec.rb

```

I suddenly get the same errors as when using `rake spec`. So???

```
rspec spec/controllers/user_controller/*_spec.rb

```

gives all green, and with the first command those same specs fail ???

---

<div class="post-metadata">

**Author:** ![nathanvda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/57b2e6/32.png) [@nathanvda](https://www.ruby-forum.com/u/nathanvda)\
**Post date:** [April 8, 2011, 9:37am UTC](https://www.ruby-forum.com/t/getting-weird-no-route-matches-error-using-rspec2-and-rails3-just-migrated-but-app-works/205493/3 "2011-04-08T09:37:22Z")

</div>

> without any problem and is clickable correctly.

[EDIT: more findings]

I have done some more digging. The test run perfectly fine in  
Rubymine, or if i use the command-line and type

```
rspec spec/controllers/users_controller/*.spec.rb

```

But they do not work if I use

```
rake spec

```

What is the difference? I have deleted the `lib/tasks/rspec.rake` file  
(which was generated for rspec1) and i can see that the correct  
command is executed:

```
bundle exec rspec

```

So I am a bit at a loss here.

---

<div class="post-metadata">

**Author:** ![nathanvda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/57b2e6/32.png) [@nathanvda](https://www.ruby-forum.com/u/nathanvda)\
**Post date:** [April 8, 2011, 3:35pm UTC](https://www.ruby-forum.com/t/getting-weird-no-route-matches-error-using-rspec2-and-rails3-just-migrated-but-app-works/205493/4 "2011-04-08T15:35:05Z")

</div>

I found it! It took my a while, eventually i diffed the log-files that  
see what happens differently.

Apparently I have on spec file, where we try to test a baseclass.  
Inside that spec we define a new controller that derives  
from that baseclass, with a dummy index method.

And also we need the routes, so inside that spec the following code  
was to be found:

```
ActionController::Routing::Routes.draw do |map|
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
end

```

and somehow this spec was always run first. This effectively clears  
the whole routing configuration i guess.

Not sure if this change is caused by rails3 or rspec2, anyway the  
majority of my tests are now working, just need to fix this one  
test now.
