Last Updated: February 19, 2025
·
3.713K
· tmartin314

Set user agent for rspec controller tests

In controller specs, you can just modify the Rack environment before making your request:

request.env['HTTP_USER_AGENT'] = 'Googlebot'
get :index