Last active
June 21, 2022 19:18
-
-
Save slayer/51f8c00f2c9ad3f5fcbb36e8b72e28b8 to your computer and use it in GitHub Desktop.
Rails Rspec helper for turbo (hotwire)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe SomeController, type: :controller do | |
context 'turbo' do | |
include_context 'turbo_requests' | |
it 'should be successful' do | |
post :action | |
expect(response).to be_successful | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/support/turbo_helper.rb | |
shared_context 'turbo_requests' do | |
# perform requests as turbolinks | |
before do | |
request.headers['HTTP_TURBO_FRAME'] = 'true' | |
request.headers['HTTP_ACCEPT'] = "text/vnd.turbo-stream.html, text/html, application/xhtml+xml" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment