我想用 rspec 测试 API 控制器。所以这是一段简单的代码:
require 'rails_helper'
describe "GET /api/config" do
it 'routes GET to /api/config to Api::V1::ConfigsController#show' do
get '/api/config.json'
expect(response).to be_success
end
end
但我有一个错误:
1) Configs API GET /api/config routes GET to /api/config to Api::V1::ConfigsController#show
Failure/Error: expect(response).to be_success
NameError:
undefined local variable or method `response' for #<RSpec::ExampleGroups::ConfigsAPI::GETApiConfig:0x007f84d93fbb90>
# ./spec/routing/api/v1/devise/configs_routing_spec.rb:13:in `block (3 levels) in <top (required)>'