Hello fellow testers,
I'm adding tests to an app that needs to redirect a lot of legacy URLs, and
was surprised that routing specs do not natively allow testing redirection.
Since Rails `routes.rb` allows both routing _and_ redirecting, I presumed
that routing specs would also handle both. I know controller and request
specs handle redirection, but it feels weird to split tests like this, as
it would lead to split my tests into request and routing specs though the
path are very similar, and it's a functional unit.
I was able to test redirection by including
`RSpec::Rails::RequestExampleGroup` in my routing specs but that feels
weird too, and the syntax is a little different: `get '/path'` versus `get:
'/path'`.
I'd feel more comfortable if I could natively write in the same file:
```
expect(get: '/blog/2018/01/slug').to route_to('posts#show')
expect(get: '/cms/2018/01/slug').to redirect_to('/blog/2018/01/slug')
```
Is there a cleaner workaround, or is it something which could be added to
rspec-rails?
- Ruby version: 2.5.8
- Rails version: 6.1.3.1
- RSpec version: 3.10.1
- RSpec-Rails version:5.0.1
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/e270ea61-5cdf-44ef-881c-37db783e75dan%40googlegroups.com.