lib/cli/kit/support/test_helper.rb in cli-kit-3.3.0 vs lib/cli/kit/support/test_helper.rb in cli-kit-4.0.0
- old
+ new
@@ -8,11 +8,11 @@
end
def assert_all_commands_run(should_raise: true)
errors = CLI::Kit::System.error_message
CLI::Kit::System.reset!
- assert false, errors if should_raise && !errors.nil?
+ assert(false, errors) if should_raise && !errors.nil?
errors
end
def teardown
super
@@ -132,12 +132,12 @@
# `sudo` : expectation of sudo being set or not (defaults to false)
# `env` : expectation of env being set or not (defaults to {})
#
# Note: Must set allow or success
#
- def fake(*a, stdout: "", stderr: "", allow: nil, success: nil, sudo: false, env: {})
- raise ArgumentError, "success or allow must be set" if success.nil? && allow.nil?
+ def fake(*a, stdout: '', stderr: '', allow: nil, success: nil, sudo: false, env: {})
+ raise ArgumentError, 'success or allow must be set' if success.nil? && allow.nil?
@delegate_open3 ||= {}
@delegate_open3[a.join(' ')] = {
expected: {
sudo: sudo,
@@ -194,25 +194,25 @@
final_error = []
unless errors[:unexpected].empty?
final_error << CLI::UI.fmt(<<~EOF)
- {{bold:Unexpected command invocations:}}
- {{command:#{errors[:unexpected].join("\n")}}}
+ {{bold:Unexpected command invocations:}}
+ {{command:#{errors[:unexpected].join("\n")}}}
EOF
end
unless errors[:not_run].empty?
final_error << CLI::UI.fmt(<<~EOF)
- {{bold:Expected commands were not run:}}
- {{command:#{errors[:not_run].join("\n")}}}
+ {{bold:Expected commands were not run:}}
+ {{command:#{errors[:not_run].join("\n")}}}
EOF
end
unless errors[:other].empty?
final_error << CLI::UI.fmt(<<~EOF)
- {{bold:Commands were not run as expected:}}
- #{errors[:other].map { |cmd, msg| "{{command:#{cmd}}}\n#{msg}" }.join("\n\n")}
+ {{bold:Commands were not run as expected:}}
+ #{errors[:other].map { |cmd, msg| "{{command:#{cmd}}}\n#{msg}" }.join("\n\n")}
EOF
end
return nil if final_error.empty?
"\n" + final_error.join("\n") # Initial new line for formatting reasons