如何使测试名称与控制器名称匹配?
How to make the test name match the controller name?
我有这个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)>'
这是怎么回事?
谢谢
我想你想念
require 'test_helper'
在文件的顶部。试一试。
我有这个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)>'
这是怎么回事?
谢谢
我想你想念
require 'test_helper'
在文件的顶部。试一试。