Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RSpec spec fails when invoked via "rake spec", passes when invoked via "spec spec"

One of my specs fails when I run it via "rake spec" but passes when I use the RSpec executable "spec". The spec fails when I use a url helper in a ActionMailer view. The error message is:

auction_url failed to generate from {:action=>"show", :state=>"asd", :slug=>"asd", :controller=>"auctions"}, expected: {:action=>"show", :controller=>"auctions"}, diff: {:state=>"asd", :slug=>"asd"}

:state and :slug are required attributes for the url, though. The route looks like this:

map.auction ':state/:slug', :controller => 'auctions', :action => 'show'

I set the host, which is needed to use the url helpers in ActionMailer views, in the environment files:

ActionMailer::Base.default_url_options[:host] = 'myhost.com'

What could be the problem? Why is "rake spec" behaving differently from "spec spec"? Anything that is loaded/not loaded when using one or the other?

like image 930
Manuel Meurer Avatar asked Mar 02 '10 16:03

Manuel Meurer


1 Answers

I realize this is a bit old, but anyway - I just ran into the same problem, not for the first time either. Then, when I started inserting debug statements into the failing spec to figure out what was going on - rake spec worked again. So I suspect some sort of caching going on when spec is involved with rake. If this occurs again, maybe try running

rake tmp:cache:clear

or even

rake tmp:clear
like image 193
Thilo Avatar answered Nov 07 '22 20:11

Thilo