README.md in truemail-3.0.0 vs README.md in truemail-3.0.1

- old
+ new

@@ -1449,9 +1449,59 @@ config.blacklisted_domains = Constants::Email::BLACK_DOMAINS end end ``` +Or you can use end-to-end approach and mock DNS and SMTP services with [`dns_mock`](https://github.com/mocktools/ruby-dns-mock), [`smtp_mock`](https://github.com/mocktools/ruby-smtp-mock) for your test environment like in example below: + +```ruby +# Gemfile + +group :test do + gem 'dns_mock', require: false + gem 'smtp_mock', require: false +end + +# spec/spec_helper.rb + +require 'dns_mock/test_framework/rspec' +require 'smtp_mock/test_framework/rspec' + +RSpec.configure do |config| + config.include DnsMock::TestFramework::RSpec::Helper + config.include SmtpMock::TestFramework::RSpec::Helper +end + +# spec/integration_spec.rb + +RSpec.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) + + Truemail.configuration.tap do |config| + config.dns = %W[127.0.0.1:#{dns_mock_server.port}] + config.smtp_port = smtp_mock_server.port + end + end + + context 'when checks real email' do + let(:smtp_mock_server_options) { {} } + + it { expect(Truemail.validate(target_email).result).to be_valid } + end + + context 'when checks fake email' do + let(:smtp_mock_server_options) { { not_registered_emails: [target_email] } } + + it { expect(Truemail.validate(target_email).result).not_to be_valid } + end +end +``` + --- ## Truemail family All Truemail solutions: https://truemail-rb.org