Skip to content

Instantly share code, notes, and snippets.

@sephraim
Last active March 8, 2023 20:49
Show Gist options
  • Save sephraim/b087cefeca0a8052698e8fd65d1af1ef to your computer and use it in GitHub Desktop.
Save sephraim/b087cefeca0a8052698e8fd65d1af1ef to your computer and use it in GitHub Desktop.
[Test that a file gets downloaded in Rails] Use RSpec to test that a file gets downloaded in a Rails app
it 'downloads the file' do
expect(controller).to receive(:send_file).with(GooglePlacesApiClient::DEFAULT_CSV_FILEPATH, type: 'text/csv').and_call_original
get :download_report
end
# OR
it 'does not try to download the file' do
expect(controller).not_to receive(:send_file)
get :download_report
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment