如何测试发送文件的 Controller Action ?

如果我使用controller.should_receive(:send_file)进行测试,则“Missing template”将失败,因为未呈现任何内容。

最佳答案

Googlingaround,看来render也会在某个时间点被调用..但是没有模板会导致错误。

解决方案似乎也是将其存根:

controller.stub!(:render)

关于ruby-on-rails - RSpec send_file测试,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4701108/

10-14 13:27
查看更多