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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With