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:
describe "#abc" do
before(:each) do
@meth = :abc
helper.request.env['HTTP_USER_AGENT'] = "..."
end
it "should return the webstart jnlp file" do
@obj.send(@meth, "some_url").should ....
end
end
When I run the spec I have this error:
undefined local variable or method `request' for <ObjectWithDocHelperMixedIn:0x00000103b5a7d0>
How do I stub for request.env['...'] in my specs?
Thanks.
If you're using rspec-rails, you might be able to use controller.request
in your helper tests.