Sha256: 65e884ce008169d638916ce99e8233c7e520dfa71c0858def6c28370bd123e28

Contents?: true

Size: 786 Bytes

Versions: 8

Compression:

Stored size: 786 Bytes

Contents

require "rspec"
require "wildcard_matchers"

RSpec.configure do |c|
  c.include WildcardMatchers
end

RSpec::Matchers.define :wildcard_match do |expected|
  match do |actual|
    @matcher = WildcardMatchers::WildcardMatcher.new(expected)
    @matcher === actual
  end

  # RSpec now prefers `failure_message` instead of `failure_message_for_should`.
  if respond_to? :failure_message
    failure_message do |actual| # RSpec 3.x
      @matcher.errors.join("\n")
    end
  else
    failure_message_for_should do |actual| # RSpec 1.2, 2.x
      @matcher.errors.join("\n")
    end
  end
end

module RSpec::Matchers
  alias wildcard_match_without_block wildcard_match
  def wildcard_match(expected = nil, &block)
    wildcard_match_without_block((block_given? ? block : expected))
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wildcard_matchers-0.9.2 lib/wildcard_matchers/rspec.rb
wildcard_matchers-0.9.1 lib/wildcard_matchers/rspec.rb
wildcard_matchers-0.9.0 lib/wildcard_matchers/rspec.rb
wildcard_matchers-0.4.0 lib/wildcard_matchers/rspec.rb
wildcard_matchers-0.3.1 lib/wildcard_matchers/rspec.rb
wildcard_matchers-0.3.0 lib/wildcard_matchers/rspec.rb
wildcard_matchers-0.2.1 lib/wildcard_matchers/rspec.rb
wildcard_matchers-0.2.0 lib/wildcard_matchers/rspec.rb