views:

223

answers:

1

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?

A: 

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". Let me know if that works,.

Thilo
Or better rake tmp:clear
Thilo