小编Sta*_*tan的帖子

Rspec没有看到我的模型类.未初始化的常量错误

我正在为Ruby on Rails应用程序中的模型编写Rspec测试.我在启动'rspec spec'时收到此错误

command:
/spec/models/client_spec.rb:4:in `<top (required)>': uninitialized constant Client (NameError)
Run Code Online (Sandbox Code Playgroud)

我使用Rails 4.0.0和Ruby 2.0.0

这是我的client_spec.rb:

require 'spec_helper'


describe Client do

  it 'is invalid without first_name', :focus => true do
     client = Client.new
     client.should_not be_valid
  end
end
Run Code Online (Sandbox Code Playgroud)

和Gemfile:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0.rc1'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0.rc1'

# Use Uglifier as compressor for JavaScript assets …
Run Code Online (Sandbox Code Playgroud)

testing rspec model ruby-on-rails

81
推荐指数
6
解决办法
6万
查看次数

标签 统计

model ×1

rspec ×1

ruby-on-rails ×1

testing ×1