测试 rspec 测试:NameError: uninitialized constant User

zhangyanan · June 26, 2014 · 2521 hits

新建的项目测试 rspec,运行的时候提示,需要引入什么吗?

user_controller_spec.rb
describe "GET index" do
  it "assigns all users as @users" do
    user = User.create! valid_attributes
    get :index, {}, valid_session
    assigns(:users).should eq([user])
  end
end
No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.