主应用程序的RSpec测试无法找到已安装的引擎

时间:2011-12-13 12:49:23

标签: ruby-on-rails ruby rspec rails-engines

我有一个应用程序在其routes.rb中安装引擎,如下所示:

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服务器没有重新加载以安装新的应用程序。

1 个答案:

答案 0 :(得分:0)

您是否尝试过添加

   ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')

在您的spec_helper.rb中,如Testing Rails 3.1 mountable engine with Rspec中建议的那样?