Sha256: 96f48828663a1c2b61237407b718beedaf8e0d1d278ec46753db4b908d305a85

Contents?: true

Size: 1.34 KB

Versions: 14

Compression:

Stored size: 1.34 KB

Contents

require "spec_helper"

describe WildcardMatchers::Matchers do
  [ [ "string",            String ],
    [ 0,                   Integer ],
    [ 0.1,                 Float ],
    [ 0,                   Numeric ],  # superclass
    [ { :some => :hash },  Hash  ],
    [ [ 1, 2, 3 ],         Array ],
  ].each do |actual, expected|
    it_behaves_like "wildcard match", actual, :is_a, expected
  end

  [ [ "string",           :is_a_string ],
    [ 0,                  :is_a_integer ],
    [ 0.1,                :is_a_float ],
    [ { :some => :hash }, :is_a_hash ],
    [ [ 1, 2, 3 ],        :is_a_array ],

    # is_bool
    [ true,  :is_bool ],
    [ false, :is_bool ],

    # is_time
    [ Time.now,      :is_time ],
    [ Time.now.to_s, :is_time ],
    [ "2012-05-10",  :is_time ],

  ].each do |actual, matcher|
    it_behaves_like "wildcard match", actual, matcher
  end

  [ [ 0, :is_bool ],
  ].each do |actual, matcher|
    it_behaves_like "not wildcard match", actual, matcher
  end

  [ [ "a", :is_a_member_of, %w[ a b ] ],
    [ "a", :is_a_member_of, [ String ] ],
  ].each do |actual, matcher, *args|
    it_behaves_like "wildcard match", actual, matcher, *args
  end

  [ [ "a", :is_a_member_of, %w[ b c ] ],
    [ "a", :is_a_member_of, [ Integer ] ],
  ].each do |actual, matcher, *args|
    it_behaves_like "not wildcard match", actual, matcher, *args
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
wildcard_matchers-0.4.0 spec/wildcard_matchers/matchers_spec.rb
wildcard_matchers-0.3.1 spec/wildcard_matchers/matchers_spec.rb
wildcard_matchers-0.3.0 spec/wildcard_matchers/matchers_spec.rb
wildcard_matchers-0.2.1 spec/wildcard_matchers/matchers_spec.rb
wildcard_matchers-0.2.0 spec/wildcard_matchers/matchers_spec.rb
wildcard_matchers-0.1.8 spec/wildcard_matchers/matchers_spec.rb
wildcard_matchers-0.1.7 spec/wildcard_matchers/matchers_spec.rb
wildcard_matchers-0.1.6 spec/wildcard_matchers/matchers_spec.rb
wildcard_matchers-0.1.5 spec/wildcard_matchers/matchers_spec.rb
wildcard_matchers-0.1.4 spec/wildcard_matchers/matchers_spec.rb
wildcard_matchers-0.1.3 spec/wildcard_matchers/matchers_spec.rb
wildcard_matchers-0.1.2 spec/wildcard_matchers/matchers_spec.rb
wildcard_matchers-0.1.1 spec/wildcard_matchers/matchers_spec.rb
wildcard_matchers-0.1.0 spec/wildcard_matchers/matchers_spec.rb