Sha256: 6266a74c977bcc69c4a293ed2419383acda994d4f102cb574b71047d92fc2957

Contents?: true

Size: 876 Bytes

Versions: 3

Compression:

Stored size: 876 Bytes

Contents

# frozen_string_literal: true

# RSpec::Matchers.define :be_a_multiple_of do |expected|
#   match do |actual|
#     actual % expected == 0
#   end
# end
# 9.should be_a_multiple_of(3)
# expect(9).to be_a_multiple_of(3)

RSpec::Matchers.define(:have_message) do |message|
  match do |actual|
    actual.check
    actual.message.include?(message)
  end

  failure_message do |actual|
    "expected '#{actual.message}' to include '#{message}'"
  end

  failure_message_when_negated do |actual|
    "expected '#{actual.message}' to not include '#{message}'"
  end
end

RSpec::Matchers.define(:be_successful_check) do |_message|
  match do |actual|
    actual.check
    actual.success?
  end

  failure_message do |actual|
    "expected #{actual.inspect} to be successful"
  end

  failure_message_when_negated do |actual|
    "expected '#{actual}' to not be successful"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
okcomputer-checks-1.1.1 spec/support/check_matcher.rb
okcomputer-checks-1.1.0 spec/support/check_matcher.rb
okcomputer-checks-1.0.0 spec/support/check_matcher.rb