【发布时间】:2014-10-07 10:17:10
【问题描述】:
我的目标是对axlsx-rails gem 生成的文件运行规范,并使用我找到的自定义 rspec 匹配器 here。
在我的规范示例中,我有:
describe Statistic::CompanyTableSetsController do
login_user # this just for Devise Auth
it "generates a proper excel sheet" do
...
get "show", format: :xlsx, id: id
response.content_type.to_s.should eq Mime::Type.lookup_by_extension(:xlsx).to_s
end
end
但是当我运行测试时,我得到:
Failure/Error: response.content_type.to_s.should eq Mime::Type.lookup_by_extension(:xlsx).to_s
expected: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
got: "text/html"
当然,我无法在其他规范示例中获得工作表...
我想我在这里错过了什么,因为在我的浏览器中,Excel工作表是正常生成的。
感谢您的帮助。
【问题讨论】:
标签: ruby-on-rails-4 rspec axlsx