mirror of
https://github.com/Evolix/chexpire.git
synced 2024-04-29 07:20:50 +02:00
Test: custom assertion assert_just_now
This commit is contained in:
parent
e6283fac6c
commit
20ad6953e5
5
test/chexpire_assertions.rb
Normal file
5
test/chexpire_assertions.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
module ChexpireAssertions
|
||||
def assert_just_now(expected)
|
||||
assert_in_delta expected.to_i, Time.now.to_i, 1.0
|
||||
end
|
||||
end
|
|
@ -55,8 +55,4 @@ class WhoisSyncJobTest < ActiveJob::TestCase
|
|||
def whois_response(domain)
|
||||
file_fixture("whois/#{domain}.txt").read
|
||||
end
|
||||
|
||||
def assert_just_now(expected)
|
||||
assert_in_delta expected.to_i, Time.now.to_i, 1.0
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,7 @@ require "rails/test_help"
|
|||
|
||||
require "minitest/mock"
|
||||
require_relative "test_mocks_helper"
|
||||
require_relative "chexpire_assertions"
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
||||
|
@ -27,6 +28,7 @@ class ActiveSupport::TestCase
|
|||
include ActiveJob::TestHelper
|
||||
include FactoryBot::Syntax::Methods
|
||||
include TestMocksHelper
|
||||
include ChexpireAssertions
|
||||
end
|
||||
|
||||
# Capybara configuration
|
||||
|
|
|
@ -9,7 +9,7 @@ module TestMocksHelper
|
|||
mock = Minitest::Mock.new
|
||||
mock.expect :execute, result
|
||||
|
||||
fussy = lambda { |actual_program, actual_args, _logger|
|
||||
assert_stub = lambda { |actual_program, actual_args, _logger|
|
||||
assert_equal program, actual_program,
|
||||
"SystemCommand was not initialized with the expected program name"
|
||||
|
||||
|
@ -19,7 +19,7 @@ module TestMocksHelper
|
|||
mock
|
||||
}
|
||||
|
||||
SystemCommand.stub :new, fussy do
|
||||
SystemCommand.stub :new, assert_stub do
|
||||
yield
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue