I've got a request test in rspec that tests for several potential redirects from an endpoint, such as:
get registrations_path
expect(response).to redirect_to(new_registration_path)
In one case, I expect it to not redirect. Is there a way to negate the matcher redirect_to
? Or a matcher that explicitly asserts not_redirect
?
I've tried variations such as these, without success:
expect(response).not_to redirect_to(nil)
expect(response).not_to redirect
expect(response).to not_redirect
I do have other tests that test for specifics of a non-redirecting response...but I want this high-level test to flesh out a suite of redirect tests.
This isn't quite as tight as
.to not_redirect
, but is at least concise and obvious to understand:When the test fails, it gives a useful response: