nathanvda
2011-Apr-07 14:37 UTC
[rspec-users] getting weird "no route matches" error, using rspec2 and rails3 (just migrated) but app works
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?
nathanvda
2011-Apr-08 07:00 UTC
[rspec-users] getting weird "no route matches" error, using rspec2 and rails3 (just migrated) but app works
> > 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. >[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.
nathanvda
2011-Apr-08 07:08 UTC
[rspec-users] getting weird "no route matches" error, using rspec2 and rails3 (just migrated) but app works
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 ????
nathanvda
2011-Apr-08 13:01 UTC
[rspec-users] getting weird "no route matches" error, using rspec2 and rails3 (just migrated) but app works
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.