当我试图为端点运行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知道我可能做错什么了吗?
发布于 2014-04-07 16:41:53
我已经通过删除行来解决这个问题
config.include ActionView::Helpers从我的spec_helper.rb配置块。我想这是自相矛盾的。我不太清楚为什么任何进一步的洞察力都会很棒。
https://stackoverflow.com/questions/22875355
复制相似问题