Sha256: 07355b47807497f98b7714b4115f37fd6c633d85b2a27f4c7ae52a4e0b022137

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

require "spec_helper"

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

  [ [ "1", :is_a_string ],
  ].each do |actual, expected|
    it "match #{actual.inspect} with #{expected}" do
      actual.should wildcard_match(send(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.inspect} 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

8 entries across 8 versions & 1 rubygems

Version Path
wildcard_matchers-0.1.7 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.1.6 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.1.5 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.1.4 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.1.3 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.1.2 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.1.1 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.1.0 spec/wildcard_matchers/rspec_spec.rb