Sha256: b68d7fb2e510fa06b66409049d9f1f72c1be31c00b1c3300f0b82d46cd99c641

Contents?: true

Size: 584 Bytes

Versions: 8

Compression:

Stored size: 584 Bytes

Contents

require "rspec/expectations"

RSpec::Matchers.define :have_matched do |expected_root|
  match do |actual|
    actual.matches? && (expected_root.nil? || actual.root == expected_root)
  end

  failure_message do |actual|
    if actual.matches?
      "expected a match against '#{expected_root.inspect}', " \
      "but got a match against '#{actual.root.inspect}'"
    else
      "expected a match, but got none"
    end
  end

  failure_message_when_negated do |actual|
    if actual.matches?
      "expected no match, but got a match against #{actual.root.inspect}"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
metamorpher-0.2.6 spec/support/matchers/have_matched_matcher.rb
metamorpher-0.2.5 spec/support/matchers/have_matched_matcher.rb
metamorpher-0.2.4 spec/support/matchers/have_matched_matcher.rb
metamorpher-0.2.3 spec/support/matchers/have_matched_matcher.rb
metamorpher-0.2.2 spec/support/matchers/have_matched_matcher.rb
metamorpher-0.2.1 spec/support/matchers/have_matched_matcher.rb
metamorpher-0.2.0 spec/support/matchers/have_matched_matcher.rb
metamorpher-0.1.1 spec/support/matchers/have_matched_matcher.rb