我有以下 Rspec 声明:
it "requires a valid email address" do
should disallow_value("@email.com", "email.com", "my@email",
"my@e_mail.com", "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1e73673f5e7b737f7772307d7173" rel="noreferrer noopener nofollow">[email protected]</a>", "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>
我的 Shoulda 版本是:
shoulda (3.5.0)
shoulda-context (1.1.6)
shoulda-matchers (2.4.0)
知道出了什么问题吗?
更新:
gem 文件:
group :development, :test do
gem 'rspec-rails'
gem 'factory_girl_rails'
end
group :test do
gem 'shoulda-matchers'
end
最佳答案
这很有趣。 README file was rewritten 2013 年 11 月添加了 disallow_value
的文档,但尽管 DisallowValueMatcher
module致力于实现这样一个匹配器,spec for it不包括任何 disallow_value
方法的使用。我提交了issue against the shoulda-matchers gem
等待更多信息,我建议使用 should_not allowed_value
作为替代方案。
更新:这已被 shoulda gem 维护者确认为文档中的错误。
关于ruby-on-rails - #<RSpec::Core::ExampleGroup::Nested_1:0x0000000a4b3a98> 的未定义方法 `disallow_value',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20828010/