-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Technical/Update gem development dependencies (#197)
* Added truemail integration tests * Added Truemail::DnsHelper#dns_mock_records_by_email, tests * Updated gem development dependencies * Updated CircleCI config * Updated gem version, changelog
- Loading branch information
Showing
8 changed files
with
87 additions
and
21 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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Truemail | ||
VERSION = '2.6.1' | ||
VERSION = '2.6.2' | ||
end |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'smtp_mock/test_framework/rspec' | ||
|
||
RSpec.configure do |config| | ||
config.include SmtpMock::TestFramework::RSpec::Helper | ||
end |
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 |
---|---|---|
|
@@ -10,4 +10,27 @@ | |
expect(dns_mock_gateway).to eq(["#{described_class::LOCALHOST_IP_ADDRESS}:#{dns_mock_server.port}"]) | ||
end | ||
end | ||
|
||
describe '#dns_mock_records_by_email' do | ||
let(:email) { '[email protected]' } | ||
let(:email_domain) { 'domain.com' } | ||
let(:mx_domain) { 'mx.example.com' } | ||
|
||
before { allow(FFaker::Internet).to receive(:domain_name).and_return(mx_domain) } | ||
|
||
specify do | ||
dns_mock_records = dns_mock_records_by_email(email) | ||
expect(dns_mock_records.dig(email_domain, :mx).size).to eq(1) | ||
expect(dns_mock_records).to eq( | ||
email_domain => { mx: [mx_domain] }, | ||
mx_domain => { a: [Truemail::DnsHelper::LOCALHOST_IP_ADDRESS] } | ||
) | ||
end | ||
|
||
specify do | ||
expect( | ||
dns_mock_records_by_email(email, dimension: 2).dig(email_domain, :mx).size | ||
).to eq(2) | ||
end | ||
end | ||
end |
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 |
---|---|---|
|
@@ -146,27 +146,39 @@ | |
before do | ||
described_class.configure do |config| | ||
config.verifier_email = '[email protected]' | ||
config.connection_timeout = 1 | ||
config.response_timeout = 1 | ||
config.dns = dns_mock_gateway | ||
# config.smtp_port = smtp_mock_server.port # TODO: should be refactored with smtp-mock server in next release | ||
end | ||
end | ||
|
||
include_examples 'returns validator instance' | ||
|
||
# TODO: should be refactored with smtp-mock server in next release | ||
# describe 'integration tests' do | ||
# context 'when checks real email' do | ||
# specify do | ||
# expect(described_class.validate('[email protected]').result.valid?).to be(true) | ||
# end | ||
# end | ||
|
||
# context 'when checks fake email' do | ||
# specify do | ||
# expect(described_class.validate('[email protected]').result.valid?).to be(false) | ||
# end | ||
# end | ||
# end | ||
describe 'integration tests' do | ||
let(:target_email) { random_email } | ||
let(:dns_mock_records) { dns_mock_records_by_email(target_email, dimension: 2) } | ||
|
||
before do | ||
dns_mock_server.assign_mocks(dns_mock_records) | ||
smtp_mock_server(**smtp_mock_server_options) | ||
stub_const('Truemail::Validate::Smtp::Request::SMTP_PORT', smtp_mock_server.port) | ||
end | ||
|
||
context 'when checks real email' do | ||
let(:smtp_mock_server_options) { {} } | ||
|
||
specify do | ||
expect(described_class.validate(target_email).result).to be_valid | ||
end | ||
end | ||
|
||
context 'when checks fake email' do | ||
let(:smtp_mock_server_options) { { not_registered_emails: [target_email] } } | ||
|
||
specify do | ||
expect(described_class.validate(target_email).result).not_to be_valid | ||
end | ||
end | ||
end | ||
end | ||
|
||
context 'when custom configuration passed' do | ||
|
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