In my helper module, I have:
def abc(url) ... if request.env[\'HTTP_USER_AGENT\'] do something end end
In my spec file, I have:
for those who use request specs instead of controller specs and want to set request.env can do it like this:
request.env
Rails.application.env_config["whatever"] = "whatever"
this will make request.env["whatever"] available in your controllers with value you gave it in your specs.
request.env["whatever"]