rspec controller 出错
运行 spec/controller下的测试时,如果进入到spec/controller 目录下运行相关的spec,会出现undefined method get for #<ActiveSupport::TestCase::Subclass_1::Subclass_1:0xb6ec8cd4>
这样类似的错误,解决方法居然是从项目的根目录运行,即spec spec/controller/action_controller_spec.rb
。然后everything is ok.
解决方法是从一个老外的网站上找到,这里引用一下他的原话,看着这英文真是解气啊!
The problem was exactly in the path. I run my tests from spec/controllers folder where they didn’t work. From root folder everything goes right.
I found the solution, but i still don’t understand why, especially that my models tests works fine from user@user:~/application_folder/spec/models$ path