2015-12-16 122 views
1

我有这个users_controller如何使测试名称与控制器名称相匹配?

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

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

end 

该文件是app/controllers/api/v1/

而且我的测试是:

class Api::V1::UsersControllerTest < ActionController::TestCase 

    test '#show displays the specific user' do 
    @user = FactoryGirl.build(:user) 

    get :show, id: @user.id 
    assert_response :success 
    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)>' 

发生了什么事?

感谢

回答

1

我觉得你在你的文件的顶部,错过

require 'test_helper' 

。试一下。

相关问题