Skip to content

Commit

Permalink
Merge pull request #130 from jovanmaric/features/refine_v3_documentation
Browse files Browse the repository at this point in the history
Readme: Add disposable stub and extend the v3 update section
  • Loading branch information
micke authored May 19, 2019
2 parents 78f9676 + c866b95 commit 68be972
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,16 @@ It is a good idea to stub out that validation in your test environment.
Do so by adding this in your `spec_helper`:
```ruby
config.before(:each) do
allow_any_instance_of(ValidEmail2::Address).to receive(:valid_mx?) { true }
allow_any_instance_of(ValidEmail2::Address).to receive(:valid_mx?).and_return(true)
end
```

Validating `disposable` e-mails triggers a `mx` validation alongside checking if
the domain is disposable. The above stub does not apply to the `disposable`
validation and should therefore be individually stubbed with:
```ruby
config.before(:each) do
allow_any_instance_of(ValidEmail2::Address).to receive(:mx_server_is_in?).and_return(false)
end
```

Expand All @@ -118,6 +127,10 @@ vendor directory to the config directory. That means:
`vendor/blacklist.yml` -> `config/blacklisted_email_domains.yml`
`vendor/whitelist.yml` -> `config/whitelisted_email_domains.yml`

The `disposable` validation has been improved with a `mx` check. Apply the
stub, as noted in the Test environment section, if your tests have slowed
down or if they do not work without an internet connection.

## Upgrading to v2.0.0

In version 1.0 of valid_email2 we only defined the `email` validator.
Expand Down

0 comments on commit 68be972

Please sign in to comment.