Sha256: cba83b2d84c8f9cb379d605af3a58cdda2b21a9ebebccb24a1cfca152e3c7daa

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 KB

Contents

require "spec_helper"

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

  [ [ 1, ->(e) { e == 1 } ],
  ].each do |actual, expected|
    it "match #{actual.inspect} with #{expected} block" do
      expect(actual).to wildcard_match(&expected)
    end
  end

  [ [ "1", :is_a_string ],
  ].each do |actual, expected|
    it "match #{actual.inspect} with #{expected}" do
      expect(actual).to 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
        expect(actual).to wildcard_match(expected)
        fail # if matched come here and must fail
      rescue RSpec::Expectations::ExpectationNotMetError => e
        expect(e.message).to include(failure_message)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wildcard_matchers-0.9.2 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.9.1 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.9.0 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.4.0 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.3.1 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.3.0 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.2.1 spec/wildcard_matchers/rspec_spec.rb
wildcard_matchers-0.2.0 spec/wildcard_matchers/rspec_spec.rb