我是测试和特别是rspec的新手。我正在尝试在我们为API构建的控制器上测试索引操作。
控制器本身位于../ app / controllers / my_api / api_controller.rb
../规格/控制器/ my_api / api_controller_spec.rb
require 'spec_helper'
describe MyApi::ApiController do
render_views
describe 'GET index' do
it 'returns a list of all available API endpoints' do
get :index, :format => :json
response.should be_success
end
end
end
运行测试后,我收到以下错误:
api_controller_spec.rb:4:in `block in <top (required)>': undefined local variable or method `render_views' for #<Class:0x007ffafd532a78> (NameError)
有人可以帮忙吗?