I was doing this before in a rails 2 app in a ActionController::IntegrationTest
with
get '/', {}, {:user_agent => "Googlebot"}
but this seems to not work anymore in Rails 3.
What should I do?
If you use request.user_agent in your application, you can write the following code:
get '/', {}, { "HTTP_USER_AGENT" => "Googlebot" }
None of the above answers worked for me, the following is what finally worked in an rspec controller test:
@request.user_agent = "a MobileDevice/User-Agent" post :endpoint, param: 2354
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