Search code examples
ruby-on-railsrspecsendfile

RSpec send_file testing


How to test a controller action that sends a file?

If I do it with controller.should_receive(:send_file) test fails with "Missing template" because nothing gets rendered.


Solution

  • From Googling around, it appears that render will also be called at some point .. but with no template, will cause an error.

    The solution seems to be to stub it out as well:

    controller.stub!(:render)