*** 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
知道我可能做错了吗?
答案 0 :(得分:1)
我已通过删除
行解决了这个问题 config.include ActionView::Helpers
来自我的spec_helper.rb配置块。我想这是相互矛盾的。我并不十分清楚为什么这么进一步的见解会很棒。