*** RuntimeErrorexception:ActionView :: Helpers :: ControllerHelper#response委托给controller.response,但是控制器是nil

当我尝试运行端点的api规范时,我遇到了一个问题。 当我运行规范并检查响应时,它说:

*** RuntimeError Exception: ActionView::Helpers::ControllerHelper#response delegated to controller.response, but controller is nil: #<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1:0x007faeb4852b08 

我在controllers / api / v1 / catalog_controller.rb下有一个控制器

 class Api::V1::CatalogController < ApplicationController def search ...some stuff here... render json: {some_response} end end 

它的匹配规范在spec / controllers / api / v1 / catalog_controller_spec.rb下

 describe Api::V1::CatalogController do describe "searching" do before(:all) do @title = FactoryGirl.create(:title, {name: "Test Title"}) @author = FactoryGirl.create(:author, last_name: "Smith") @edition = FactoryGirl.create(:edition, title: @title, writer_id: @author.id) end context "#search" do it "should return the given titles for a single word search" do get :search, {search_terms: {term: 'smith'}} expect(response).status.to eql(200) return_value.body.should == {titles: [@title]} end end end end 

知道我可能做错了吗?

我通过删除该行解决了这个问题

  config.include ActionView::Helpers 

来自我的spec_helper.rb配置块。 我猜这是相互矛盾的。 我不是非常确定为什么所以任何进一步的见解都会很棒。