[rspec-users] rspec doesnt recognize a custom mime type

David Chelimsky dchelimsky at gmail.com
Thu Apr 29 09:00:22 EDT 2010

On Apr 29, 2010, at 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?

Definitely. I believe what's happening is that the options hash produced by the Rails router is a hash with indifferent access (allows you to access any key as a symbol or a string), but the test helper methods (get, post, etc) don't do the same thing.

Glad you solved it.


More information about the rspec-users mailing list