未定义的方法`allow_value'

时间:2014-04-03 14:39:01

标签: ruby-on-rails-4 rspec-rails

有宝石的问题' shoulda-matchers'在gem' rails',#4.1; 4.1.0.rc2',当我运行我的测试时出现错误

/Volumes/Khaya/myapp/spec/models/account_spec.rb:13:in `block (2 levels) in <top (required)>': undefined method `allow_value' for RSpec::ExampleGroups::Account_2::Validations:Class (NoMethodError)

我的宝石文件

gem 'rails', '4.1.0.rc2'


group :development, :test do
  gem 'guard'
  gem 'guard-livereload'
  gem 'rspec', '~> 3.0.0.beta2'
  gem 'rspec-rails', '~> 3.0.0.beta'
  gem 'guard-rspec', require: false
  gem 'capybara'
  gem 'factory_girl_rails'
  gem 'database_cleaner'
  gem 'minitest'
  gem 'shoulda-matchers'
end

group :development do
  #gem 'spring'
  gem 'better_errors'
  gem 'binding_of_caller', :platforms=>[:mri_19, :mri_20, :rbx]
  gem 'quiet_assets'
end

我的测试

it {should allow_value('vezu').for(:name)}

我无法弄清楚如何解决这个问题。我在配置上遗漏了什么吗?

1 个答案:

答案 0 :(得分:0)

我的错误我有这样的事情

it should_not allow_value('VEZU S').for(:name)

而不是

it {should_not allow_value('VEZU S').for(:name)}