【发布时间】:2013-05-20 10:33:17
【问题描述】:
我的控制器中有以下用于导出 csv 文件的代码
...
def export
@filename = 'users.csv'
@output_encoding = 'UTF-8'
@users = User.active_users #not the actual scope but this only returns active
respond_to do |format|
format.csv
end
end
...
我的规范中有以下内容
it "should only return active users"
get :export, :format => :csv
# i want to check that my mocked users_controller#export is only returning the active users and not the inactive ones
end
response.body 在我检查时在此测试中为空。当在浏览器中点击此操作时,我将如何获取下载的规范中的 csv 文件,以便我可以检查结果?我在试图弄清楚这一点时遇到了一些困难。
感谢您提供的任何帮助。
【问题讨论】:
标签: ruby-on-rails-3 rspec rspec-rails respond-to