smtp_mock 0.1.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +20 -5
- data/.circleci/gemspec_compatible +36 -0
- data/.circleci/gemspec_latest +47 -0
- data/.codeclimate.yml +1 -4
- data/.github/DEVELOPMENT_ENVIRONMENT_GUIDE.md +26 -0
- data/.reek.yml +1 -0
- data/.rubocop.yml +9 -3
- data/CHANGELOG.md +36 -0
- data/CONTRIBUTING.md +4 -2
- data/README.md +12 -5
- data/lib/smtp_mock/cli/resolver.rb +25 -12
- data/lib/smtp_mock/core.rb +2 -0
- data/lib/smtp_mock/dependency.rb +17 -0
- data/lib/smtp_mock/error/dependency.rb +1 -0
- data/lib/smtp_mock/server.rb +2 -2
- data/lib/smtp_mock/version.rb +1 -1
- data/smtp_mock.gemspec +3 -14
- metadata +9 -137
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33e54a07175e2b3e8245c8934d9839082a28e02f51d958127135342187e87326
|
4
|
+
data.tar.gz: cf9ff702f31049e1bc849bcde4f3cee662a5e76d77adf7f2404e634c35e9a53a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e13797075610d3a5d99917a8d4584014ef320bc8a522a2785061b24d1fe842dda34d9cee834af07918ae9b826de3566244bdd0b693ac632363bebe6302874dc
|
7
|
+
data.tar.gz: 490d7e3e2688ef984bd2de0a90a90ee9946120ae0eb2b532eb561e4e8b102b0ef6e8e6d4cfe80df6edd111e4e15e03c84e58b7c1e0bd35186c19c89835e41a04
|
data/.circleci/config.yml
CHANGED
@@ -6,7 +6,7 @@ defaults: &defaults
|
|
6
6
|
- image: cimg/ruby:<< parameters.ruby-version >>
|
7
7
|
|
8
8
|
orbs:
|
9
|
-
ruby: circleci/ruby@1.
|
9
|
+
ruby: circleci/ruby@1.4.0
|
10
10
|
|
11
11
|
references:
|
12
12
|
restore_bundle_cache: &restore_bundle_cache
|
@@ -40,6 +40,18 @@ references:
|
|
40
40
|
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
41
41
|
chmod +x ./cc-test-reporter
|
42
42
|
|
43
|
+
use_latest_gemspec: &use_latest_gemspec
|
44
|
+
run:
|
45
|
+
name: Using latest gemspec
|
46
|
+
command: |
|
47
|
+
cp .circleci/gemspec_latest smtp_mock.gemspec
|
48
|
+
|
49
|
+
use_compatible_gemspec: &use_compatible_gemspec
|
50
|
+
run:
|
51
|
+
name: Using compatible gemspec
|
52
|
+
command: |
|
53
|
+
cp .circleci/gemspec_compatible smtp_mock.gemspec
|
54
|
+
|
43
55
|
jobs:
|
44
56
|
linters-ruby:
|
45
57
|
parameters:
|
@@ -51,6 +63,7 @@ jobs:
|
|
51
63
|
steps:
|
52
64
|
- checkout
|
53
65
|
|
66
|
+
- <<: *use_latest_gemspec
|
54
67
|
- <<: *restore_bundle_cache
|
55
68
|
- <<: *bundle_install
|
56
69
|
- <<: *save_bundle_cache
|
@@ -71,6 +84,7 @@ jobs:
|
|
71
84
|
steps:
|
72
85
|
- checkout
|
73
86
|
|
87
|
+
- <<: *use_latest_gemspec
|
74
88
|
- <<: *restore_bundle_cache
|
75
89
|
- <<: *bundle_install
|
76
90
|
- <<: *save_bundle_cache
|
@@ -106,8 +120,9 @@ jobs:
|
|
106
120
|
- image: cimg/ruby:<< parameters.ruby-version >>
|
107
121
|
steps:
|
108
122
|
- checkout
|
123
|
+
- <<: *use_compatible_gemspec
|
109
124
|
- ruby/install-deps:
|
110
|
-
bundler-version: "2.3.
|
125
|
+
bundler-version: "2.3.9"
|
111
126
|
with-cache: false
|
112
127
|
path: './vendor/custom_bundle'
|
113
128
|
- <<: *system_dependencies
|
@@ -121,12 +136,12 @@ workflows:
|
|
121
136
|
- linters-ruby:
|
122
137
|
matrix:
|
123
138
|
parameters:
|
124
|
-
ruby-version: ["
|
139
|
+
ruby-version: ["3.1"]
|
125
140
|
- tests-ruby:
|
126
141
|
matrix:
|
127
142
|
parameters:
|
128
|
-
ruby-version: ["
|
143
|
+
ruby-version: ["3.1"]
|
129
144
|
- compatibility-ruby:
|
130
145
|
matrix:
|
131
146
|
parameters:
|
132
|
-
ruby-version: ["2.
|
147
|
+
ruby-version: ["2.5", "2.6", "2.7", "3.0"]
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/smtp_mock/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'smtp_mock'
|
7
|
+
spec.version = SmtpMock::VERSION
|
8
|
+
spec.authors = ['Vladislav Trotsenko']
|
9
|
+
spec.email = ['admin@bestweb.com.ua']
|
10
|
+
|
11
|
+
spec.summary = %(smtp_mock)
|
12
|
+
spec.description = %(💎 Ruby SMTP mock. Mimic any SMTP server behaviour for your test environment.)
|
13
|
+
|
14
|
+
spec.homepage = 'https://github.com/mocktools/ruby-smtp-mock'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.metadata = {
|
18
|
+
'homepage_uri' => 'https://github.com/mocktools/ruby-smtp-mock',
|
19
|
+
'changelog_uri' => 'https://github.com/mocktools/ruby-smtp-mock/blob/master/CHANGELOG.md',
|
20
|
+
'source_code_uri' => 'https://github.com/mocktools/ruby-smtp-mock',
|
21
|
+
'documentation_uri' => 'https://github.com/mocktools/ruby-smtp-mock/blob/master/README.md',
|
22
|
+
'bug_tracker_uri' => 'https://github.com/mocktools/ruby-smtp-mock/issues'
|
23
|
+
}
|
24
|
+
|
25
|
+
spec.required_ruby_version = '>= 2.5.0'
|
26
|
+
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
spec.executables = %w[smtp_mock]
|
29
|
+
spec.require_paths = %w[lib]
|
30
|
+
|
31
|
+
spec.add_runtime_dependency 'dry-struct', '~> 1.4'
|
32
|
+
|
33
|
+
spec.add_development_dependency 'ffaker', '~> 2.20'
|
34
|
+
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
|
35
|
+
spec.add_development_dependency 'rspec', '~> 3.11'
|
36
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/smtp_mock/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'smtp_mock'
|
7
|
+
spec.version = SmtpMock::VERSION
|
8
|
+
spec.authors = ['Vladislav Trotsenko']
|
9
|
+
spec.email = ['admin@bestweb.com.ua']
|
10
|
+
|
11
|
+
spec.summary = %(smtp_mock)
|
12
|
+
spec.description = %(💎 Ruby SMTP mock. Mimic any SMTP server behaviour for your test environment.)
|
13
|
+
|
14
|
+
spec.homepage = 'https://github.com/mocktools/ruby-smtp-mock'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.metadata = {
|
18
|
+
'homepage_uri' => 'https://github.com/mocktools/ruby-smtp-mock',
|
19
|
+
'changelog_uri' => 'https://github.com/mocktools/ruby-smtp-mock/blob/master/CHANGELOG.md',
|
20
|
+
'source_code_uri' => 'https://github.com/mocktools/ruby-smtp-mock',
|
21
|
+
'documentation_uri' => 'https://github.com/mocktools/ruby-smtp-mock/blob/master/README.md',
|
22
|
+
'bug_tracker_uri' => 'https://github.com/mocktools/ruby-smtp-mock/issues'
|
23
|
+
}
|
24
|
+
|
25
|
+
spec.required_ruby_version = '>= 2.5.0'
|
26
|
+
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
spec.executables = %w[smtp_mock]
|
29
|
+
spec.require_paths = %w[lib]
|
30
|
+
spec.post_install_message = 'smtpmock is required system dependency. For more details run: `bundle exec smtp_mock -h`'
|
31
|
+
|
32
|
+
spec.add_runtime_dependency 'dry-struct', '~> 1.4'
|
33
|
+
|
34
|
+
spec.add_development_dependency 'bundler-audit', '~> 0.9.0.1'
|
35
|
+
spec.add_development_dependency 'fasterer', '~> 0.9.0'
|
36
|
+
spec.add_development_dependency 'ffaker', '~> 2.20'
|
37
|
+
spec.add_development_dependency 'net-smtp', '~> 0.3.1'
|
38
|
+
spec.add_development_dependency 'overcommit', '~> 0.58.0'
|
39
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.9'
|
40
|
+
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
|
41
|
+
spec.add_development_dependency 'reek', '~> 6.1'
|
42
|
+
spec.add_development_dependency 'rspec', '~> 3.11'
|
43
|
+
spec.add_development_dependency 'rubocop', '~> 1.26'
|
44
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.13', '>= 1.13.3'
|
45
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.9'
|
46
|
+
spec.add_development_dependency 'simplecov', '~> 0.21.2'
|
47
|
+
end
|
data/.codeclimate.yml
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Development environment guide
|
2
|
+
|
3
|
+
## Preparing
|
4
|
+
|
5
|
+
Clone `smtp_mock` repository:
|
6
|
+
|
7
|
+
```bash
|
8
|
+
git clone https://github.com/mocktools/ruby-smtp-mock.git
|
9
|
+
cd ruby-smtp-mock
|
10
|
+
```
|
11
|
+
|
12
|
+
Configure latest Ruby environment:
|
13
|
+
|
14
|
+
```bash
|
15
|
+
echo 'ruby-3.1.1' > .ruby-version
|
16
|
+
cp .circleci/gemspec_latest smtp_mock.gemspec
|
17
|
+
```
|
18
|
+
|
19
|
+
## Commiting
|
20
|
+
|
21
|
+
Commit your changes excluding `.ruby-version`, `smtp_mock.gemspec`
|
22
|
+
|
23
|
+
```bash
|
24
|
+
git add . ':!.ruby-version' ':!smtp_mock.gemspec'
|
25
|
+
git commit -m 'Your new awesome smtp_mock feature'
|
26
|
+
```
|
data/.reek.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -166,6 +166,9 @@ Style/MapToHash:
|
|
166
166
|
Style/OpenStructUse:
|
167
167
|
Enabled: true
|
168
168
|
|
169
|
+
Style/NestedFileDirname:
|
170
|
+
Enabled: true
|
171
|
+
|
169
172
|
Layout/LineLength:
|
170
173
|
Max: 150
|
171
174
|
|
@@ -290,9 +293,6 @@ Gemspec/DateAssignment:
|
|
290
293
|
Gemspec/RequireMFA:
|
291
294
|
Enabled: false
|
292
295
|
|
293
|
-
Gemspec/RubyVersionGlobalsUsage:
|
294
|
-
Enabled: false
|
295
|
-
|
296
296
|
Security/IoMethods:
|
297
297
|
Enabled: true
|
298
298
|
|
@@ -394,3 +394,9 @@ RSpec/SubjectDeclaration:
|
|
394
394
|
|
395
395
|
RSpec/FactoryBot/SyntaxMethods:
|
396
396
|
Enabled: true
|
397
|
+
|
398
|
+
RSpec/BeEq:
|
399
|
+
Enabled: true
|
400
|
+
|
401
|
+
RSpec/BeNil:
|
402
|
+
Enabled: true
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,42 @@
|
|
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
|
+
|
6
|
+
## [1.0.1] - 2022-03-10
|
7
|
+
|
8
|
+
### Added
|
9
|
+
|
10
|
+
- Development environment guide
|
11
|
+
|
12
|
+
### Updated
|
13
|
+
|
14
|
+
- Updated gemspecs
|
15
|
+
- Updated codeclimate/circleci configs
|
16
|
+
- Updated gem development dependencies
|
17
|
+
- Updated gem version
|
18
|
+
|
19
|
+
## [1.0.0] - 2022-01-31
|
20
|
+
|
21
|
+
### Added
|
22
|
+
|
23
|
+
- Added `smtpmock` version checker
|
24
|
+
- Added command for upgrade `smtpmock` to latest version
|
25
|
+
- Added `SmtpMock::Error::Dependency::SMTPMOCK_MIN_VERSION`
|
26
|
+
- Added `SmtpMock::Server#version`, tests
|
27
|
+
|
28
|
+
### Updated
|
29
|
+
|
30
|
+
- Updated `SmtpMock::Dependency.verify_dependencies`, tests
|
31
|
+
- Updated `SmtpMock::Cli::Command`, tests
|
32
|
+
- Updated gem version, documentation
|
33
|
+
|
34
|
+
## [0.1.2] - 2022-01-24
|
35
|
+
|
36
|
+
### Updated
|
37
|
+
|
38
|
+
- Updated `SmtpMock::Cli::Command`, tests
|
39
|
+
- Updated gem version, documentation
|
40
|
+
|
5
41
|
## [0.1.1] - 2022-01-18
|
6
42
|
|
7
43
|
### Updated
|
data/CONTRIBUTING.md
CHANGED
@@ -42,5 +42,7 @@ Guidelines for pull requests:
|
|
42
42
|
2. Fork the repo, checkout to `develop` branch
|
43
43
|
3. Run the tests. This is to make sure your starting point works
|
44
44
|
4. Read our [branch naming convention](.github/BRANCH_NAMING_CONVENTION.md)
|
45
|
-
5. Create a new branch
|
46
|
-
6.
|
45
|
+
5. Create a new branch
|
46
|
+
6. Read our [setup development environment guide](.github/DEVELOPMENT_ENVIRONMENT_GUIDE.md)
|
47
|
+
7. Make your changes. Please note that your PR should include tests for the new codebase!
|
48
|
+
9. Push to your fork and submit a pull request to `develop` branch
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# ![Ruby SmtpMock - mimic any 📤 SMTP server behaviour for your test environment
|
1
|
+
# ![Ruby SmtpMock - mimic any 📤 SMTP server behaviour for your test environment with fake SMTP server](https://repository-images.githubusercontent.com/443795043/81ce5b00-0915-4dd0-93ad-88e6699e18cd)
|
2
2
|
|
3
3
|
[![Maintainability](https://api.codeclimate.com/v1/badges/315c5fff7449a11868dd/maintainability)](https://codeclimate.com/github/mocktools/ruby-smtp-mock/maintainability)
|
4
4
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/315c5fff7449a11868dd/test_coverage)](https://codeclimate.com/github/mocktools/ruby-smtp-mock/test_coverage)
|
@@ -70,15 +70,16 @@ Then install [`smtpmock`](https://github.com/mocktools/go-smtp-mock) as system d
|
|
70
70
|
|
71
71
|
### Dependency manager
|
72
72
|
|
73
|
-
This gem includes
|
73
|
+
This gem includes easy system dependency manager. Run `bundle exec smtp_mock` with options for manage `smtpmock` system dependency.
|
74
74
|
|
75
75
|
#### Available flags
|
76
76
|
|
77
77
|
| Flag | Description | Example of usage |
|
78
78
|
| --- | --- | --- |
|
79
79
|
| `-s`, `--sudo` | Run command as sudo | `bundle exec smtp_mock -s -i ~` |
|
80
|
-
| `-i`, `--install=PATH` | Install smtpmock to the existing path | `bundle exec smtp_mock -i ~/existent_dir` |
|
81
|
-
| `-u`, `--uninstall` | Uninstall smtpmock | `bundle exec smtp_mock -u` |
|
80
|
+
| `-i`, `--install=PATH` | Install `smtpmock` to the existing path | `bundle exec smtp_mock -i ~/existent_dir` |
|
81
|
+
| `-u`, `--uninstall` | Uninstall `smtpmock` | `bundle exec smtp_mock -u` |
|
82
|
+
| `-g`, `--upgrade` | Upgrade to latest version of `smtpmock` | `bundle exec smtp_mock -g` |
|
82
83
|
| `-h`, `--help` | Prints help | `bundle exec smtp_mock -h` |
|
83
84
|
|
84
85
|
### DSL
|
@@ -134,6 +135,9 @@ smtp_mock_server.port # => 55640
|
|
134
135
|
# returns current smtp mock server port
|
135
136
|
smtp_mock_server.pid # => 38195
|
136
137
|
|
138
|
+
# returns current smtp mock server version
|
139
|
+
smtp_mock_server.version # => '1.5.2'
|
140
|
+
|
137
141
|
# interface for graceful shutdown current smtp mock server
|
138
142
|
smtp_mock_server.stop # => true
|
139
143
|
|
@@ -157,6 +161,7 @@ Require this either in your Gemfile or in RSpec's support scripts. So either:
|
|
157
161
|
|
158
162
|
```ruby
|
159
163
|
# Gemfile
|
164
|
+
|
160
165
|
group :test do
|
161
166
|
gem 'rspec'
|
162
167
|
gem 'smtp_mock', require: 'smtp_mock/test_framework/rspec'
|
@@ -167,6 +172,7 @@ or
|
|
167
172
|
|
168
173
|
```ruby
|
169
174
|
# spec/support/config/smtp_mock.rb
|
175
|
+
|
170
176
|
require 'smtp_mock/test_framework/rspec'
|
171
177
|
```
|
172
178
|
|
@@ -176,13 +182,14 @@ Just add `SmtpMock::TestFramework::RSpec::Helper` if you wanna use shortcut `smt
|
|
176
182
|
|
177
183
|
```ruby
|
178
184
|
# spec/support/config/smtp_mock.rb
|
185
|
+
|
179
186
|
RSpec.configure do |config|
|
180
187
|
config.include SmtpMock::TestFramework::RSpec::Helper
|
181
188
|
end
|
182
189
|
```
|
183
190
|
|
184
191
|
```ruby
|
185
|
-
# your awesome
|
192
|
+
# your awesome smtp_client_spec.rb
|
186
193
|
|
187
194
|
RSpec.describe SmtpClient do
|
188
195
|
subject(:smtp_response) do
|
@@ -12,36 +12,35 @@ module SmtpMock
|
|
12
12
|
opt_parser = ::OptionParser.new do |parser|
|
13
13
|
parser.banner = SmtpMock::Cli::Resolver::USE_CASE
|
14
14
|
|
15
|
-
parser.on('-s', '--sudo', 'Run command as sudo')
|
16
|
-
self.sudo = true
|
17
|
-
end
|
15
|
+
parser.on('-s', '--sudo', 'Run command as sudo') { self.sudo = true }
|
18
16
|
|
19
17
|
parser.on('-iPATH', '--install=PATH', 'Install smtpmock to the existing path') do |argument|
|
20
18
|
self.install_path = argument
|
21
19
|
return self.message = 'smtpmock is already installed' if ::File.exist?(binary_path)
|
22
20
|
|
23
|
-
|
21
|
+
install_to(install_path)
|
24
22
|
::Kernel.system("#{as_sudo}ln -s #{binary_path} #{SmtpMock::Dependency::SYMLINK}")
|
25
|
-
|
26
23
|
self.message = 'smtpmock was installed successfully'
|
27
24
|
end
|
28
25
|
|
29
26
|
parser.on('-u', '--uninstall', 'Uninstall smtpmock') do
|
30
|
-
|
31
|
-
return self.message = 'smtpmock not installed yet' if current_smtpmock_path.empty?
|
27
|
+
return if not_installed? # rubocop:disable Lint/NonLocalExitFromIterator
|
32
28
|
|
33
29
|
::Kernel.system("#{as_sudo}unlink #{SmtpMock::Dependency::SYMLINK}")
|
34
30
|
::Kernel.system("rm #{current_smtpmock_path}")
|
35
|
-
|
36
31
|
self.message = 'smtpmock was uninstalled successfully'
|
37
32
|
end
|
38
33
|
|
39
|
-
|
34
|
+
parser.on('-g', '--upgrade', 'Upgrade to latest version of smtpmock') do
|
35
|
+
return if not_installed? # rubocop:disable Lint/NonLocalExitFromIterator
|
40
36
|
|
41
|
-
|
42
|
-
|
43
|
-
::Kernel.exit
|
37
|
+
install_to(current_smtpmock_path[%r{(.+)/.+}, 1])
|
38
|
+
self.message = 'smtpmock was upgraded successfully'
|
44
39
|
end
|
40
|
+
|
41
|
+
parser.on('-h', '--help', 'Prints help') { self.message = parser.to_s }
|
42
|
+
|
43
|
+
self.success = true
|
45
44
|
end
|
46
45
|
|
47
46
|
opt_parser.parse(command_line_args) # TODO: add error handler
|
@@ -53,9 +52,23 @@ module SmtpMock
|
|
53
52
|
"#{install_path}/smtpmock"
|
54
53
|
end
|
55
54
|
|
55
|
+
def install_to(install_path)
|
56
|
+
::Kernel.system("cd #{install_path} && curl -sL #{SmtpMock::Cli::Resolver::DOWNLOAD_SCRIPT} | bash")
|
57
|
+
end
|
58
|
+
|
56
59
|
def as_sudo
|
57
60
|
return 'sudo ' if sudo
|
58
61
|
end
|
62
|
+
|
63
|
+
def current_smtpmock_path
|
64
|
+
@current_smtpmock_path ||= SmtpMock::Dependency.smtpmock_path_by_symlink
|
65
|
+
end
|
66
|
+
|
67
|
+
def not_installed?
|
68
|
+
return false unless current_smtpmock_path.empty?
|
69
|
+
self.message = 'smtpmock not installed yet'
|
70
|
+
true
|
71
|
+
end
|
59
72
|
end
|
60
73
|
end
|
61
74
|
end
|
data/lib/smtp_mock/core.rb
CHANGED
data/lib/smtp_mock/dependency.rb
CHANGED
@@ -4,6 +4,7 @@ module SmtpMock
|
|
4
4
|
module Dependency
|
5
5
|
BINARY_SHORTCUT = 'smtpmock'
|
6
6
|
SYMLINK = "/usr/local/bin/#{BINARY_SHORTCUT}"
|
7
|
+
VERSION_REGEX_PATTERN = /#{BINARY_SHORTCUT}: (.+)/.freeze
|
7
8
|
|
8
9
|
class << self
|
9
10
|
def smtpmock_path_by_symlink
|
@@ -16,11 +17,27 @@ module SmtpMock
|
|
16
17
|
|
17
18
|
def verify_dependencies
|
18
19
|
raise SmtpMock::Error::Dependency, SmtpMock::Error::Dependency::SMTPMOCK_NOT_INSTALLED unless smtpmock?
|
20
|
+
current_version = version
|
21
|
+
raise SmtpMock::Error::Dependency, SmtpMock::Error::Dependency::SMTPMOCK_MIN_VERSION unless minimal_version?(current_version)
|
22
|
+
current_version
|
19
23
|
end
|
20
24
|
|
21
25
|
def compose_command(command_line_args)
|
22
26
|
"#{SmtpMock::Dependency::BINARY_SHORTCUT} #{command_line_args}".strip
|
23
27
|
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def version
|
32
|
+
::Kernel.public_send(
|
33
|
+
:`,
|
34
|
+
"#{SmtpMock::Dependency::BINARY_SHORTCUT} -v"
|
35
|
+
)[SmtpMock::Dependency::VERSION_REGEX_PATTERN, 1]
|
36
|
+
end
|
37
|
+
|
38
|
+
def minimal_version?(current_version)
|
39
|
+
!!current_version && current_version >= SmtpMock::SMTPMOCK_MIN_VERSION
|
40
|
+
end
|
24
41
|
end
|
25
42
|
end
|
26
43
|
end
|
@@ -4,6 +4,7 @@ module SmtpMock
|
|
4
4
|
module Error
|
5
5
|
class Dependency < ::RuntimeError
|
6
6
|
SMTPMOCK_NOT_INSTALLED = 'smtpmock is required system dependency. Run `bundle exec smtp_mock -h` for details'
|
7
|
+
SMTPMOCK_MIN_VERSION = "smtpmock #{SmtpMock::SMTPMOCK_MIN_VERSION} or higher is required. Run `bundle exec smtp_mock -g` for version upgrade"
|
7
8
|
end
|
8
9
|
end
|
9
10
|
end
|
data/lib/smtp_mock/server.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module SmtpMock
|
4
4
|
class Server
|
5
|
-
attr_reader :pid, :port
|
5
|
+
attr_reader :pid, :port, :version
|
6
6
|
|
7
7
|
def initialize( # rubocop:disable Metrics/ParameterLists
|
8
8
|
deps_handler = SmtpMock::Dependency,
|
@@ -11,7 +11,7 @@ module SmtpMock
|
|
11
11
|
process = SmtpMock::Server::Process,
|
12
12
|
**args
|
13
13
|
)
|
14
|
-
deps_handler.verify_dependencies
|
14
|
+
@version = deps_handler.verify_dependencies
|
15
15
|
args[:port] = port_checker.random_free_port unless args.include?(:port)
|
16
16
|
@command_line_args, @port = args_builder.call(**args), args[:port]
|
17
17
|
@deps_handler, @port_checker, @process = deps_handler, port_checker, process
|
data/lib/smtp_mock/version.rb
CHANGED
data/smtp_mock.gemspec
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require 'smtp_mock/version'
|
3
|
+
require_relative 'lib/smtp_mock/version'
|
6
4
|
|
7
5
|
Gem::Specification.new do |spec|
|
8
6
|
spec.name = 'smtp_mock'
|
@@ -33,17 +31,8 @@ Gem::Specification.new do |spec|
|
|
33
31
|
|
34
32
|
spec.add_runtime_dependency 'dry-struct', '~> 1.4'
|
35
33
|
|
36
|
-
spec.add_development_dependency 'bundler-audit', '~> 0.9.0.1'
|
37
|
-
spec.add_development_dependency 'fasterer', '~> 0.9.0'
|
38
34
|
spec.add_development_dependency 'ffaker', '~> 2.20'
|
39
|
-
spec.add_development_dependency 'net-smtp', '~> 0.3' if ::RUBY_VERSION >= '3.1.0'
|
40
|
-
spec.add_development_dependency 'overcommit', '~> 0.58.0'
|
41
|
-
spec.add_development_dependency 'pry-byebug', '~> 3.9'
|
35
|
+
spec.add_development_dependency 'net-smtp', '~> 0.3.1' if ::RUBY_VERSION >= '3.1.0'
|
42
36
|
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
|
43
|
-
spec.add_development_dependency '
|
44
|
-
spec.add_development_dependency 'rspec', '~> 3.10'
|
45
|
-
spec.add_development_dependency 'rubocop', '~> 1.24'
|
46
|
-
spec.add_development_dependency 'rubocop-performance', '~> 1.13'
|
47
|
-
spec.add_development_dependency 'rubocop-rspec', '~> 2.7'
|
48
|
-
spec.add_development_dependency 'simplecov', '~> 0.17.1'
|
37
|
+
spec.add_development_dependency 'rspec', '~> 3.11'
|
49
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smtp_mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladislav Trotsenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|
@@ -24,34 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.4'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler-audit
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.9.0.1
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.9.0.1
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: fasterer
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.9.0
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.9.0
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
28
|
name: ffaker
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,34 +38,6 @@ dependencies:
|
|
66
38
|
- - "~>"
|
67
39
|
- !ruby/object:Gem::Version
|
68
40
|
version: '2.20'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: overcommit
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 0.58.0
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 0.58.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry-byebug
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '3.9'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '3.9'
|
97
41
|
- !ruby/object:Gem::Dependency
|
98
42
|
name: rake
|
99
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,96 +58,20 @@ dependencies:
|
|
114
58
|
- - ">="
|
115
59
|
- !ruby/object:Gem::Version
|
116
60
|
version: 13.0.6
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: reek
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - "~>"
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '6.0'
|
124
|
-
- - ">="
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
version: 6.0.6
|
127
|
-
type: :development
|
128
|
-
prerelease: false
|
129
|
-
version_requirements: !ruby/object:Gem::Requirement
|
130
|
-
requirements:
|
131
|
-
- - "~>"
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '6.0'
|
134
|
-
- - ">="
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
version: 6.0.6
|
137
61
|
- !ruby/object:Gem::Dependency
|
138
62
|
name: rspec
|
139
63
|
requirement: !ruby/object:Gem::Requirement
|
140
64
|
requirements:
|
141
65
|
- - "~>"
|
142
66
|
- !ruby/object:Gem::Version
|
143
|
-
version: '3.
|
144
|
-
type: :development
|
145
|
-
prerelease: false
|
146
|
-
version_requirements: !ruby/object:Gem::Requirement
|
147
|
-
requirements:
|
148
|
-
- - "~>"
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
version: '3.10'
|
151
|
-
- !ruby/object:Gem::Dependency
|
152
|
-
name: rubocop
|
153
|
-
requirement: !ruby/object:Gem::Requirement
|
154
|
-
requirements:
|
155
|
-
- - "~>"
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '1.24'
|
158
|
-
type: :development
|
159
|
-
prerelease: false
|
160
|
-
version_requirements: !ruby/object:Gem::Requirement
|
161
|
-
requirements:
|
162
|
-
- - "~>"
|
163
|
-
- !ruby/object:Gem::Version
|
164
|
-
version: '1.24'
|
165
|
-
- !ruby/object:Gem::Dependency
|
166
|
-
name: rubocop-performance
|
167
|
-
requirement: !ruby/object:Gem::Requirement
|
168
|
-
requirements:
|
169
|
-
- - "~>"
|
170
|
-
- !ruby/object:Gem::Version
|
171
|
-
version: '1.13'
|
172
|
-
type: :development
|
173
|
-
prerelease: false
|
174
|
-
version_requirements: !ruby/object:Gem::Requirement
|
175
|
-
requirements:
|
176
|
-
- - "~>"
|
177
|
-
- !ruby/object:Gem::Version
|
178
|
-
version: '1.13'
|
179
|
-
- !ruby/object:Gem::Dependency
|
180
|
-
name: rubocop-rspec
|
181
|
-
requirement: !ruby/object:Gem::Requirement
|
182
|
-
requirements:
|
183
|
-
- - "~>"
|
184
|
-
- !ruby/object:Gem::Version
|
185
|
-
version: '2.7'
|
186
|
-
type: :development
|
187
|
-
prerelease: false
|
188
|
-
version_requirements: !ruby/object:Gem::Requirement
|
189
|
-
requirements:
|
190
|
-
- - "~>"
|
191
|
-
- !ruby/object:Gem::Version
|
192
|
-
version: '2.7'
|
193
|
-
- !ruby/object:Gem::Dependency
|
194
|
-
name: simplecov
|
195
|
-
requirement: !ruby/object:Gem::Requirement
|
196
|
-
requirements:
|
197
|
-
- - "~>"
|
198
|
-
- !ruby/object:Gem::Version
|
199
|
-
version: 0.17.1
|
67
|
+
version: '3.11'
|
200
68
|
type: :development
|
201
69
|
prerelease: false
|
202
70
|
version_requirements: !ruby/object:Gem::Requirement
|
203
71
|
requirements:
|
204
72
|
- - "~>"
|
205
73
|
- !ruby/object:Gem::Version
|
206
|
-
version:
|
74
|
+
version: '3.11'
|
207
75
|
description: "\U0001F48E Ruby SMTP mock. Mimic any SMTP server behaviour for your
|
208
76
|
test environment."
|
209
77
|
email:
|
@@ -214,8 +82,11 @@ extensions: []
|
|
214
82
|
extra_rdoc_files: []
|
215
83
|
files:
|
216
84
|
- ".circleci/config.yml"
|
85
|
+
- ".circleci/gemspec_compatible"
|
86
|
+
- ".circleci/gemspec_latest"
|
217
87
|
- ".codeclimate.yml"
|
218
88
|
- ".github/BRANCH_NAMING_CONVENTION.md"
|
89
|
+
- ".github/DEVELOPMENT_ENVIRONMENT_GUIDE.md"
|
219
90
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
220
91
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
221
92
|
- ".github/ISSUE_TEMPLATE/issue_report.md"
|
@@ -281,7 +152,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
281
152
|
- !ruby/object:Gem::Version
|
282
153
|
version: '0'
|
283
154
|
requirements: []
|
284
|
-
|
155
|
+
rubyforge_project:
|
156
|
+
rubygems_version: 2.7.3
|
285
157
|
signing_key:
|
286
158
|
specification_version: 4
|
287
159
|
summary: smtp_mock
|