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:
Try this:
stub(request).env { {"HTTP_USER_AGENT" => "Some String"} }