BartlomiejSkwira
5/7/2013 - 10:05 AM

Test file download dialog in Capybara/Rack::Test

Test file download dialog in Capybara/Rack::Test

page.response_headers['Content-Type'].should == "application/gpx+xml" 
page.response_headers['Content-Disposition'].should =~ /attachment/
page.response_headers['Content-Disposition'].should =~ /#{@route.gpx_file_name}/

#if you can't stub a file create an upload

filename = "lol.jpg"
    path = "#{Rails.root}/spec/fixtures/files/#{filename}"
    upload = ActionDispatch::Http::UploadedFile.new({
      :filename => filename,
      :content_type => 'image/jpeg',
      :tempfile => File.new(path)
    })