I have the following Rspec statement:
it "requires a valid email address" do
should disallow_value("@email.com", "email.com", "my@email",
"my@e_mail.com", "[email protected]", "my @email.com").for(:email)
end
When I run my tests, this statement always fails with:
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 versions are:
shoulda (3.5.0)
shoulda-context (1.1.6)
shoulda-matchers (2.4.0)
Any idea what's going wrong?
UPDATE:
Gemfile:
group :development, :test do
gem 'rspec-rails'
gem 'factory_girl_rails'
end
group :test do
gem 'shoulda-matchers'
end
This is interesting. The README file was rewritten in November 2013 to include documentation for disallow_value
, but despite a DisallowValueMatcher
module devoted to implementing such a matcher, the spec for it doesn't include any use of the disallow_value
method. I submitted an issue against the shoulda-matchers gem
Pending more information on this, I'd recommend using should_not allow_value
as an alternative.
Update: This has been acknowledged as an error in the documentation by the shoulda gem maintainers.