Content-Type が異なるファイルを送信する Rails コントローラーがあります。
Exel-File の例、コントローラ セット Content-Type ="application/excel"
RSpec テストは次のとおりです。
describe "GET getfile" do
it "Excel File" do
controller.stub(:render)
controller.should_receive(:send_file)
get :getfile, :name => 'test+xls'
controller.response.header.should == '???'
end
end
テストからの答えは次のとおりです。
1) ExportController GET getfile Excel File
Failure/Error: controller.response.header.should == ''
expected: ""
got: {"Content-Type"=>"text/html; charset=utf-8"} (using ==)
Diff:
@@ -1,2 +1,2 @@
-""
+"Content-Type" => "text/html; charset=utf-8"