Don't use should validate_format_of(...)
because that matcher works in weird ways. Use the allow_value
matcher instead:
describe Email, '#sender' do
# > Rspec 3 should syntax
it { should allow_value("email@addresse.foo").for(:sender) }
it { should_not allow_value("foo").for(:sender) }
# Rspec 3 expect syntax
it { is_expected.to allow_value("email@addresse.foo").for(:sender) }
it { is_expected.not_to allow_value("foo").for(:sender) }
end
Errors that may occur if you do use should validate_format_of(...)
:
NoMethodError: private method `gsub' called for /\A[a-z0-9\-_]+\z/:Regexp
Posted by Henning Koch to makandra dev (2010-09-02 12:42)