似乎唯一可行的就是做这样的事情
let(:request){ stub('request', :fullpath => '/path/to/place?arg=value') }
it 'blah blah' do
...
end
对我来说,问题是我想在测试中间更改这个值,但似乎没有一个简单的方法可以做到这一点
具体来说
helper.request.path = '/search?search_type=question'
不起作用。我明白了
undefined method `fullpath=' for #<ActionController::TestRequest:0x007fe203e47d88>
PS:是的,我检查了Rails: test a helper that need to access the Rails environment (eg request.fullpath),除了 let 指令似乎没有任何作用