Ruby on rails 如何使测试名称与控制器名称匹配?

Ruby on rails 如何使测试名称与控制器名称匹配?,ruby-on-rails,ruby,minitest,Ruby On Rails,Ruby,Minitest,我有这个用户\u控制器 class Api::V1::UsersController < ApplicationController respond_to :json def show respond_with User.find(params[:id]) end end 文件位于test/controllers/api/v1 当我运行测试时,出现以下错误: NameError: uninitialized constant Api /Users/Ahmad/ra

我有这个
用户\u控制器

class Api::V1::UsersController < ApplicationController
  respond_to :json

  def show
    respond_with User.find(params[:id])
  end

end
文件位于
test/controllers/api/v1

当我运行测试时,出现以下错误:

NameError: uninitialized constant Api
/Users/Ahmad/rails_apps/json_api/test/controllers/api/v1/users_controller_test.rb:1:in `<top (required)>'
NameError:未初始化的常量Api
/Users/Ahmad/rails\u apps/json\u api/test/controllers/api/v1/Users\u controller\u test.rb:1:in`'
发生什么事了

谢谢

我想你错过了

require 'test_helper'
在文件的顶部。试试看

require 'test_helper'