truemail-rspec 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f6d68015103cf004aa629a7ca43dbf56cac43e347869b1432b6d9febec0376a
4
- data.tar.gz: 050d8be4be336495dff724175b564344aff62bf343fd3ff4f081024e8736c2df
3
+ metadata.gz: 114f3c307d854a6988182866e7feca4697284fd20b52a96a1e13b1e452fffe28
4
+ data.tar.gz: 983c0a0a3cddc80cb451486ff53d15e6948cfae9c434c0ad5d2df939f4b2f589
5
5
  SHA512:
6
- metadata.gz: d41388a66ff75b07b5342c2205ddf3ac66ff7767cdac80a2c577c791b3f80b526733aa788ffd64897320c3bc1d5a2eeaf8bf72eadb22e0e14f0205084ca7ba61
7
- data.tar.gz: 1786e4d9d5aa5c34bee622cf360a1760f8e2e51bce0606523b7b9929c5734ea6069c26db3fc11a46a84fc32ad7ddc6668e01f6320e336e0d86c77b405a232e59
6
+ metadata.gz: 59583cf1eac7f731f9d57e3a9bc698a4b964b301165347ea660b95f9a136b66a5c2a33e83f417f3e556d2eda3e4a8e876e5c2eec4bb0701b9eb169c918133357
7
+ data.tar.gz: 0deba058e67e28f9b034456a9a94f5e06999c4e7016ff095edb51d189f33afc3a7d0ad4516ee54eb796a4818cd4820abaacb5ae7764ea669a041f478870d1ccc
data/.circleci/config.yml CHANGED
@@ -1,11 +1,21 @@
1
+ version: 2.1
2
+
1
3
  defaults: &defaults
2
4
  working_directory: ~/truemail-rspec
3
5
  docker:
4
- - image: circleci/ruby:2.5.0-node
6
+ - image: cimg/ruby:<< parameters.ruby-version >>
5
7
  environment:
6
8
  CC_TEST_REPORTER_ID: 889fa37782e4f5d0f81705f0d869a9c907f04151faae8260dde55d3f74e65606
7
9
 
10
+ orbs:
11
+ ruby: circleci/ruby@1.1.3
12
+
8
13
  references:
14
+ install_bundler: &install_bundler
15
+ run:
16
+ name: Installing Bundler
17
+ command: gem i bundler -v $(tail -1 Gemfile.lock | tr -d ' ')
18
+
9
19
  restore_bundle_cache: &restore_bundle_cache
10
20
  restore_cache:
11
21
  keys:
@@ -24,66 +34,97 @@ references:
24
34
 
25
35
  install_codeclimate_reporter: &install_codeclimate_reporter
26
36
  run:
27
- name: Install Code Climate Test Reporter
37
+ name: Installing CodeClimate test reporter
28
38
  command: |
29
39
  curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
30
40
  chmod +x ./cc-test-reporter
31
41
 
32
- version: 2
33
42
  jobs:
34
- linters:
43
+ linters-ruby:
44
+ parameters:
45
+ ruby-version:
46
+ type: string
47
+
35
48
  <<: *defaults
36
49
 
37
50
  steps:
38
51
  - checkout
39
52
 
53
+ - <<: *install_bundler
40
54
  - <<: *restore_bundle_cache
41
55
  - <<: *bundle_install
42
56
  - <<: *save_bundle_cache
43
57
 
44
58
  - run:
45
- name: Running overcommit
59
+ name: Running Overcommit
46
60
  command: |
47
61
  bundle exec overcommit -s
48
62
  SKIP=AuthorEmail,AuthorName bundle exec overcommit -r
49
63
 
50
- tests:
64
+ tests-ruby:
65
+ parameters:
66
+ ruby-version:
67
+ type: string
68
+
51
69
  <<: *defaults
52
70
 
53
71
  steps:
54
72
  - checkout
55
73
 
74
+ - <<: *install_bundler
56
75
  - <<: *restore_bundle_cache
57
76
  - <<: *bundle_install
58
77
  - <<: *save_bundle_cache
59
78
  - <<: *install_codeclimate_reporter
60
79
 
61
80
  - run:
62
- name: Running tests
81
+ name: Running RSpec
63
82
  command: |
64
- mkdir /tmp/test-results
65
83
  ./cc-test-reporter before-build
66
84
  bundle exec rspec
67
85
 
68
86
  - run:
69
- name: Code Climate Test Coverage
87
+ name: Creating CodeClimate test coverage report
70
88
  command: |
71
89
  ./cc-test-reporter format-coverage -t simplecov -o "coverage/codeclimate.$CIRCLE_NODE_INDEX.json"
72
90
 
73
- - store_test_results:
74
- path: /tmp/test-results
75
-
76
91
  - store_artifacts:
77
- path: /tmp/test-results
78
- destination: test-results
92
+ name: Saving Simplecov coverage artifacts
93
+ path: ~/truemail-rspec/coverage
94
+ destination: coverage
79
95
 
80
96
  - deploy:
97
+ name: Uploading CodeClimate test coverage report
81
98
  command: |
82
99
  ./cc-test-reporter sum-coverage --output - --parts $CIRCLE_NODE_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --debug --input -
83
100
 
101
+ compatibility-ruby:
102
+ parameters:
103
+ ruby-version:
104
+ type: string
105
+ docker:
106
+ - image: cimg/ruby:<< parameters.ruby-version >>
107
+ steps:
108
+ - checkout
109
+ - ruby/install-deps:
110
+ with-cache: false
111
+ path: './vendor/custom_bundle'
112
+ - run:
113
+ name: Running compatibility tests
114
+ command: bundle exec rspec
115
+
84
116
  workflows:
85
- version: 2
86
- build:
117
+ build_and_test:
87
118
  jobs:
88
- - linters
89
- - tests
119
+ - linters-ruby:
120
+ matrix:
121
+ parameters:
122
+ ruby-version: ["2.5"]
123
+ - tests-ruby:
124
+ matrix:
125
+ parameters:
126
+ ruby-version: ["2.5"]
127
+ - compatibility-ruby:
128
+ matrix:
129
+ parameters:
130
+ ruby-version: ["2.6", "2.7", "3.0"]
data/.reek.yml CHANGED
@@ -25,9 +25,14 @@ detectors:
25
25
  DuplicateMethodCall:
26
26
  exclude:
27
27
  - Truemail::RSpec::ValidatorHelper#mx_layer
28
+ - Truemail::RSpec::ValidatorHelper#mx_blacklist_layer
28
29
  - Truemail::RSpec::ValidatorHelper#smtp_layer
29
30
  - Truemail::RSpec::ValidatorHelper#unstub_validation_layers
30
31
 
32
+ TooManyInstanceVariables:
33
+ exclude:
34
+ - Truemail::RSpec::ValidatorHelper::ValidatorFactory
35
+
31
36
  LongParameterList:
32
37
  enabled: false
33
38
 
data/CHANGELOG.md CHANGED
@@ -2,6 +2,88 @@
2
2
 
3
3
  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).
4
4
 
5
+ ## [0.6.0] - 2021-05-13
6
+
7
+ ### Added
8
+
9
+ ```ruby
10
+ # Truemail::Validator instance, successful case
11
+ create_validator(:mx_blacklist)
12
+ => #<Truemail::Validator:0x00007fea91a1d528
13
+ @result=
14
+ #<struct Truemail::Validator::Result
15
+ success=true,
16
+ email="danyell@brakus-dooley.co",
17
+ domain="brakus-dooley.co",
18
+ mail_servers=["175.244.212.125", "69.106.253.221", "7.125.70.85", "152.249.195.7"],
19
+ errors={},
20
+ smtp_debug=nil,
21
+ configuration=
22
+ #<Truemail::Configuration:0x00007fea98977248
23
+ @blacklisted_domains=[],
24
+ @blacklisted_mx_ip_addresses=[],
25
+ @connection_attempts=2,
26
+ @connection_timeout=2,
27
+ @default_validation_type=:smtp,
28
+ @dns=[],
29
+ @email_pattern=/(?=\A.{6,255}\z)(\A([\p{L}0-9]+[\w|\-.+]*)@((?i-mx:[\p{L}0-9]+([\-.]{1}[\p{L}0-9]+)*\.\p{L}{2,63}))\z)/,
30
+ @not_rfc_mx_lookup_flow=false,
31
+ @response_timeout=2,
32
+ @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
33
+ @smtp_fail_fast=false,
34
+ @smtp_safe_check=false,
35
+ @validation_type_by_domain={},
36
+ @verifier_domain="lubowitz.com",
37
+ @verifier_email="shante.keeling@lubowitz.com",
38
+ @whitelist_validation=false,
39
+ @whitelisted_domains=[]>>,
40
+ @validation_type=:mx_blacklist>
41
+
42
+ # Truemail::Validator instance, failure case
43
+ create_validator(:mx_blacklist, success: false)
44
+ => #<Truemail::Validator:0x00007fea988cfd18
45
+ @result=
46
+ #<struct Truemail::Validator::Result
47
+ success=false,
48
+ email="mike.treutel@heathcote.biz",
49
+ domain="heathcote.biz",
50
+ mail_servers=["212.76.177.170", "253.244.87.72", "144.225.110.224"],
51
+ errors={:mx_blacklist=>"blacklisted mx server ip address"},
52
+ smtp_debug=nil,
53
+ configuration=
54
+ #<Truemail::Configuration:0x00007fea988ee150
55
+ @blacklisted_domains=[],
56
+ @blacklisted_mx_ip_addresses=["212.76.177.170", "253.244.87.72", "144.225.110.224"],
57
+ @connection_attempts=2,
58
+ @connection_timeout=2,
59
+ @default_validation_type=:smtp,
60
+ @dns=[],
61
+ @email_pattern=/(?=\A.{6,255}\z)(\A([\p{L}0-9]+[\w|\-.+]*)@((?i-mx:[\p{L}0-9]+([\-.]{1}[\p{L}0-9]+)*\.\p{L}{2,63}))\z)/,
62
+ @not_rfc_mx_lookup_flow=false,
63
+ @response_timeout=2,
64
+ @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
65
+ @smtp_fail_fast=false,
66
+ @smtp_safe_check=false,
67
+ @validation_type_by_domain={},
68
+ @verifier_domain="grant-flatley.org",
69
+ @verifier_email="mariano@grant-flatley.org",
70
+ @whitelist_validation=false,
71
+ @whitelisted_domains=[]>>,
72
+ @validation_type=:mx_blacklist>
73
+ ```
74
+
75
+ - Ability to create `Truemail::Validator` instance for `MxBlacklist` validation layer
76
+ - Stub for `MxBlacklist` validation layer
77
+ - CircleCI config for using multiple Ruby versions
78
+
79
+ ### Updated
80
+
81
+ - Updated gem development dependencies
82
+
83
+ ### Fixed
84
+
85
+ - Simplecov coverage issues
86
+
5
87
  ## [0.5.0] - 2021-05-05
6
88
 
7
89
  ### Added
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- truemail-rspec (0.5.0)
4
+ truemail-rspec (0.6.0)
5
5
  faker (~> 2.17)
6
6
  rspec (~> 3.10)
7
- truemail (>= 2.3)
7
+ truemail (>= 2.4)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
@@ -19,7 +19,7 @@ GEM
19
19
  colorize (0.8.1)
20
20
  concurrent-ruby (1.1.8)
21
21
  diff-lcs (1.4.4)
22
- docile (1.3.5)
22
+ docile (1.4.0)
23
23
  faker (2.17.0)
24
24
  i18n (>= 1.6, < 2)
25
25
  fasterer (0.9.0)
@@ -77,7 +77,7 @@ GEM
77
77
  unicode-display_width (>= 1.4.0, < 3.0)
78
78
  rubocop-ast (1.5.0)
79
79
  parser (>= 3.0.1.1)
80
- rubocop-performance (1.11.2)
80
+ rubocop-performance (1.11.3)
81
81
  rubocop (>= 1.7.0, < 2.0)
82
82
  rubocop-ast (>= 0.4.0)
83
83
  rubocop-rspec (2.3.0)
@@ -95,7 +95,7 @@ GEM
95
95
  simpleidn (0.2.1)
96
96
  unf (~> 0.1.4)
97
97
  thor (1.1.0)
98
- truemail (2.4.0)
98
+ truemail (2.4.1)
99
99
  simpleidn (~> 0.2.1)
100
100
  unf (0.1.4)
101
101
  unf_ext
@@ -103,10 +103,10 @@ GEM
103
103
  unicode-display_width (2.0.0)
104
104
 
105
105
  PLATFORMS
106
- ruby
106
+ x86_64-darwin-19
107
107
 
108
108
  DEPENDENCIES
109
- bundler (~> 1.16)
109
+ bundler (~> 2.2, >= 2.2.17)
110
110
  bundler-audit (~> 0.8.0)
111
111
  faker (~> 2.17)
112
112
  fasterer (~> 0.9.0)
@@ -116,10 +116,10 @@ DEPENDENCIES
116
116
  reek (~> 6.0, >= 6.0.4)
117
117
  rspec (~> 3.10)
118
118
  rubocop (~> 1.14)
119
- rubocop-performance (~> 1.11, >= 1.11.2)
119
+ rubocop-performance (~> 1.11, >= 1.11.3)
120
120
  rubocop-rspec (~> 2.3)
121
121
  simplecov (~> 0.17.1)
122
122
  truemail-rspec!
123
123
 
124
124
  BUNDLED WITH
125
- 1.16.6
125
+ 2.2.17
data/README.md CHANGED
@@ -129,7 +129,7 @@ create_servers_list(42) # => returns array with 42 random ip addresses
129
129
 
130
130
  ```ruby
131
131
  create_validator(
132
- validation_type, # optional, type:Symbol, can be :regex, :mx or :smtp, by default creates :smtp validation
132
+ validation_type, # optional, type:Symbol, can be :whitelist, :regex, :mx, :mx_blacklist or :smtp, by default creates :smtp validation
133
133
  email, # optional, type:String, by default random email
134
134
  mail_servers, # optional, type:Array(String), by default array with random ip addresses
135
135
  success: true, # optional, type:Bool, by default true
@@ -17,7 +17,7 @@ module Truemail
17
17
  )
18
18
  set_expected_result(validation_type, email, mail_servers, success, configuration, rcptto_error)
19
19
  stub_validation_layers
20
- validator_instance = ValidatorFactory.call(validation_type, success, email, configuration)
20
+ validator_instance = ValidatorFactory.call(validation_type, success, email, mail_servers, configuration)
21
21
  unstub_validation_layers
22
22
  validator_instance
23
23
  end
@@ -39,6 +39,7 @@ module Truemail
39
39
  case validation_type
40
40
  when :regex then regex_layer
41
41
  when :mx then mx_layer
42
+ when :mx_blacklist then mx_blacklist_layer
42
43
  else smtp_layer
43
44
  end
44
45
  end
@@ -63,6 +64,13 @@ module Truemail
63
64
  allow_any_instance_of(Truemail::Validate::Mx).to receive(:domain_not_include_null_mx).and_return(success)
64
65
  end
65
66
 
67
+ def mx_blacklist_layer # rubocop:disable Metrics/AbcSize
68
+ allow(Truemail::Validate::Regex).to receive(:check).and_return(true)
69
+ allow_any_instance_of(Truemail::Validate::Mx).to receive(:mx_records).and_return(mail_servers)
70
+ allow_any_instance_of(Truemail::Validate::Mx).to receive(:domain_not_include_null_mx).and_return(true)
71
+ allow_any_instance_of(Truemail::Validate::MxBlacklist).to receive(:not_blacklisted_mail_servers?).and_return(success)
72
+ end
73
+
66
74
  def request_instance
67
75
  request = Truemail::Validate::Smtp::Request.new(
68
76
  host: mail_servers.first,
@@ -92,14 +100,15 @@ module Truemail
92
100
  end
93
101
 
94
102
  class ValidatorFactory
95
- def self.call(validation_type, success, email, configuration)
96
- new(validation_type, success, email, configuration).build
103
+ def self.call(validation_type, success, email, mail_servers, configuration)
104
+ new(validation_type, success, email, mail_servers, configuration).build
97
105
  end
98
106
 
99
- def initialize(validation_type, success, email, configuration)
107
+ def initialize(validation_type, success, email, mail_servers, configuration)
100
108
  @validation_type = validation_type
101
109
  @success = success
102
110
  @email = email
111
+ @mail_servers = mail_servers
103
112
  @configuration = configuration
104
113
  end
105
114
 
@@ -110,15 +119,19 @@ module Truemail
110
119
 
111
120
  private
112
121
 
113
- attr_reader :success, :email, :configuration
122
+ attr_reader :success, :email, :mail_servers, :configuration
114
123
  attr_accessor :validation_type
115
124
 
116
125
  def process_validator_params
117
- return unless validation_type.eql?(:whitelist)
118
- self.validation_type = nil
119
- method = success ? :whitelisted_domains : :blacklisted_domains
120
- domain = email[Truemail::RegexConstant::REGEX_EMAIL_PATTERN, 3]
121
- configuration.tap { |config| config.public_send(method) << domain }
126
+ case validation_type
127
+ when :whitelist
128
+ self.validation_type = nil
129
+ method = success ? :whitelisted_domains : :blacklisted_domains
130
+ domain = email[Truemail::RegexConstant::REGEX_EMAIL_PATTERN, 3]
131
+ configuration.tap { |config| config.public_send(method) << domain }
132
+ when :mx_blacklist
133
+ configuration.blacklisted_mx_ip_addresses.push(*mail_servers) unless success
134
+ end
122
135
  end
123
136
  end
124
137
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Truemail
4
4
  module RSpec
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
32
  spec.require_paths = ['lib']
33
33
 
34
- spec.add_development_dependency 'bundler', '~> 1.16'
34
+ spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.17'
35
35
  spec.add_development_dependency 'bundler-audit', '~> 0.8.0'
36
36
  spec.add_development_dependency 'faker', '~> 2.17'
37
37
  spec.add_development_dependency 'fasterer', '~> 0.9.0'
@@ -41,10 +41,10 @@ Gem::Specification.new do |spec|
41
41
  spec.add_development_dependency 'reek', '~> 6.0', '>= 6.0.4'
42
42
  spec.add_development_dependency 'rspec', '~> 3.10'
43
43
  spec.add_development_dependency 'rubocop', '~> 1.14'
44
- spec.add_development_dependency 'rubocop-performance', '~> 1.11', '>= 1.11.2'
44
+ spec.add_development_dependency 'rubocop-performance', '~> 1.11', '>= 1.11.3'
45
45
  spec.add_development_dependency 'rubocop-rspec', '~> 2.3'
46
46
  spec.add_development_dependency 'simplecov', '~> 0.17.1'
47
47
  spec.add_runtime_dependency 'faker', '~> 2.17'
48
48
  spec.add_runtime_dependency 'rspec', '~> 3.10'
49
- spec.add_runtime_dependency 'truemail', '>= 2.3'
49
+ spec.add_runtime_dependency 'truemail', '>= 2.4'
50
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truemail-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladislav Trotsenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-05 00:00:00.000000000 Z
11
+ date: 2021-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: '2.2'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.2.17
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '1.16'
29
+ version: '2.2'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.2.17
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler-audit
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -171,7 +177,7 @@ dependencies:
171
177
  version: '1.11'
172
178
  - - ">="
173
179
  - !ruby/object:Gem::Version
174
- version: 1.11.2
180
+ version: 1.11.3
175
181
  type: :development
176
182
  prerelease: false
177
183
  version_requirements: !ruby/object:Gem::Requirement
@@ -181,7 +187,7 @@ dependencies:
181
187
  version: '1.11'
182
188
  - - ">="
183
189
  - !ruby/object:Gem::Version
184
- version: 1.11.2
190
+ version: 1.11.3
185
191
  - !ruby/object:Gem::Dependency
186
192
  name: rubocop-rspec
187
193
  requirement: !ruby/object:Gem::Requirement
@@ -244,14 +250,14 @@ dependencies:
244
250
  requirements:
245
251
  - - ">="
246
252
  - !ruby/object:Gem::Version
247
- version: '2.3'
253
+ version: '2.4'
248
254
  type: :runtime
249
255
  prerelease: false
250
256
  version_requirements: !ruby/object:Gem::Requirement
251
257
  requirements:
252
258
  - - ">="
253
259
  - !ruby/object:Gem::Version
254
- version: '2.3'
260
+ version: '2.4'
255
261
  description: Truemail RSpec helpers
256
262
  email:
257
263
  - admin@bestweb.com.ua