On Tue, Mar 25, 2008 at 11:38 AM, Seth Ladd <[EMAIL PROTECTED]> wrote:
> >  There is a guideline in TDD that you should test your code and not
>  >  other people's code. The behaviour you're interested in testing is
>  >  that of ActionController::Base, not of your code.
>
>  I, of course, do not want to test Rails.  I do, however, want to
>  ensure that I have a block to handle the correct MIME type and I have
>  a template for that MIME type.  I suppose checking for the template
>  "foo/show" is good enough in this case.  If there was an error, I'd
>  get a nil there.

If you're really concerned about it, you could also mock respond_to:

format = mock("format")
format.should_receive(:json).and_return("this text")
controller.should_receive(:respond_to).and_yield(format)
get 'path/to/file', :format => 'json'

That seems a bit implementation heavy, but it might give you the
feeling of confidence you're looking for.

HTH,
David

>
>  I guess where this strategy falls down is if I forgot to put a
>  responds_to in my controller.  Then, no matter the format, I'll still
>  render 'foo/show' (assuming I do indeed have that template)
>
>  Thanks for your help,
>
>
> Seth
>  _______________________________________________
>  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