clarify namespaces and require

This commit is contained in:
Jérémy Lecour 2019-03-03 22:47:05 +01:00
parent e9693a23a5
commit eaf58c0b0e
8 changed files with 21 additions and 24 deletions

View File

@ -10,8 +10,8 @@
module SSL
class Error < StandardError; end
class SSLCommandError < Error; end
class SSLConfigurationError < Error; end
class CommandError < Error; end
class ConfigurationError < Error; end
class ParserError < Error; end
class DomainNotMatchError < ParserError; end
@ -51,7 +51,7 @@ module SSL
result = command.execute
unless result.exit_status.zero?
fail SSLCommandError, "SSL command failed with status #{result.exit_status}"
fail SSL::CommandError, "SSL command failed with status #{result.exit_status}"
end
result
@ -79,7 +79,7 @@ module SSL
def custom_check_http_args
return nil unless configuration.check_http_args.present?
fail SSLConfigurationError, "check_http_args option must be an array of argument." \
fail SSL::ConfigurationError, "check_http_args option must be an array of argument." \
unless configuration.check_http_args.is_a?(Array)
configuration.check_http_args

View File

@ -11,7 +11,7 @@
module Whois
class Error < StandardError; end
class WhoisCommandError < Error; end
class CommandError < Error; end
class UnsupportedDomainError < Error; end
class DomainNotFoundError < Error; end
class ParserError < Error; end
@ -49,7 +49,7 @@ module Whois
result = command.execute
unless result.exit_status.zero?
fail WhoisCommandError, "Whois command failed with status #{result.exit_status}"
fail Whois::CommandError, "Whois command failed with status #{result.exit_status}"
end
result

View File

@ -3,7 +3,3 @@ require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!
# binding.pry
# Rails.autoloaders.main
# loader.push_dir(Rails.root.join("app/services"))

View File

@ -2,6 +2,7 @@
# License: GNU AGPL-3+ (see full text in LICENSE file)
require "test_helper"
# require "notifier/resolver"
# rubocop:disable Metrics/LineLength
module Notifier

View File

@ -11,7 +11,7 @@ module SSL
result = OpenStruct.new(exit_status: 0)
mock_system_klass("check_http", standard_args, result) do |system_klass|
service = Service.new("example.org", system_klass: system_klass)
service = SSL::Service.new("example.org", system_klass: system_klass)
assert_equal result, service.run_command
end
end
@ -20,9 +20,9 @@ module SSL
result = OpenStruct.new(exit_status: 1)
mock_system_klass("check_http", standard_args, result) do |system_klass|
service = Service.new("example.org", system_klass: system_klass)
service = SSL::Service.new("example.org", system_klass: system_klass)
assert_raises SSLCommandError do
assert_raises SSL::CommandError do
service.run_command
end
end
@ -34,7 +34,7 @@ module SSL
stdout: file_fixture("ssl/ssl0.domain.org.txt").read,
)
service = Service.new("ssl0.domain.org")
service = SSL::Service.new("ssl0.domain.org")
assert_kind_of SSL::Response, service.parse(result)
end
@ -44,7 +44,7 @@ module SSL
expected_args = standard_args.concat ["-f", "-I 127.0.0.1"]
mock_system_klass("check_http", expected_args, result) do |system_klass|
service = Service.new("example.org", configuration: config, system_klass: system_klass)
service = SSL::Service.new("example.org", configuration: config, system_klass: system_klass)
assert_equal result, service.run_command
end
end
@ -53,8 +53,8 @@ module SSL
black_hole = Naught.build(&:black_hole)
config = OpenStruct.new(check_http_args: "-f")
assert_raises SSLConfigurationError do
service = Service.new("example.org", configuration: config, system_klass: black_hole)
assert_raises SSL::ConfigurationError do
service = SSL::Service.new("example.org", configuration: config, system_klass: black_hole)
service.run_command
end
end
@ -64,7 +64,7 @@ module SSL
config = OpenStruct.new(check_http_path: "/usr/local/custom/path")
mock_system_klass("/usr/local/custom/path", standard_args, result) do |sys|
service = Service.new("example.org", configuration: config, system_klass: sys)
service = SSL::Service.new("example.org", configuration: config, system_klass: sys)
assert_equal result, service.run_command
end
end

View File

@ -11,7 +11,7 @@ module Whois
result = OpenStruct.new(exit_status: 0)
mock_system_klass("whois", "example.org", result) do |system_klass|
service = Service.new("example.org", system_klass: system_klass)
service = Whois::Service.new("example.org", system_klass: system_klass)
assert_equal result, service.run_command
end
end
@ -20,9 +20,9 @@ module Whois
result = OpenStruct.new(exit_status: 1)
mock_system_klass("whois", "example.org", result) do |system_klass|
service = Service.new("example.org", system_klass: system_klass)
service = Whois::Service.new("example.org", system_klass: system_klass)
assert_raises WhoisCommandError do
assert_raises Whois::CommandError do
service.run_command
end
end
@ -34,7 +34,7 @@ module Whois
stdout: file_fixture("whois/domain.fr.txt").read,
)
service = Service.new("domain.fr")
service = Whois::Service.new("domain.fr")
assert_kind_of Whois::Response, service.parse(result)
end

View File

@ -1,7 +1,7 @@
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Jeremy Lecour <jlecour@evolix.fr>, 2018 Evolix <info@evolix.fr>
# License: GNU AGPL-3+ (see full text in LICENSE file)
# require "application_system_test_case"
require "application_system_test_case"
class ChecksTest < ApplicationSystemTestCase
setup do

View File

@ -1,7 +1,7 @@
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
# License: GNU AGPL-3+ (see full text in LICENSE file)
# require "application_system_test_case"
require "application_system_test_case"
class UsersTest < ApplicationSystemTestCase
setup do