【发布时间】:2012-09-21 09:39:41
【问题描述】:
我有一个助手可以访问request.fullpath。在隔离的辅助测试中,request 不可用。我该怎么办?我可以以某种方式嘲笑它或类似的东西吗?
我正在使用最新版本的 Rails 和 RSpec。这是我的助手的样子:
def item(*args, &block)
# some code
if request.fullpath == 'some-path'
# do some stuff
end
end
所以有问题的代码行是 #4,其中帮助程序需要访问在帮助程序规范中不可用的 request 对象。
非常感谢您的帮助。
【问题讨论】:
-
你的 spec_helper.rb 中有“require 'rspec/rails'”吗?
标签: ruby-on-rails testing rspec