21
1
Fork 0
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:
Colin Darie 2018-06-04 14:03:08 +02:00
parent e6283fac6c
commit 20ad6953e5
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
4 changed files with 9 additions and 6 deletions

View 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

View file

@ -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

View file

@ -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

View file

@ -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