Sha256: 1ee3fa9bd286bda6ac8a92b7d09270f76913474fed9d182dcb12bf785641fb33

Contents?: true

Size: 1.55 KB

Versions: 5

Compression:

Stored size: 1.55 KB

Contents

# :nocov:
require 'minitest/assertions'
# rubocop:disable Metrics/MethodLength
module Minitest::Assertions
  def assert_ok(result, status: nil, message: nil, value: nil)
    assert result.ok?, 'Expected command to succeed.'

    unless status.nil?
      assert_equal(
        status,
        result.status,
        "Expected command to succeed with status: :#{status}, got: :#{result.status}"
      )
    end

    unless message.nil?
      assert_equal(
        message,
        result.message,
        "Expected command to succeed with message: #{message}, got: #{result.message}"
      )
    end

    unless value.nil?
      assert_equal(
        value,
        result.value,
        "Expected command to succeed with value: #{value}, got: #{result.value}"
      )
    end
  end
  alias refute_err assert_ok

  def refute_ok(result, status: nil, message: nil, value: nil)
    refute result.ok?, 'Expected command to fail.'

    unless status.nil?
      refute_equal(
        status,
        result.status,
        "Expected command to fail with status: :#{status}, got: :#{result.status}"
      )
    end

    unless message.nil?
      refute_equal(
        message,
        result.message,
        "Expected command to fail with message: #{message}, got: #{result.message}"
      )
    end

    unless value.nil?
      refute_equal(
        value,
        result.value,
        "Expected command to fail with value: #{value}, got: #{result.value}"
      )
    end
  end
  alias assert_err refute_ok
end
# rubocop:enable Style/Documentation
# rubocop:enable Metrics/MethodLength
# :nocov:

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slayer-0.5.4 lib/slayer/minitest.rb
slayer-0.5.3 lib/slayer/minitest.rb
slayer-0.5.2 lib/slayer/minitest.rb
slayer-0.5.1 lib/slayer/minitest.rb
slayer-0.5.0.beta lib/slayer/minitest.rb