I have the following in Rspec
response.should redirect_to %r{\A/my_settings/mysub_path/}
I get the following error
NoMethodError: undefined method `model_name' for Regexp:Class
I just need to match a part of my path which contains my_settings/mysub_path. How is this achieved in rspec?
To check the redirect against a regex do a string match on the response.location, like so:
expect(response.location).to match('your_expected_location.com')
redirect_to expects a string or an active record model.
if you want to match something, you can use response.location
Here's another simple way to do it:
response.location.should =~ /whatever_you_want_to_match/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With