0
我的目标是运行由axlsx-rails gem生成的文件的规格,并使用自定义的rspec匹配器,我发现here。在axslx生成的文件上运行规格
在我的规格例如,我有:
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工作表正常生成。
谢谢你的帮助。