Hm, of course, now that I have sent the previous email, I found the
bug in my code and have fixed it. So I know I am using RSpec
correctly with controllers and a respond_to block. Using the :format
=> 'json' attribute in my get call was all I needed.
However, not matter what the format I choose, the template rendered is
always "databases/show" (this is essentially correct behavior).
However, it's hard to determine which show was rendered:
show.json.erb or show.html.erb
I can check the content-type header, but that's not exactly what I'd
like to test.
Is there a better way to write a spec to ensure that the correct
template is rendered when I use certain formats?
Seth
On Mon, Mar 24, 2008 at 8:35 PM, Seth Ladd <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm having a hard time testing my controllers that use respond_to.
> I'm trying to test that I can correctly handle each MIME type on
> request.
>
> For instance, I have this:
>
> respond_to do |format|
> format.html
> format.json
> end
>
> And I've tried things like this:
>
> get 'show', :id => databases(:one).id, :format => 'json'
> response.should render_template('show')
>
> but I keep getting a nil template.
>
> I know this works in the code, when I try a URI like
> http://localhost:3000/foo.json
>
> Any tips for setting the format or MIME Type correctly so I can
> activate other respond_to blocks?
>
> Thanks very much,
> Seth
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users