On 2010-04-29 7:40 AM, jollyroger wrote:
Ok,

fixed it, in a nutshell:

Doesnt work:

get :new, :format =>  :lightbox

Works:

get :new, :format =>  'lightbox'

What was really confusing was that in BOTH cases the same URL appeared
in the log.

Here is my turn on what happened:

Internally - when rails sees a mime-type / format - rails
distinguishes between a string and a symbol, saying that when using
something like

respond_to do |format|
   format.lightbox {}
end

"lightbox" is expected to be a string.

When doing a normal request via a browser I passed in the format in
the URL, so as a string.
When running a spec apparently this is passed directly the way I wrote
it, so as a symbol.

That's why one and the same URL worked in the browser, but not in my
spec.

Does this sound plausible?

Perfectly. I struggled with this a couple of months ago doing something like:

get :show, {:id => 1}

and whatever it was in my controller wasn't expecting an integer, so I had to change it to:

get :show, {:id => '1'}

and it was fine. As I dug into it, I noticed that the params hash in controllers has everything as strings, and then the light bulb went on in my head. Since then, I've paid more attention to what the params hash in my specs looks like. And I'm sure you will, too :)

Peace,
Phillip
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to