rspec test redirect_back code example
Example 1: redirect_back fallback_location root_path rspec
RSpec.describe InterestsController, type: :controller do
describe 'POST #create' do
context 'with valid attributes' do
it 'redirects to referer' do
from about_path
post :create, params: { interest: attributes_for(:interest) }
expect(response).to redirect_to about_url
end
end
end
end
Example 2: redirect_back fallback_location root_path rspec
RSpec.configure do |config|
config.include RedirectBack
end