RSpec send_file testing with Content-Type validation

I have a Rails controller that sends a file with a different Content-Type

Exel-File example, Content-Type = "application/excel" controller set

and here is the RSpec test:

 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 

Test Answer:

 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" 
+4
source share
1 answer

If you want (or already use) a gem with a mouse, then clip the paperclip into it

https://github.com/thoughtbot/paperclip/blob/master/shoulda_macros/paperclip.rb

and has a s3 boot method.

0
source

Source: https://habr.com/ru/post/1394749/


All Articles