Skip to content

Commit 7a494fc

Browse files
committed
add example 'when Rails::VERSION::MAJOR < 7'
1 parent 8ebe075 commit 7a494fc

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

spec/controllers/controller_spec.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,18 @@
201201
allow_any_instance_of(ActionController::TestRequest).to receive(:referer).and_return('http://test.host/referer_action')
202202
end
203203

204-
it 'uses Rails 7 redirect_back_or_to method' do
205-
get :test_return_to
204+
context 'when Rails::VERSION::MAJOR >= 7', skip: Rails::VERSION::MAJOR < 7 do
205+
it 'uses Rails 7 redirect_back_or_to method' do
206+
get :test_return_to
207+
208+
expect(response).to redirect_to('http://test.host/referer_action')
209+
end
210+
end
206211

207-
expect(response).to redirect_to('http://test.host/referer_action')
212+
context 'when Rails::VERSION::MAJOR < 7', skip: Rails::VERSION::MAJOR >= 7 do
213+
it 'raise NoMethodError' do
214+
expect { get :test_return_to }.to raise_error(NoMethodError)
215+
end
208216
end
209217
end
210218

0 commit comments

Comments
 (0)