the*_*pod 22 ruby ruby-on-rails functional-testing fixtures recycle
我有一个使用灯具的功能测试.我也在我的单元测试中使用灯具,但它们没有缺陷.运行功能测试时,我得到一个:
NoMethodError: undefined method 'recycle!' for #<Response:0x10346be10>
/test/functional/responses_controller_test.rb:10:in 'test_testing'
到目前为止,我的功能测试只是进行索引操作.例:
setup do
@response = responses(:one)
end
test "testing" do
get :index
assert true
end
Run Code Online (Sandbox Code Playgroud)
我的TestHelper类确实包含了所有灯具,因此响应灯具肯定会加载.就像我说的那样,灯具在单元测试中运行得非常好.
知道可能导致这种情况的原因吗?
小智 44
更改
setup do
@response = responses(:one)
end
Run Code Online (Sandbox Code Playgroud)
至
setup do
@myresponse = responses(:one)
end
Run Code Online (Sandbox Code Playgroud)
然后你走吧!
问题在于第386行的"actionpack-3.0.1/lib/action_controller/test_case.rb".
测试用例假定@response持有"ActionDispatch :: Response".你覆盖它,它不再是"ActionDispatch :: Response"而且测试用例失败了.
我不确定这是否是预期的行为.
无论如何,只要确保你没有覆盖@ response/@ request/@ controller/@ routes就可以了.
| 归档时间: |
|
| 查看次数: |
2153 次 |
| 最近记录: |