在我的辅助模块中,我有:
def abc(url)
...
if request.env['HTTP_USER_AGENT']
do something
end
end
在我的规范文件中,我有:
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
当我运行这个规范时,我遇到了这个错误:
undefined local variable or method `request' for <ObjectWithDocHelperMixedIn:0x00000103b5a7d0>
我该如何在我的测试中为request.env['...']进行桩测试?
谢谢。