Sha256: f854e6b9e56705a1cca240dcbcef6c82e0eb0f398f0e5c4be543b9cf0703fa43

Contents?: true

Size: 910 Bytes

Versions: 2

Compression:

Stored size: 910 Bytes

Contents

require "spec_helper"

describe "matcher wildcard_match" do
  [ [ 1, Integer ]
  ].each do |actual, expected|
    it "match #{actual} with #{expected}" do
      actual.should wildcard_match(expected)
    end
  end

  [ [ 1,           String,     ".: expect 1 to String" ],
    [ [ 1 ],       [ String ], ".[0]: expect 1 to String" ],
    [ [ 1 ],       [],         ".: expect Array size 1 to 0" ],
    [ { :a => 1 }, {},         "+keys: [:a]" ],
    [ {},          {:a => 1},  "-keys: [:a]" ],
    [ { :a => 1},  {:a => 0},  ".[:a]: expect 1 to 0" ],
  ].each do |actual, expected, failure_message|
    it "not match #{actual} with #{expected} and return #{failure_message.inspect} as failure_message" do
      begin
        actual.should wildcard_match(expected)
        fail # if matched come here and must fail
      rescue => e
        e.message.should include(failure_message)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wildcard_matchers-0.0.2 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.0.1 spec/wildcard_matchers/rspec_spec.rb