diff --git a/.codeclimate.yml b/.codeclimate.yml index 9907dc2..3768886 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -7,7 +7,7 @@ checks: plugins: rubocop: enabled: true - channel: rubocop-1-9 + channel: rubocop-1-10 reek: enabled: true diff --git a/.rubocop.yml b/.rubocop.yml index c9daa54..a06f538 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -148,6 +148,9 @@ Style/EndlessMethod: Style/IfWithBooleanLiteralBranches: Enabled: true +Style/HashConversion: + Enabled: true + Layout/LineLength: Max: 140 @@ -302,6 +305,9 @@ Lint/SymbolConversion: Lint/TripleQuotes: Enabled: true +Gemspec/DateAssignment: + Enabled: true + Performance/AncestorsInclude: Enabled: true diff --git a/CHANGELOG.md b/CHANGELOG.md index cb5489c..bd3af35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ 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). +## [2.3.1] - 2020.02.26 + +### Changed + +- Updated gem development dependencies +- Updated rubocop/codeclimate config +- Updated tests + ## [2.3.0] - 2020.02.05 ### Added diff --git a/Gemfile.lock b/Gemfile.lock index 9c3ab9f..94d14a2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - truemail (2.3.0) + truemail (2.3.1) simpleidn (~> 0.2.1) GEM @@ -23,13 +23,13 @@ GEM diff-lcs (1.4.4) dns_mock (1.2.0) docile (1.3.5) - faker (2.15.1) + faker (2.16.0) i18n (>= 1.6, < 2) - fasterer (0.8.3) + fasterer (0.9.0) colorize (~> 0.7) ruby_parser (>= 3.14.1) hashdiff (1.0.1) - i18n (1.8.8) + i18n (1.8.9) concurrent-ruby (~> 1.0) iniparse (1.5.0) json (2.5.1) @@ -50,7 +50,7 @@ GEM pry-byebug (3.9.0) byebug (~> 11.0) pry (~> 0.13.0) - psych (3.3.0) + psych (3.3.1) public_suffix (4.0.6) rainbow (3.0.0) rake (13.0.3) @@ -59,7 +59,7 @@ GEM parser (~> 3.0.0) psych (~> 3.1) rainbow (>= 2.0, < 4.0) - regexp_parser (2.0.3) + regexp_parser (2.1.1) rexml (3.2.4) rspec (3.10.0) rspec-core (~> 3.10.0) @@ -74,7 +74,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.2) - rubocop (1.9.1) + rubocop (1.10.0) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) @@ -103,15 +103,15 @@ GEM simpleidn (0.2.1) unf (~> 0.1.4) thor (1.1.0) - truemail-rspec (0.3.3) - faker (~> 2.15, >= 2.15.1) + truemail-rspec (0.4.0) + faker (~> 2.16) rspec (~> 3.10) - truemail (~> 2.2) + truemail (>= 2.3) unf (0.1.4) unf_ext unf_ext (0.0.7.7) unicode-display_width (2.0.0) - webmock (3.11.2) + webmock (3.12.0) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) @@ -123,21 +123,21 @@ DEPENDENCIES bundler (~> 1.16) bundler-audit (~> 0.7.0.1) dns_mock (~> 1.2) - faker (~> 2.15, >= 2.15.1) - fasterer (~> 0.8.3) + faker (~> 2.16) + fasterer (~> 0.9.0) json_matchers (~> 0.11.1) overcommit (~> 0.57.0) pry-byebug (~> 3.9) rake (~> 13.0, >= 13.0.3) reek (~> 6.0, >= 6.0.3) rspec (~> 3.10) - rubocop (~> 1.9, >= 1.9.1) + rubocop (~> 1.10) rubocop-performance (~> 1.9, >= 1.9.2) rubocop-rspec (~> 2.2) simplecov (~> 0.17.1) truemail! - truemail-rspec (~> 0.3.3) - webmock (~> 3.11, >= 3.11.2) + truemail-rspec (~> 0.4) + webmock (~> 3.12) BUNDLED WITH 1.16.6 diff --git a/bin/console b/bin/console index c9185e0..6f32468 100755 --- a/bin/console +++ b/bin/console @@ -3,14 +3,7 @@ # frozen_string_literal: true require 'bundler/setup' -require 'truemail' +require 'pry' +require_relative '../lib/truemail' -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require 'irb' -IRB.start(__FILE__) +Pry.start diff --git a/lib/truemail/version.rb b/lib/truemail/version.rb index b585527..ebf65d7 100644 --- a/lib/truemail/version.rb +++ b/lib/truemail/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Truemail - VERSION = '2.3.0' + VERSION = '2.3.1' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b400989..5011b5e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,26 +1,15 @@ # frozen_string_literal: true require 'bundler/setup' -require 'simplecov' -require 'faker' -require 'json_matchers/rspec' -require 'pry' -require 'truemail' -require 'truemail/rspec' -require 'dns_mock/test_framework/rspec' -require 'webmock/rspec' +require_relative '../lib/truemail' -SimpleCov.start -JsonMatchers.schema_root = 'spec/support/schemas' - -rspec_custom = File.join(File.dirname(__FILE__), 'support/**/*.rb') -Dir[File.expand_path(rspec_custom)].each { |file| require file unless file[/\A.+_spec\.rb\z/] } +rspec_custom = ::File.join(::File.dirname(__FILE__), 'support/**/*.rb') +::Dir[File.expand_path(rspec_custom)].each { |file| require file unless file[/\A.+_spec\.rb\z/] } RSpec::Mocks.configuration.allow_message_expectations_on_nil = true RSpec.configure do |config| - config.include Truemail::RSpec + config.include Truemail::ContextHelper config.include Truemail::IpifyHelper - config.include DnsMock::TestFramework::RSpec::Helper config.order = :random config.example_status_persistence_file_path = '.rspec_status' config.disable_monkey_patching! diff --git a/spec/support/config/dns_mock.rb b/spec/support/config/dns_mock.rb new file mode 100644 index 0000000..9af9420 --- /dev/null +++ b/spec/support/config/dns_mock.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require 'dns_mock/test_framework/rspec' + +RSpec.configure do |config| + config.include DnsMock::TestFramework::RSpec::Helper +end diff --git a/spec/support/config/faker.rb b/spec/support/config/faker.rb new file mode 100644 index 0000000..62608d0 --- /dev/null +++ b/spec/support/config/faker.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require 'faker' diff --git a/spec/support/config/json_matchers.rb b/spec/support/config/json_matchers.rb new file mode 100644 index 0000000..7838017 --- /dev/null +++ b/spec/support/config/json_matchers.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +require 'json_matchers/rspec' + +JsonMatchers.schema_root = 'spec/support/schemas' diff --git a/spec/support/config/pry.rb b/spec/support/config/pry.rb new file mode 100644 index 0000000..a1f7232 --- /dev/null +++ b/spec/support/config/pry.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require 'pry' diff --git a/spec/support/config/simplecov.rb b/spec/support/config/simplecov.rb new file mode 100644 index 0000000..fb7c231 --- /dev/null +++ b/spec/support/config/simplecov.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +require 'simplecov' + +SimpleCov.start diff --git a/spec/support/config/truemail.rb b/spec/support/config/truemail.rb new file mode 100644 index 0000000..8bedb0a --- /dev/null +++ b/spec/support/config/truemail.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require 'truemail/rspec' + +RSpec.configure do |config| + config.include Truemail::RSpec +end diff --git a/spec/support/config/webmock.rb b/spec/support/config/webmock.rb new file mode 100644 index 0000000..ebb3576 --- /dev/null +++ b/spec/support/config/webmock.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require 'webmock/rspec' diff --git a/spec/support/helpers/context_helper.rb b/spec/support/helpers/context_helper.rb new file mode 100644 index 0000000..c3835ce --- /dev/null +++ b/spec/support/helpers/context_helper.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Truemail + module ContextHelper + def random_email + faker.email + end + + def random_ip_address + faker.ip_v4_address + end + + def random_domain_name + faker.domain_name + end + + def random_uniq_domain_name + faker.unique.domain_name + end + + private + + def faker + Faker::Internet + end + end +end diff --git a/spec/support/helpers/context_helper_spec.rb b/spec/support/helpers/context_helper_spec.rb new file mode 100644 index 0000000..d00c60e --- /dev/null +++ b/spec/support/helpers/context_helper_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +RSpec.describe Truemail::ContextHelper, type: :helper do # rubocop:disable RSpec/FilePath + describe '#random_email' do + specify do + expect(Faker::Internet).to receive(:email).and_call_original + expect(random_email).to match(Truemail::RegexConstant::REGEX_EMAIL_PATTERN) + end + end + + describe '#random_domain_name' do + specify do + expect(Faker::Internet).to receive(:domain_name).and_call_original + expect(random_domain_name).to match(Truemail::RegexConstant::REGEX_DOMAIN_PATTERN) + end + end + + describe '#random_uniq_domain_name' do + specify do + expect(Faker::Internet).to receive_message_chain(:unique, :domain_name) + random_uniq_domain_name + end + + specify { expect(random_domain_name).to match(Truemail::RegexConstant::REGEX_DOMAIN_PATTERN) } + end + + describe '#random_ip_address' do + specify do + expect(Faker::Internet).to receive(:ip_v4_address).and_call_original + expect(random_ip_address).to match(Truemail::RegexConstant::REGEX_DNS_SERVER_ADDRESS_PATTERN) + end + end +end diff --git a/spec/support/helpers/ipify_helper_spec.rb b/spec/support/helpers/ipify_helper_spec.rb index b7836ab..45402bb 100644 --- a/spec/support/helpers/ipify_helper_spec.rb +++ b/spec/support/helpers/ipify_helper_spec.rb @@ -2,7 +2,7 @@ RSpec.describe Truemail::IpifyHelper, type: :helper do # rubocop:disable RSpec/FilePath describe '#mock_ipify_request' do - let(:ip_address) { Faker::Internet.ip_v4_address } + let(:ip_address) { random_ip_address } specify do mock_ipify_request(ip_address) diff --git a/spec/truemail/audit/dns_spec.rb b/spec/truemail/audit/dns_spec.rb index 53a842e..13e475b 100644 --- a/spec/truemail/audit/dns_spec.rb +++ b/spec/truemail/audit/dns_spec.rb @@ -34,7 +34,7 @@ describe 'Success' do context 'when a record found and refers to current host ip' do - let(:current_host_ip) { Faker::Internet.ip_v4_address } + let(:current_host_ip) { random_ip_address } before { dns_mock_server.assign_mocks(verifier_domain => { a: [current_host_ip] }) } @@ -46,7 +46,7 @@ end describe 'Fails' do - let(:current_host_ip) { Faker::Internet.ip_v4_address } + let(:current_host_ip) { random_ip_address } shared_examples 'addes verifier domain not refer warning to result instance' do it 'addes verifier domain not refer warning to result instance' do @@ -62,7 +62,7 @@ end context 'when a record of verifier domain not refers to currernt host ip address' do - before { dns_mock_server.assign_mocks(verifier_domain => { a: [Faker::Internet.ip_v4_address] }) } + before { dns_mock_server.assign_mocks(verifier_domain => { a: [random_ip_address] }) } include_examples 'addes verifier domain not refer warning to result instance' end diff --git a/spec/truemail/audit/ip_spec.rb b/spec/truemail/audit/ip_spec.rb index 1eb4ec4..9be57eb 100644 --- a/spec/truemail/audit/ip_spec.rb +++ b/spec/truemail/audit/ip_spec.rb @@ -33,7 +33,7 @@ describe 'Success' do context 'when determination of host ip address was successful' do - let(:host_address) { Faker::Internet.ip_v4_address } + let(:host_address) { random_ip_address } before { mock_ipify_request(host_address) } diff --git a/spec/truemail/audit/ptr_spec.rb b/spec/truemail/audit/ptr_spec.rb index d41f907..c345060 100644 --- a/spec/truemail/audit/ptr_spec.rb +++ b/spec/truemail/audit/ptr_spec.rb @@ -30,7 +30,7 @@ subject(:ptr_auditor) { ptr_auditor_instance.run } let(:ptr_auditor_instance) { described_class.new(result_instance) } - let(:current_host_ip) { Faker::Internet.ip_v4_address } + let(:current_host_ip) { random_ip_address } before { allow(ptr_auditor_instance).to receive(:current_host_ip).and_return(current_host_ip) } @@ -74,7 +74,7 @@ context 'when ptr records do not refer to verifier domain' do let(:warning_context) { Truemail::Audit::Ptr::PTR_NOT_REFER } - before { dns_mock_server.assign_mocks(current_host_ip => { ptr: [Faker::Internet.domain_name] }) } + before { dns_mock_server.assign_mocks(current_host_ip => { ptr: [random_domain_name] }) } include_examples 'addes warning context into result instance' end diff --git a/spec/truemail/configuration_spec.rb b/spec/truemail/configuration_spec.rb index c55ee79..10e5f57 100644 --- a/spec/truemail/configuration_spec.rb +++ b/spec/truemail/configuration_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Truemail::Configuration do subject(:configuration_instance) { described_class.new } - let(:valid_email) { Faker::Internet.email } + let(:valid_email) { random_email } describe 'class constants' do context 'DEFAULT_CONNECTION_TIMEOUT' do @@ -208,7 +208,7 @@ end context 'when manual independent configuration' do - let(:valid_domain) { Faker::Internet.domain_name } + let(:valid_domain) { random_domain_name } describe '#verifier_email=' do context 'with valid email' do @@ -379,7 +379,7 @@ describe '#validation_type_for=' do context 'with valid validation type attributes' do let(:domains_config) do - ::Array.new(2) { Faker::Internet.unique.domain_name }.zip(%i[regex mx smtp]).to_h + ::Array.new(2) { random_uniq_domain_name }.zip(%i[regex mx smtp]).to_h end it 'sets validation type for domain' do @@ -408,7 +408,7 @@ end context 'with invalid validation type' do - let(:domain) { Faker::Internet.domain_name } + let(:domain) { random_domain_name } let(:validation_type) { 'wrong_validation_type' } specify do @@ -421,7 +421,7 @@ %i[whitelisted_domains= blacklisted_domains=].each do |domain_list_type| describe "##{domain_list_type}" do let(:setter) { domain_list_type } - let(:domains_list) { ::Array.new(2) { Faker::Internet.unique.domain_name } } + let(:domains_list) { ::Array.new(2) { random_uniq_domain_name } } context "with valid #{domain_list_type} parameter type and context" do it 'sets whitelisted domains list' do @@ -451,8 +451,8 @@ context 'with valid dns parameter type and context' do let(:dns_servers_list) do [ - Faker::Internet.ip_v4_address, - "#{Faker::Internet.ip_v4_address}:#{rand(1..65_535)}" + random_ip_address, + "#{random_ip_address}:#{rand(1..65_535)}" ].shuffle end @@ -471,19 +471,19 @@ context 'with invalid dns parameter context' do context 'when includes not a String' do - let(:invalid_argument) { [42, Faker::Internet.ip_v4_address] } + let(:invalid_argument) { [42, random_ip_address] } include_examples 'raises extended argument error' end context 'when includes wrong ip address' do - let(:invalid_argument) { ['not_ip_address', Faker::Internet.ip_v4_address] } + let(:invalid_argument) { ['not_ip_address', random_ip_address] } include_examples 'raises extended argument error' end context 'when includes wrong port' do - let(:invalid_argument) { [Faker::Internet.ip_v4_address, "#{Faker::Internet.ip_v4_address}:0"] } + let(:invalid_argument) { [random_ip_address, "#{random_ip_address}:0"] } include_examples 'raises extended argument error' end diff --git a/spec/truemail/dns/punycode_representer_spec.rb b/spec/truemail/dns/punycode_representer_spec.rb index d1a67b3..f8851d9 100644 --- a/spec/truemail/dns/punycode_representer_spec.rb +++ b/spec/truemail/dns/punycode_representer_spec.rb @@ -11,7 +11,7 @@ end context 'when email not includes ASCII chars' do - let(:email) { Faker::Internet.email } + let(:email) { random_email } it 'returns not changed email' do expect(SimpleIDN).not_to receive(:to_ascii) diff --git a/spec/truemail/dns/worker_spec.rb b/spec/truemail/dns/worker_spec.rb index 5fb0212..f954dde 100644 --- a/spec/truemail/dns/worker_spec.rb +++ b/spec/truemail/dns/worker_spec.rb @@ -36,8 +36,8 @@ def dns_resolver_worker_instance describe '#dns_lookup' do subject(:dns_lookup) { dns_resolver_worker_instance.dns_lookup(host_address) } - let(:host_address) { Faker::Internet.ip_v4_address } - let(:ptr_record) { Faker::Internet.domain_name } + let(:host_address) { random_ip_address } + let(:ptr_record) { random_domain_name } before { dns_mock_server.assign_mocks(host_address => { ptr: [ptr_record] }) } @@ -47,8 +47,8 @@ def dns_resolver_worker_instance describe '#a_record' do subject(:resolve_a_record) { dns_resolver_worker_instance.a_record(host_name) } - let(:host_name) { Faker::Internet.domain_name } - let(:a_record) { Faker::Internet.ip_v4_address } + let(:host_name) { random_domain_name } + let(:a_record) { random_ip_address } before { dns_mock_server.assign_mocks(host_name => { a: [a_record] }) } @@ -58,8 +58,8 @@ def dns_resolver_worker_instance describe '#a_records' do subject(:resolve_a_records) { dns_resolver_worker_instance.a_records(host_name) } - let(:host_name) { Faker::Internet.domain_name } - let(:a_records) { ::Array.new(2) { Faker::Internet.ip_v4_address } } + let(:host_name) { random_domain_name } + let(:a_records) { ::Array.new(2) { random_ip_address } } before { dns_mock_server.assign_mocks(host_name => { a: a_records }) } @@ -69,8 +69,8 @@ def dns_resolver_worker_instance describe '#cname_records' do subject(:resolve_cname_records) { dns_resolver_worker_instance.cname_records(host_name) } - let(:host_name) { Faker::Internet.domain_name } - let(:cname_record) { Faker::Internet.domain_name } + let(:host_name) { random_domain_name } + let(:cname_record) { random_domain_name } before { dns_mock_server.assign_mocks(host_name => { cname: cname_record }) } @@ -80,8 +80,8 @@ def dns_resolver_worker_instance describe '#mx_records' do subject(:resolve_mx_records) { dns_resolver_worker_instance.mx_records(host_name) } - let(:host_name) { Faker::Internet.domain_name } - let(:mx_records) { ::Array.new(2) { Faker::Internet.domain_name } } + let(:host_name) { random_domain_name } + let(:mx_records) { ::Array.new(2) { random_domain_name } } before { dns_mock_server.assign_mocks(host_name => { mx: mx_records }) } @@ -92,10 +92,10 @@ def dns_resolver_worker_instance subject(:resolve_ptr_records) { dns_resolver_worker_instance.ptr_records(host_address) } # TODO: change it after update dns_mock - # let(:host_address) { Faker::Internet.ip_v4_address } + # let(:host_address) { random_ip_address } # should works with 42.42.42.42 or 42.42.42.42.in-addr.arpa; request for 42.42.42.42 let(:host_address) { '42.42.42.42.in-addr.arpa' } - let(:ptr_records) { ::Array.new(2) { Faker::Internet.domain_name } } + let(:ptr_records) { ::Array.new(2) { random_domain_name } } before { dns_mock_server.assign_mocks(host_address => { ptr: ptr_records }) } diff --git a/spec/truemail/log/serializer/validator_text_spec.rb b/spec/truemail/log/serializer/validator_text_spec.rb index 3a5caba..8cf034f 100644 --- a/spec/truemail/log/serializer/validator_text_spec.rb +++ b/spec/truemail/log/serializer/validator_text_spec.rb @@ -12,7 +12,7 @@ describe '.call' do subject(:text_serializer) { described_class.call(validator_instance) } - let(:email) { Faker::Internet.email } + let(:email) { random_email } let(:mx_servers) { create_servers_list } let(:validator_instance) { create_validator(validation_type, email, mx_servers, success: success_status) } diff --git a/spec/truemail/validate/domain_list_match_spec.rb b/spec/truemail/validate/domain_list_match_spec.rb index 181890e..0c4fd99 100644 --- a/spec/truemail/validate/domain_list_match_spec.rb +++ b/spec/truemail/validate/domain_list_match_spec.rb @@ -12,7 +12,7 @@ describe '.check' do subject(:list_match_validator) { described_class.check(result_instance) } - let(:email) { Faker::Internet.email } + let(:email) { random_email } let(:domain) { email[Truemail::RegexConstant::REGEX_DOMAIN_FROM_EMAIL, 1] } let(:configuration_instance) { create_configuration } let(:result_instance) { Truemail::Validator::Result.new(email: email, configuration: configuration_instance) } diff --git a/spec/truemail/validate/mx_spec.rb b/spec/truemail/validate/mx_spec.rb index 3cfa972..02d08c7 100644 --- a/spec/truemail/validate/mx_spec.rb +++ b/spec/truemail/validate/mx_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe Truemail::Validate::Mx do - let(:email) { Faker::Internet.email } + let(:email) { random_email } let(:configuration) { create_configuration(dns: ["127.0.0.1:#{dns_mock_server.port}"]) } let(:result_instance) { Truemail::Validator::Result.new(email: email, configuration: configuration) } @@ -47,9 +47,9 @@ context 'when mx records found' do let(:total_records) { 2 } - let(:mx_records) { ::Array.new(total_records) { Faker::Internet.domain_name } } - let(:a_record) { Faker::Internet.ip_v4_address } - let(:a_records) { ::Array.new(total_records) { [Faker::Internet.ip_v4_address, a_record] } } + let(:mx_records) { ::Array.new(total_records) { random_domain_name } } + let(:a_record) { random_ip_address } + let(:a_records) { ::Array.new(total_records) { [random_ip_address, a_record] } } let(:uniq_mail_servers_by_ip) { a_records.flatten.uniq } let(:mx_records_dns_mock) { mx_records.zip(a_records).to_h.transform_values { |value| { a: value } } } let(:dns_mock_records) do @@ -82,11 +82,11 @@ context 'when cname records found' do let(:total_records) { 2 } - let(:cname_records) { [Faker::Internet.domain_name] } - let(:a_records) { [Faker::Internet.ip_v4_address] } - let(:mx_records) { ::Array.new(total_records) { Faker::Internet.domain_name } } - let(:a_record) { Faker::Internet.ip_v4_address } - let(:mx_a_records) { ::Array.new(total_records) { [Faker::Internet.ip_v4_address, a_record] } } + let(:cname_records) { [random_domain_name] } + let(:a_records) { [random_ip_address] } + let(:mx_records) { ::Array.new(total_records) { random_domain_name } } + let(:a_record) { random_ip_address } + let(:mx_a_records) { ::Array.new(total_records) { [random_ip_address, a_record] } } let(:uniq_mail_servers_by_ip) { mx_a_records.flatten.uniq } let(:cname_records_dns_mock) { cname_records.zip(a_records).to_h.transform_values { |value| { a: [value], mx: mx_records } } } let(:ptr_records_dns_mock) { a_records.zip(cname_records).to_h.transform_values { |value| { ptr: [value] } } } @@ -140,7 +140,7 @@ end context 'when a record found' do - let(:a_record) { Faker::Internet.ip_v4_address } + let(:a_record) { random_ip_address } let(:dns_mock_records) { { email[Truemail::RegexConstant::REGEX_EMAIL_PATTERN, 3] => { a: [a_record] } } } before { dns_mock_server.assign_mocks(dns_mock_records) } diff --git a/spec/truemail/validate/regex_spec.rb b/spec/truemail/validate/regex_spec.rb index 17ad547..14e258a 100644 --- a/spec/truemail/validate/regex_spec.rb +++ b/spec/truemail/validate/regex_spec.rb @@ -14,7 +14,7 @@ let(:configuration_instance) { create_configuration } let(:result_instance) do - Truemail::Validator::Result.new(email: Faker::Internet.email, configuration: configuration_instance) + Truemail::Validator::Result.new(email: random_email, configuration: configuration_instance) end context 'when validation pass' do diff --git a/spec/truemail/validate/smtp/request_spec.rb b/spec/truemail/validate/smtp/request_spec.rb index c90e5ab..58f26bf 100644 --- a/spec/truemail/validate/smtp/request_spec.rb +++ b/spec/truemail/validate/smtp/request_spec.rb @@ -11,8 +11,8 @@ ) end - let(:mail_server) { Faker::Internet.domain_name } - let(:target_email) { Faker::Internet.email } + let(:mail_server) { random_domain_name } + let(:target_email) { random_email } let(:response_instance) { request_instance.response } let(:request_instance_host) { request_instance.host } let(:configuration_instance) { create_configuration } diff --git a/spec/truemail/validate/smtp_spec.rb b/spec/truemail/validate/smtp_spec.rb index aff2d05..4604930 100644 --- a/spec/truemail/validate/smtp_spec.rb +++ b/spec/truemail/validate/smtp_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe Truemail::Validate::Smtp do - let(:email) { Faker::Internet.email } + let(:email) { random_email } let(:configuration_instance) { create_configuration } describe 'defined constants' do @@ -20,7 +20,7 @@ described_class.new( Truemail::Validator::Result.new( email: email, - mail_servers: Array.new(3) { Faker::Internet.ip_v4_address }, + mail_servers: Array.new(3) { random_ip_address }, configuration: configuration_instance ) ) diff --git a/spec/truemail/validator_spec.rb b/spec/truemail/validator_spec.rb index 8732197..c8aefc9 100644 --- a/spec/truemail/validator_spec.rb +++ b/spec/truemail/validator_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Truemail::Validator do subject(:validator_instance) { described_class.new(email, **options) } - let(:email) { Faker::Internet.email } + let(:email) { random_email } let(:configuration_instance) { create_configuration } let(:configuration) { { configuration: configuration_instance } } let(:options) { { **configuration } } @@ -141,7 +141,7 @@ let(:current_validation_type) { :regex } let(:new_validation_type) { :mx } - let(:domain) { Faker::Internet.domain_name } + let(:domain) { random_domain_name } before { configuration_instance.validation_type_for = { domain => new_validation_type } } @@ -166,7 +166,7 @@ RSpec.describe Truemail::Validator::Result do subject(:result_instance) { described_class.new } - let(:email) { Faker::Internet.email } + let(:email) { random_email } specify do expect(result_instance.members).to match_array(Truemail::Validator::RESULT_ATTRS) diff --git a/spec/truemail_spec.rb b/spec/truemail_spec.rb index b8fb369..99c82fa 100644 --- a/spec/truemail_spec.rb +++ b/spec/truemail_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe Truemail do - let(:email) { Faker::Internet.email } + let(:email) { random_email } let(:custom_configuration) { nil } shared_examples 'configuration error' do @@ -36,7 +36,7 @@ describe '.configure' do subject(:configure) { described_class.configure(&config_block) } - let(:config_block) {} # rubocop:disable Lint/EmptyBlock + let(:config_block) { nil } context 'without block' do specify { expect(configure).to be_nil } @@ -90,9 +90,9 @@ )) end - let(:domain) { Faker::Internet.domain_name } - let(:new_email) { Faker::Internet.email } - let(:new_domain) { Faker::Internet.domain_name } + let(:domain) { random_domain_name } + let(:new_email) { random_email } + let(:new_domain) { random_domain_name } let(:new_regex_pattern) { /\A+.\z/ } let(:new_smtp_error_body_pattern) { /\A\d+\z/ } diff --git a/truemail.gemspec b/truemail.gemspec index 4f7b83e..ef895bc 100644 --- a/truemail.gemspec +++ b/truemail.gemspec @@ -36,18 +36,18 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', '~> 1.16' spec.add_development_dependency 'bundler-audit', '~> 0.7.0.1' spec.add_development_dependency 'dns_mock', '~> 1.2' - spec.add_development_dependency 'faker', '~> 2.15', '>= 2.15.1' - spec.add_development_dependency 'fasterer', '~> 0.8.3' + spec.add_development_dependency 'faker', '~> 2.16' + spec.add_development_dependency 'fasterer', '~> 0.9.0' spec.add_development_dependency 'json_matchers', '~> 0.11.1' spec.add_development_dependency 'overcommit', '~> 0.57.0' spec.add_development_dependency 'pry-byebug', '~> 3.9' spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.3' spec.add_development_dependency 'reek', '~> 6.0', '>= 6.0.3' spec.add_development_dependency 'rspec', '~> 3.10' - spec.add_development_dependency 'rubocop', '~> 1.9', '>= 1.9.1' + spec.add_development_dependency 'rubocop', '~> 1.10' spec.add_development_dependency 'rubocop-performance', '~> 1.9', '>= 1.9.2' spec.add_development_dependency 'rubocop-rspec', '~> 2.2' spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'truemail-rspec', '~> 0.3.3' - spec.add_development_dependency 'webmock', '~> 3.11', '>= 3.11.2' + spec.add_development_dependency 'truemail-rspec', '~> 0.4' + spec.add_development_dependency 'webmock', '~> 3.12' end