-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Technical/Update gem development dependencies (#77)
* Updated gem development dependencies * Updated reek config * Changed namespace for rspec helpers
- Loading branch information
Showing
17 changed files
with
148 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
spec/support/helpers/client_helper_spec.rb → ...k/rspec_helper/client/smtp_client_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../helpers/context_generator_helper_spec.rb → ...ck/rspec_helper/context_generator_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...support/helpers/dependency_helper_spec.rb → ...smtp_mock/rspec_helper/dependency_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
spec/support/helpers/server_helper_spec.rb → spec/smtp_mock/rspec_helper/server_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
module SmtpMock | ||
module RspecHelper | ||
module Client | ||
class SmtpClient | ||
require 'net/smtp' | ||
|
||
UNDEFINED_VERSION = '0.0.0' | ||
|
||
Error = ::Class.new(::StandardError) | ||
|
||
def initialize(host, port, net_class = ::Net::SMTP) | ||
@net_class = net_class | ||
@net_smtp_version = resolve_net_smtp_version | ||
@net_smtp = old_net_smtp? ? net_class.new(host, port) : net_class.new(host, port, tls_verify: false) | ||
end | ||
|
||
def start(helo_domain, &block) | ||
return net_smtp.start(helo_domain, &block) if net_smtp_version < '0.2.0' | ||
return net_smtp.start(helo_domain, tls_verify: false, &block) if old_net_smtp? | ||
net_smtp.start(helo: helo_domain, &block) | ||
end | ||
|
||
private | ||
|
||
attr_reader :net_class, :net_smtp_version, :net_smtp | ||
|
||
def resolve_net_smtp_version | ||
return net_class::VERSION if net_class.const_defined?(:VERSION) | ||
SmtpMock::RspecHelper::Client::SmtpClient::UNDEFINED_VERSION | ||
end | ||
|
||
def old_net_smtp? | ||
net_smtp_version < '0.3.0' | ||
end | ||
end | ||
|
||
def smtp_request(host:, port:, mailfrom:, rcptto:, message:, helo_domain: nil) # rubocop:disable Metrics/ParameterLists | ||
SmtpMock::RspecHelper::Client::SmtpClient.new(host, port).start(helo_domain) do |session| | ||
session.send_message(message, mailfrom, rcptto) | ||
rescue ::Net::SMTPFatalError => error | ||
raise SmtpMock::RspecHelper::Client::SmtpClient::Error, error.message.strip | ||
end | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# frozen_string_literal: true | ||
|
||
module SmtpMock | ||
module RspecHelper | ||
module ContextGenerator | ||
def random_ip_v4_address | ||
ffaker.ip_v4_address | ||
end | ||
|
||
def random_hostname | ||
ffaker.domain_name | ||
end | ||
|
||
def random_email | ||
ffaker.email | ||
end | ||
|
||
def random_pid | ||
random.rand(1_000..2_000) | ||
end | ||
|
||
def random_port_number | ||
random.rand(49_152..65_535) | ||
end | ||
|
||
def random_signal | ||
random.rand(1..39) | ||
end | ||
|
||
def random_message | ||
FFaker::Lorem.sentence | ||
end | ||
|
||
def random_sem_version | ||
::Array.new(3) { rand(0..42) }.join('.') | ||
end | ||
|
||
private | ||
|
||
def ffaker | ||
FFaker::Internet | ||
end | ||
|
||
def random | ||
::Random | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module SmtpMock | ||
module RspecHelper | ||
module Dependency | ||
def compose_command(command_line_args) | ||
SmtpMock::Dependency.compose_command(command_line_args) | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module SmtpMock | ||
module RspecHelper | ||
module Server | ||
def create_fake_servers(active: 1, inactive: 1) | ||
server = ::Struct.new(:active?, :stop!) | ||
active_servers = ::Array.new(active) { server.new(true, true) } | ||
inactive_servers = ::Array.new(inactive) { server.new } | ||
(active_servers + inactive_servers).shuffle | ||
end | ||
|
||
def reset_err_log | ||
SmtpMock::Server::Process.instance_variable_set(:@err_log, nil) | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.