21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-05-15 15:08:38 +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) def whois_response(domain)
file_fixture("whois/#{domain}.txt").read file_fixture("whois/#{domain}.txt").read
end end
def assert_just_now(expected)
assert_in_delta expected.to_i, Time.now.to_i, 1.0
end
end end

View file

@ -15,6 +15,7 @@ require "rails/test_help"
require "minitest/mock" require "minitest/mock"
require_relative "test_mocks_helper" require_relative "test_mocks_helper"
require_relative "chexpire_assertions"
class ActiveSupport::TestCase class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
@ -27,6 +28,7 @@ class ActiveSupport::TestCase
include ActiveJob::TestHelper include ActiveJob::TestHelper
include FactoryBot::Syntax::Methods include FactoryBot::Syntax::Methods
include TestMocksHelper include TestMocksHelper
include ChexpireAssertions
end end
# Capybara configuration # Capybara configuration

View file

@ -9,7 +9,7 @@ module TestMocksHelper
mock = Minitest::Mock.new mock = Minitest::Mock.new
mock.expect :execute, result mock.expect :execute, result
fussy = lambda { |actual_program, actual_args, _logger| assert_stub = lambda { |actual_program, actual_args, _logger|
assert_equal program, actual_program, assert_equal program, actual_program,
"SystemCommand was not initialized with the expected program name" "SystemCommand was not initialized with the expected program name"
@ -19,7 +19,7 @@ module TestMocksHelper
mock mock
} }
SystemCommand.stub :new, fussy do SystemCommand.stub :new, assert_stub do
yield yield
end end