在我的帮助模块中,我有:
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['...'] ?
Thanks.
如果您正在使用rspec-rails https://github.com/rspec/rspec-rails,你也许可以使用controller.request
在你的帮助测试中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)