21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-05-11 13:08:39 +02:00
chexpire/test/services/system_command_test.rb
2018-05-30 17:01:32 +02:00

29 lines
733 B
Ruby

require "test_helper"
require "system_command"
class SystemCommandTest < ActiveSupport::TestCase
test "should execute and log a command" do
mock_logger = Minitest::Mock.new
expected_cmd = 'whois "example.org"'
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])
command = SystemCommand.new("whois", "example.org", logger: mock_logger)
assert_equal expected_cmd, command.syscmd
command.stub(:call, expected_result) do
assert_equal expected_result, command.execute
end
mock_logger.verify
end
end