-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from charles-jan/master
Email validator add custom options support
- Loading branch information
Showing
2 changed files
with
20 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ class EmailValidatorTest < Minitest::Test | |
|
||
def user_class( | ||
smtp: true, states: %i[deliverable risky unknown], free: true, role: true, | ||
accept_all: true, disposable: true, timeout: 3 | ||
accept_all: true, disposable: true, timeout: 3, **options | ||
) | ||
Class.new do | ||
include ActiveModel::Model | ||
|
@@ -15,7 +15,7 @@ def user_class( | |
smtp: smtp, states: states, | ||
free: free, role: role, disposable: disposable, accept_all: accept_all, | ||
timeout: timeout | ||
} | ||
}.merge(options) | ||
|
||
def self.name | ||
'TestClass' | ||
|
@@ -83,4 +83,16 @@ def test_timeout_option | |
assert_raises(ArgumentError) { invalid_user2.valid? } | ||
end | ||
|
||
def test_custom_option | ||
message = 'invalid message' | ||
invalid_user = user_class(message: message, reportable: true).new( | ||
email: '[email protected]' | ||
) | ||
|
||
refute invalid_user.valid? | ||
assert invalid_user.errors[:email].present? | ||
assert_equal message, invalid_user.errors[:email].first | ||
assert invalid_user.errors.where(:email, reportable: true).present? | ||
end | ||
|
||
end |