diff --git a/.circleci/config.yml b/.circleci/config.yml index edc5d1d..4877c44 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ defaults: &defaults - image: cimg/ruby:<< parameters.ruby-version >> orbs: - ruby: circleci/ruby@2.0.0 + ruby: circleci/ruby@2.1.0 references: bundle_install: &bundle_install diff --git a/.circleci/gemspecs/compatible b/.circleci/gemspecs/compatible index 985143a..3071f23 100644 --- a/.circleci/gemspecs/compatible +++ b/.circleci/gemspecs/compatible @@ -16,7 +16,7 @@ Gem::Specification.new do |spec| spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } spec.require_paths = %w[lib] - spec.add_runtime_dependency 'net-smtp', '~> 0.3.3' if ::Gem::Version.new(::RUBY_VERSION) >= ::Gem::Version.new('3.1.0') + spec.add_runtime_dependency 'net-smtp', '~> 0.4.0' if ::Gem::Version.new(::RUBY_VERSION) >= ::Gem::Version.new('3.1.0') spec.add_runtime_dependency 'simpleidn', '~> 0.2.1' spec.add_development_dependency 'dns_mock' diff --git a/.circleci/gemspecs/latest b/.circleci/gemspecs/latest index 521d148..b094248 100644 --- a/.circleci/gemspecs/latest +++ b/.circleci/gemspecs/latest @@ -16,23 +16,23 @@ Gem::Specification.new do |spec| spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } spec.require_paths = %w[lib] - spec.add_runtime_dependency 'net-smtp', '~> 0.3.3' + spec.add_runtime_dependency 'net-smtp', '~> 0.4.0' spec.add_runtime_dependency 'simpleidn', '~> 0.2.1' spec.add_development_dependency 'bundler-audit', '~> 0.9.1' - spec.add_development_dependency 'dns_mock', '~> 1.5', '>= 1.5.15' + spec.add_development_dependency 'dns_mock', '~> 1.5', '>= 1.5.16' spec.add_development_dependency 'fasterer', '~> 0.10.1' - spec.add_development_dependency 'ffaker', '~> 2.21' + spec.add_development_dependency 'ffaker', '~> 2.23' spec.add_development_dependency 'json_matchers', '~> 0.11.1' spec.add_development_dependency 'pry-byebug', '~> 3.10', '>= 3.10.1' - spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6' + spec.add_development_dependency 'rake', '~> 13.1' spec.add_development_dependency 'reek', '~> 6.1', '>= 6.1.4' spec.add_development_dependency 'rspec', '~> 3.12' - spec.add_development_dependency 'rubocop', '~> 1.54', '>= 1.54.2' - spec.add_development_dependency 'rubocop-performance', '~> 1.18' - spec.add_development_dependency 'rubocop-rspec', '~> 2.22' + spec.add_development_dependency 'rubocop', '~> 1.57', '>= 1.57.2' + spec.add_development_dependency 'rubocop-performance', '~> 1.19', '>= 1.19.1' + spec.add_development_dependency 'rubocop-rspec', '~> 2.25' spec.add_development_dependency 'simplecov', '~> 0.22.0' - spec.add_development_dependency 'smtp_mock', '~> 1.3', '>= 1.3.4' - spec.add_development_dependency 'truemail-rspec', '~> 1.1' - spec.add_development_dependency 'webmock', '~> 3.18', '>= 3.18.1' + spec.add_development_dependency 'smtp_mock', '~> 1.3', '>= 1.3.5' + spec.add_development_dependency 'truemail-rspec', '~> 1.2' + spec.add_development_dependency 'webmock', '~> 3.19', '>= 3.19.1' end diff --git a/.codeclimate.yml b/.codeclimate.yml index 68428b9..3c9d25a 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -9,7 +9,7 @@ checks: plugins: rubocop: enabled: true - channel: rubocop-1-54 + channel: rubocop-1-57 config: file: .circleci/linter_configs/.rubocop.yml diff --git a/.reek.yml b/.reek.yml index 97f4e64..487e74e 100644 --- a/.reek.yml +++ b/.reek.yml @@ -13,6 +13,7 @@ detectors: exclude: - Truemail::Validate::Smtp::Request#run - Truemail::Validate::Smtp#run + - Truemail::Validate::Smtp#not_includes_user_not_found_errors? - Truemail::Validate::Mx#hosts_from_cname_records - Truemail::Configuration#logger= - Truemail::Validate::Smtp::Request#initialize @@ -55,7 +56,7 @@ detectors: ControlParameter: exclude: - - Truemail::GenerateEmailHelper#calculate_email_size + - Truemail::RspecHelper::GenerateEmail#calculate_email_size - Truemail::Worker#success - Truemail#raise_unless - Truemail::Configuration#raise_unless @@ -64,7 +65,7 @@ detectors: FeatureEnvy: exclude: - Truemail::Validate::Smtp#not_includes_user_not_found_errors - - Truemail::GenerateEmailHelper#prepare_user_name + - Truemail::RspecHelper::GenerateEmail#prepare_user_name - Truemail::ConfigurationHelper#create_configuration - Truemail::Log::Serializer::Base#smtp_debug - Truemail::Log::Serializer::Text#data_composer diff --git a/CHANGELOG.md b/CHANGELOG.md index 692fdfc..dab0a46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.1.0] - 2023.10.31 + +### Updated + +- Updated runtime/development dependencies +- Updated gemspecs +- Updated RSpec helpers namespaces +- Updated `codeclimate`/`reek` configs +- Updated gem version + ## [3.0.9] - 2023.07.19 ### Fixed @@ -356,8 +366,8 @@ Optimized DNS (MX) validation flow. Removed needless DNS request for case when c ### Updated -- Updated gem codebase, refactored `Truemail::ContextHelper` -- Updated tests with `Truemail::DnsHelper#dns_mock_gateway` +- Updated gem codebase, refactored `Truemail::RspecHelper::Context` +- Updated tests with `Truemail::RspecHelper::Dns#dns_mock_gateway` - Updated gem development dependencies - Updated gem version diff --git a/lib/truemail/validate/smtp.rb b/lib/truemail/validate/smtp.rb index ddcf232..7fe3b73 100644 --- a/lib/truemail/validate/smtp.rb +++ b/lib/truemail/validate/smtp.rb @@ -63,7 +63,7 @@ def success_response? def not_includes_user_not_found_errors? return false unless configuration.smtp_safe_check - result.smtp_debug.map(&:response).map(&:errors).all? do |errors| + result.smtp_debug.map { |request| request.response.errors }.all? do |errors| next true unless errors.key?(:rcptto) errors.slice(:rcptto).values.none? do |error| configuration.smtp_error_body_pattern.match?(error) diff --git a/lib/truemail/version.rb b/lib/truemail/version.rb index 9fe69a0..9fd0c29 100644 --- a/lib/truemail/version.rb +++ b/lib/truemail/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Truemail - VERSION = '3.0.9' + VERSION = '3.1.0' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2009911..a015817 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,9 +9,9 @@ RSpec::Mocks.configuration.allow_message_expectations_on_nil = true RSpec.configure do |config| - config.include Truemail::ContextHelper - config.include Truemail::DnsHelper - config.include Truemail::IpifyHelper + config.include Truemail::RspecHelper::Context + config.include Truemail::RspecHelper::Dns + config.include Truemail::RspecHelper::Ipify config.order = :random config.example_status_persistence_file_path = '.rspec_status' config.disable_monkey_patching! diff --git a/spec/support/helpers/context.rb b/spec/support/helpers/context.rb new file mode 100644 index 0000000..672e4b0 --- /dev/null +++ b/spec/support/helpers/context.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +module Truemail + module RspecHelper + module Context + NON_ASCII_WORDS = %w[mañana ĉapelo dấu παράδειγμα 屋企].freeze + + def random_email + ffaker.email + end + + def random_uniq_email + ffaker.unique.email + end + + def random_internationalized_email + "#{ffaker.user_name}@#{Truemail::RspecHelper::Context::NON_ASCII_WORDS.sample}.#{ffaker.domain_suffix}" + end + + def random_ip_address + ffaker.ip_v4_address + end + + def random_domain_name + ffaker.domain_name + end + + def random_uniq_domain_name + ffaker.unique.domain_name + end + + def rdns_lookup_host_address(host_address) + DnsMock::Representer::RdnsLookup.call(host_address) + end + + def domain_from_email(email) + email[Truemail::RegexConstant::REGEX_DOMAIN_FROM_EMAIL, 1] + end + + def email_punycode_domain(email) + DnsMock::Representer::Punycode.call(domain_from_email(email)) + end + + def attempts_getter + ->(smtp_request_instance) { smtp_request_instance.send(:attempts) } + end + + private + + def ffaker + FFaker::Internet + end + end + end +end diff --git a/spec/support/helpers/context_helper.rb b/spec/support/helpers/context_helper.rb deleted file mode 100644 index bf0724d..0000000 --- a/spec/support/helpers/context_helper.rb +++ /dev/null @@ -1,53 +0,0 @@ -# frozen_string_literal: true - -module Truemail - module ContextHelper - NON_ASCII_WORDS = %w[mañana ĉapelo dấu παράδειγμα 屋企].freeze - - def random_email - ffaker.email - end - - def random_uniq_email - ffaker.unique.email - end - - def random_internationalized_email - "#{ffaker.user_name}@#{Truemail::ContextHelper::NON_ASCII_WORDS.sample}.#{ffaker.domain_suffix}" - end - - def random_ip_address - ffaker.ip_v4_address - end - - def random_domain_name - ffaker.domain_name - end - - def random_uniq_domain_name - ffaker.unique.domain_name - end - - def rdns_lookup_host_address(host_address) - DnsMock::Representer::RdnsLookup.call(host_address) - end - - def domain_from_email(email) - email[Truemail::RegexConstant::REGEX_DOMAIN_FROM_EMAIL, 1] - end - - def email_punycode_domain(email) - DnsMock::Representer::Punycode.call(domain_from_email(email)) - end - - def attempts_getter - ->(smtp_request_instance) { smtp_request_instance.send(:attempts) } - end - - private - - def ffaker - FFaker::Internet - end - end -end diff --git a/spec/support/helpers/dns.rb b/spec/support/helpers/dns.rb new file mode 100644 index 0000000..9032c85 --- /dev/null +++ b/spec/support/helpers/dns.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Truemail + module RspecHelper + module Dns + LOCALHOST_IP_ADDRESS = '127.0.0.1' + + def dns_mock_gateway + ["#{Truemail::RspecHelper::Dns::LOCALHOST_IP_ADDRESS}:#{dns_mock_server.port}"] + end + + def dns_mock_records_by_email(email, dimension: 1) + mx_records = ::Array.new(dimension) { random_domain_name } + a_records = ::Array.new(dimension) { [Truemail::RspecHelper::Dns::LOCALHOST_IP_ADDRESS] } + mx_records_dns_mock = mx_records.zip(a_records).to_h.transform_values { |value| { a: value } } + { domain_from_email(email) => { mx: mx_records } }.merge(mx_records_dns_mock) + end + end + end +end diff --git a/spec/support/helpers/dns_helper.rb b/spec/support/helpers/dns_helper.rb deleted file mode 100644 index 9ecda17..0000000 --- a/spec/support/helpers/dns_helper.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -module Truemail - module DnsHelper - LOCALHOST_IP_ADDRESS = '127.0.0.1' - - def dns_mock_gateway - ["#{Truemail::DnsHelper::LOCALHOST_IP_ADDRESS}:#{dns_mock_server.port}"] - end - - def dns_mock_records_by_email(email, dimension: 1) - mx_records = ::Array.new(dimension) { random_domain_name } - a_records = ::Array.new(dimension) { [Truemail::DnsHelper::LOCALHOST_IP_ADDRESS] } - mx_records_dns_mock = mx_records.zip(a_records).to_h.transform_values { |value| { a: value } } - { domain_from_email(email) => { mx: mx_records } }.merge(mx_records_dns_mock) - end - end -end diff --git a/spec/support/helpers/generate_email.rb b/spec/support/helpers/generate_email.rb new file mode 100644 index 0000000..b39f797 --- /dev/null +++ b/spec/support/helpers/generate_email.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +module Truemail + module RspecHelper + class GenerateEmail + def self.call(**options) + new(**options).call + end + + def initialize(size: :auto, symbols: %w[- _ . +], invalid_email_with: []) + @size = calculate_email_size(size) + @symbols = symbols + @invalid_symbols = invalid_email_with + user_name + end + + def call + "#{user_name}@#{('a'..'z').zip(0..Float::INFINITY).flatten.shuffle.sample[0]}.#{('aa'..'zz').to_a.sample}" + end + + private + + attr_reader :size, :symbols, :invalid_symbols + + def calculate_email_size(size) + case size + when :auto then rand(15..250) + when :min then 1 + when :max then 250 + when :out_of_range then rand(251..300) + end + end + + def sample_size + symbols_size = symbols.size + invalid_symbols_size = invalid_symbols.size + size < (symbols_size + invalid_symbols_size + 1) ? 1 : size - symbols_size - invalid_symbols_size - 1 + end + + def invalid_symbols_empty? + invalid_symbols.empty? + end + + def size_one? + size == 1 + end + + def user_name + @user_name ||= + if size_one? && !invalid_symbols_empty? + invalid_symbols.sample + elsif size_one? && invalid_symbols_empty? + ('a'..'z').to_a.sample + else + prepare_user_name(randomizer) + end + end + + def randomizer # rubocop:disable Metrics/AbcSize + ( + ('Aa'..'Zz').to_a.shuffle.join.chars.sample(sample_size).push(*symbols.shuffle) << rand(0..9) + ).shuffle.push(*invalid_symbols.sample(size)).shuffle[0...size] + end + + def prepare_user_name(sample) + sample.rotate!(1) while symbols.include?(sample.first) + sample.join + end + end + end +end diff --git a/spec/support/helpers/generate_email_helper.rb b/spec/support/helpers/generate_email_helper.rb deleted file mode 100644 index 56c3b44..0000000 --- a/spec/support/helpers/generate_email_helper.rb +++ /dev/null @@ -1,69 +0,0 @@ -# frozen_string_literal: true - -module Truemail - class GenerateEmailHelper - def self.call(**options) - new(**options).call - end - - def initialize(size: :auto, symbols: %w[- _ . +], invalid_email_with: []) - @size = calculate_email_size(size) - @symbols = symbols - @invalid_symbols = invalid_email_with - user_name - end - - def call - "#{user_name}@#{('a'..'z').zip(0..Float::INFINITY).flatten.shuffle.sample[0]}.#{('aa'..'zz').to_a.sample}" - end - - private - - attr_reader :size, :symbols, :invalid_symbols - - def calculate_email_size(size) - case size - when :auto then rand(15..250) - when :min then 1 - when :max then 250 - when :out_of_range then rand(251..300) - end - end - - def sample_size - symbols_size = symbols.size - invalid_symbols_size = invalid_symbols.size - size < (symbols_size + invalid_symbols_size + 1) ? 1 : size - symbols_size - invalid_symbols_size - 1 - end - - def invalid_symbols_empty? - invalid_symbols.empty? - end - - def size_one? - size == 1 - end - - def user_name - @user_name ||= - if size_one? && !invalid_symbols_empty? - invalid_symbols.sample - elsif size_one? && invalid_symbols_empty? - ('a'..'z').to_a.sample - else - prepare_user_name(randomizer) - end - end - - def randomizer # rubocop:disable Metrics/AbcSize - ( - ('Aa'..'Zz').to_a.shuffle.join.chars.sample(sample_size).push(*symbols.shuffle) << rand(0..9) - ).shuffle.push(*invalid_symbols.sample(size)).shuffle[0...size] - end - - def prepare_user_name(sample) - sample.rotate!(1) while symbols.include?(sample.first) - sample.join - end - end -end diff --git a/spec/support/helpers/ipify.rb b/spec/support/helpers/ipify.rb new file mode 100644 index 0000000..257db65 --- /dev/null +++ b/spec/support/helpers/ipify.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Truemail + module RspecHelper + module Ipify + def mock_ipify_request(mocked_ipify_response, uri = Truemail::Audit::Ip::GET_MY_IP_URL) + stub_request(:get, uri).with( + headers: { 'Host' => URI(uri).host } + ).to_return(body: mocked_ipify_response) + end + end + end +end diff --git a/spec/support/helpers/ipify_helper.rb b/spec/support/helpers/ipify_helper.rb deleted file mode 100644 index db59a16..0000000 --- a/spec/support/helpers/ipify_helper.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -module Truemail - module IpifyHelper - def mock_ipify_request(mocked_ipify_response, uri = Truemail::Audit::Ip::GET_MY_IP_URL) - stub_request(:get, uri).with( - headers: { 'Host' => URI(uri).host } - ).to_return(body: mocked_ipify_response) - end - end -end diff --git a/spec/truemail/core_spec.rb b/spec/truemail/core_spec.rb index 110c817..ee17b8e 100644 --- a/spec/truemail/core_spec.rb +++ b/spec/truemail/core_spec.rb @@ -41,26 +41,26 @@ it 'allows from 6 to 255 chars' do expect( - regex_pattern.match?(Truemail::GenerateEmailHelper.call(size: :min)) + regex_pattern.match?(Truemail::RspecHelper::GenerateEmail.call(size: :min)) ).to be(true) expect( - regex_pattern.match?(Truemail::GenerateEmailHelper.call) + regex_pattern.match?(Truemail::RspecHelper::GenerateEmail.call) ).to be(true) expect( - regex_pattern.match?(Truemail::GenerateEmailHelper.call(size: :max)) + regex_pattern.match?(Truemail::RspecHelper::GenerateEmail.call(size: :max)) ).to be(true) end it 'not allows more then 255 chars' do expect( - regex_pattern.match?(Truemail::GenerateEmailHelper.call(size: :out_of_range)) + regex_pattern.match?(Truemail::RspecHelper::GenerateEmail.call(size: :out_of_range)) ).to be(false) end it "allows '-', '_', '.', '+', numbers, letters case insensitive before @domain" do - expect(regex_pattern.match?(Truemail::GenerateEmailHelper.call)).to be(true) + expect(regex_pattern.match?(Truemail::RspecHelper::GenerateEmail.call)).to be(true) end it 'allows tld size between 2 and 63 chars' do @@ -79,7 +79,7 @@ it 'allows special chars' do expect( regex_pattern.match?( - Truemail::GenerateEmailHelper.call(symbols: special_chars) + Truemail::RspecHelper::GenerateEmail.call(symbols: special_chars) ) ).to be(true) end @@ -87,7 +87,7 @@ it 'not allows special chars for one char username' do expect( regex_pattern.match?( - Truemail::GenerateEmailHelper.call(size: :min, invalid_email_with: special_chars) + Truemail::RspecHelper::GenerateEmail.call(size: :min, invalid_email_with: special_chars) ) ).to be(false) end @@ -95,7 +95,7 @@ it 'not allows double @ char in email' do expect( regex_pattern.match?( - Truemail::GenerateEmailHelper.call(invalid_email_with: %w[@]) + Truemail::RspecHelper::GenerateEmail.call(invalid_email_with: %w[@]) ) ).to be(false) end diff --git a/spec/support/helpers/context_helper_spec.rb b/spec/truemail/rspec_helper/context_spec.rb similarity index 96% rename from spec/support/helpers/context_helper_spec.rb rename to spec/truemail/rspec_helper/context_spec.rb index d34be4c..2ddcf6d 100644 --- a/spec/support/helpers/context_helper_spec.rb +++ b/spec/truemail/rspec_helper/context_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Truemail::ContextHelper, type: :helper do # rubocop:disable RSpec/FilePath +RSpec.describe Truemail::RspecHelper::Context, type: :helper do describe 'defined constants' do specify { expect(described_class).to be_const_defined(:NON_ASCII_WORDS) } end diff --git a/spec/support/helpers/dns_helper_spec.rb b/spec/truemail/rspec_helper/dns_spec.rb similarity index 85% rename from spec/support/helpers/dns_helper_spec.rb rename to spec/truemail/rspec_helper/dns_spec.rb index 3e93b40..694de35 100644 --- a/spec/support/helpers/dns_helper_spec.rb +++ b/spec/truemail/rspec_helper/dns_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Truemail::DnsHelper, type: :helper do # rubocop:disable RSpec/FilePath +RSpec.describe Truemail::RspecHelper::Dns, type: :helper do describe 'defined constants' do specify { expect(described_class).to be_const_defined(:LOCALHOST_IP_ADDRESS) } end @@ -23,7 +23,7 @@ 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] } + mx_domain => { a: [Truemail::RspecHelper::Dns::LOCALHOST_IP_ADDRESS] } ) end diff --git a/spec/support/helpers/generate_email_helper_spec.rb b/spec/truemail/rspec_helper/generate_email_spec.rb similarity index 93% rename from spec/support/helpers/generate_email_helper_spec.rb rename to spec/truemail/rspec_helper/generate_email_spec.rb index dca8c67..33e3662 100644 --- a/spec/support/helpers/generate_email_helper_spec.rb +++ b/spec/truemail/rspec_helper/generate_email_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Truemail::GenerateEmailHelper, type: :helper do # rubocop:disable RSpec/FilePath +RSpec.describe Truemail::RspecHelper::GenerateEmail, type: :helper do describe '.call' do context 'without params' do subject(:generate_email) { described_class.call } diff --git a/spec/support/helpers/ipify_helper_spec.rb b/spec/truemail/rspec_helper/ipify_spec.rb similarity index 75% rename from spec/support/helpers/ipify_helper_spec.rb rename to spec/truemail/rspec_helper/ipify_spec.rb index 45402bb..3d95d55 100644 --- a/spec/support/helpers/ipify_helper_spec.rb +++ b/spec/truemail/rspec_helper/ipify_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Truemail::IpifyHelper, type: :helper do # rubocop:disable RSpec/FilePath +RSpec.describe Truemail::RspecHelper::Ipify, type: :helper do describe '#mock_ipify_request' do let(:ip_address) { random_ip_address } diff --git a/spec/truemail/validate/list_match_spec.rb b/spec/truemail/validate/list_match_spec.rb index 795c57f..df839d3 100644 --- a/spec/truemail/validate/list_match_spec.rb +++ b/spec/truemail/validate/list_match_spec.rb @@ -73,8 +73,7 @@ context 'when email exists on both lists' do specify do - allow(configuration_instance).to receive(:whitelisted_emails).and_return([email]) - allow(configuration_instance).to receive(:blacklisted_emails).and_return([email]) + allow(configuration_instance).to receive_messages(whitelisted_emails: [email], blacklisted_emails: [email]) expect { domain_list_match_validator } .to change(result_instance, :success) .from(nil).to(true) @@ -84,8 +83,7 @@ context 'when email domain exists on both lists' do specify do - allow(configuration_instance).to receive(:whitelisted_domains).and_return([domain]) - allow(configuration_instance).to receive(:blacklisted_domains).and_return([domain]) + allow(configuration_instance).to receive_messages(whitelisted_domains: [domain], blacklisted_domains: [domain]) expect { domain_list_match_validator } .to change(result_instance, :success) .from(nil).to(true) @@ -96,8 +94,7 @@ context 'when email domain exists not on both lists' do specify do - allow(configuration_instance).to receive(:whitelisted_domains).and_return([]) - allow(configuration_instance).to receive(:blacklisted_domains).and_return([]) + allow(configuration_instance).to receive_messages(whitelisted_domains: [], blacklisted_domains: []) expect { domain_list_match_validator } .to not_change(result_instance, :success) .and change(result_instance, :domain) diff --git a/spec/truemail/validate/smtp/request_spec.rb b/spec/truemail/validate/smtp/request_spec.rb index a3992c5..76b5002 100644 --- a/spec/truemail/validate/smtp/request_spec.rb +++ b/spec/truemail/validate/smtp/request_spec.rb @@ -272,8 +272,7 @@ it 'rcptto smtp server error' do allow(session).to receive(:start).with(verifier_domain).and_yield(session) - allow(session).to receive(:helo).and_return(true) - allow(session).to receive(:mailfrom).and_return(true) + allow(session).to receive_messages(helo: true, mailfrom: true) allow(session).to receive(:rcptto).and_raise(::StandardError, error_message) expect { response_instance_target_method } diff --git a/truemail.gemspec b/truemail.gemspec index e4f7198..113b23f 100644 --- a/truemail.gemspec +++ b/truemail.gemspec @@ -22,19 +22,22 @@ Gem::Specification.new do |spec| 'bug_tracker_uri' => 'https://github.com/truemail-rb/truemail/issues' } + current_ruby_version = ::Gem::Version.new(::RUBY_VERSION) + ffaker_version = current_ruby_version >= ::Gem::Version.new('3.0.0') ? '~> 2.23' : '~> 2.21' + spec.required_ruby_version = '>= 2.5.0' spec.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r{^(bin|lib)/|.ruby-version|truemail.gemspec|LICENSE}) } spec.require_paths = %w[lib] - spec.add_runtime_dependency 'net-smtp', '~> 0.3.3' if ::Gem::Version.new(::RUBY_VERSION) >= ::Gem::Version.new('3.1.0') + spec.add_runtime_dependency 'net-smtp', '~> 0.4.0' if current_ruby_version >= ::Gem::Version.new('3.1.0') spec.add_runtime_dependency 'simpleidn', '~> 0.2.1' - spec.add_development_dependency 'dns_mock', '~> 1.5', '>= 1.5.15' - spec.add_development_dependency 'ffaker', '~> 2.21' + spec.add_development_dependency 'dns_mock', '~> 1.5', '>= 1.5.16' + spec.add_development_dependency 'ffaker', ffaker_version spec.add_development_dependency 'json_matchers', '~> 0.11.1' - spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6' + spec.add_development_dependency 'rake', '~> 13.1' spec.add_development_dependency 'rspec', '~> 3.12' - spec.add_development_dependency 'smtp_mock', '~> 1.3', '>= 1.3.4' - spec.add_development_dependency 'truemail-rspec', '~> 1.1' - spec.add_development_dependency 'webmock', '~> 3.18', '>= 3.18.1' + spec.add_development_dependency 'smtp_mock', '~> 1.3', '>= 1.3.5' + spec.add_development_dependency 'truemail-rspec', '~> 1.2' + spec.add_development_dependency 'webmock', '~> 3.19', '>= 3.19.1' end