diff options
Diffstat (limited to 'spec/validators/addressable_url_validator_spec.rb')
-rw-r--r-- | spec/validators/addressable_url_validator_spec.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/spec/validators/addressable_url_validator_spec.rb b/spec/validators/addressable_url_validator_spec.rb index 394ffc7bbea..ec3ee9aa500 100644 --- a/spec/validators/addressable_url_validator_spec.rb +++ b/spec/validators/addressable_url_validator_spec.rb @@ -19,18 +19,20 @@ RSpec.describe AddressableUrlValidator do it 'returns error when url is nil' do expect(validator.validate_each(badge, :link_url, nil)).to be_falsey - expect(badge.errors.first[1]).to eq validator.options.fetch(:message) + expect(badge.errors.added?(:link_url, validator.options.fetch(:message))).to be true end it 'returns error when url is empty' do expect(validator.validate_each(badge, :link_url, '')).to be_falsey - expect(badge.errors.first[1]).to eq validator.options.fetch(:message) + expect(badge.errors.added?(:link_url, validator.options.fetch(:message))).to be true end it 'does not allow urls with CR or LF characters' do aggregate_failures do urls_with_CRLF.each do |url| - expect(validator.validate_each(badge, :link_url, url)[0]).to eq 'is blocked: URI is invalid' + validator.validate_each(badge, :link_url, url) + + expect(badge.errors.added?(:link_url, 'is blocked: URI is invalid')).to be true end end end @@ -113,7 +115,7 @@ RSpec.describe AddressableUrlValidator do it 'does block nil url with provided error message' do expect(validator.validate_each(badge, :link_url, nil)).to be_falsey - expect(badge.errors.first[1]).to eq message + expect(badge.errors.added?(:link_url, message)).to be true end end @@ -126,7 +128,7 @@ RSpec.describe AddressableUrlValidator do subject - expect(badge.errors.first[1]).to eq 'is not allowed due to: Only allowed schemes are http, https' + expect(badge.errors.added?(:link_url, 'is not allowed due to: Only allowed schemes are http, https')).to be true end end |