Sha256: ffa34fc22dcb958304e8235b25b054f6810054842dbe594284453a724100a164

Contents?: true

Size: 951 Bytes

Versions: 2

Compression:

Stored size: 951 Bytes

Contents

shared_examples_for "wildcard match" do |actual, matcher, *args|
  expected = matcher.inspect + (args.size > 0 ? "(#{args.map(&:inspect).join(", ")})" : "")

  it "#{actual.inspect} with #{expected}" do
    if matcher.is_a?(Symbol) and WildcardMatchers.respond_to?(matcher)
      # Note: some symbol comes here and may fail
      wildcard_match?(actual, send(matcher, *args)).should be_true
    else
      wildcard_match?(actual, matcher).should be_true
    end
  end
end

shared_examples_for "not wildcard match" do |actual, matcher, *args|
  expected = matcher.inspect + (args.size > 0 ? "(#{args.map(&:inspect).join(", ")})" : "")

  it "#{actual.inspect} with #{expected}" do
    if matcher.is_a?(Symbol) and WildcardMatchers.respond_to?(matcher)
      # Note: some symbol comes here and may fail
      wildcard_match?(actual, send(matcher, *args)).should be_false
    else
      wildcard_match?(actual, matcher).should be_false
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wildcard_matchers-0.0.2 spec/support/shared_examples.rb
wildcard_matchers-0.0.1 spec/support/shared_examples.rb