RSpec redirect: Allow specifying a location through a block
This commit is contained in:

committed by
Sebastian Serth

parent
7f30fbe221
commit
740fc85bce
@ -37,8 +37,12 @@ def expect_json
|
|||||||
expect_content_type('application/json')
|
expect_content_type('application/json')
|
||||||
end
|
end
|
||||||
|
|
||||||
def expect_redirect(path = nil)
|
def expect_redirect(path = nil, &)
|
||||||
if path
|
if block_given?
|
||||||
|
it 'performs a redirect to the location given' do
|
||||||
|
expect(controller).to redirect_to(instance_eval(&))
|
||||||
|
end
|
||||||
|
elsif path
|
||||||
it "redirects to #{path}" do
|
it "redirects to #{path}" do
|
||||||
expect(controller).to redirect_to(path)
|
expect(controller).to redirect_to(path)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user