#lcpec :: core :: examplegroup :: nested_1的未定义方法`disallow_value':0x0000000a4b3a98> </rspec :: core :: examplegroup :: nested_1:0x0000000a4b3a98>

时间:2013-12-29 17:26:11

标签: ruby-on-rails ruby rspec shoulda

我有以下Rspec声明:

it "requires a valid email address" do
  should disallow_value("@email.com", "email.com", "my@email",
    "my@e_mail.com", "my!@email.com", "my @email.com").for(:email)
end

当我运行测试时,此语句始终失败:

Failure/Error: should disallow_value("@email.com", "email.com", "my@email",
NoMethodError:
   undefined method `disallow_value' for #<RSpec::Core::ExampleGroup::Nested_1:0x000000090ea4a8>

My Shoulda版本是:

shoulda (3.5.0)
shoulda-context (1.1.6)
shoulda-matchers (2.4.0)

知道出了什么问题吗?

更新:

的Gemfile:

group :development, :test do
  gem 'rspec-rails'
  gem 'factory_girl_rails'
end

group :test do
  gem 'shoulda-matchers'
end

1 个答案:

答案 0 :(得分:3)

这很有趣。 2013年11月的README file was rewritten包含disallow_value的文档,但尽管DisallowValueMatcher module致力于实现此类匹配器,spec for it不包含issue against the shoulda-matchers gem的任何使用1}}方法。我提交了{{3}}

有关此问题的更多信息,我建议您使用disallow_value作为替代方案。

更新:这已被shoulda gem维护者在文档中确认为错误。