21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-05-24 19:28:48 +02:00
chexpire/test/services/system_command_test.rb

29 lines
733 B
Ruby
Raw Normal View History

2018-05-29 22:33:12 +02:00
require "test_helper"
require "system_command"
class SystemCommandTest < ActiveSupport::TestCase
test "should execute and log a command" do
mock_logger = Minitest::Mock.new
2018-05-30 13:23:15 +02:00
expected_cmd = 'whois "example.org"'
2018-05-29 22:33:12 +02:00
2018-05-30 13:23:15 +02:00
expected_result = SystemCommandResult.new(
expected_cmd,
0,
"my result",
"",
)
mock_logger.expect(:log, nil, [:before_command, expected_cmd])
mock_logger.expect(:log, nil, [:after_command, expected_result])
2018-05-29 22:33:12 +02:00
command = SystemCommand.new("whois", "example.org", logger: mock_logger)
2018-05-30 13:23:15 +02:00
assert_equal expected_cmd, command.syscmd
2018-05-29 22:33:12 +02:00
2018-05-30 13:23:15 +02:00
command.stub(:call, expected_result) do
assert_equal expected_result, command.execute
2018-05-29 22:33:12 +02:00
end
mock_logger.verify
end
end