RSpec的测试主应用程序无法找到安装的发动机
问题描述:
我有安装发动机在routes.rb中,像这样的应用程序:RSpec的测试主应用程序无法找到安装的发动机
mount Quby::Engine => "/quby", :as => "quby_engine"
它有一个控制器动作,做这个:
def collect_answers
# do a bunch of stuff and then
redirect_to quby_engine.edit_questionnaire_answers_path(questionnaire)
end
这样确实可以在浏览器中,但是对于我的行动RSpec的控制器测试:
it 'should redirect to something' do
get :collect_answers, :key => "honos"
response.should redirect_to("something")
end
失败,出现消息:
Failure/Error: get :collect_answers, :key => "honos"
undefined local variable or method `quby_engine' for #<EvaluateController:0x00000007245c50>
我是否需要做一些特殊的事情才能让引擎安装在我的控制器测试中?
编辑:没关系,我想我有一个Spork服务器正在运行,但没有重新载入新的安装的应用程序。
答
你有没有尝试添加
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
在你spec_helper.rb建议一样在Testing Rails 3.1 mountable engine with Rspec?