Sha256: 6875fd6782aea1c1d03b4306bcc626bd6ed781e2e8264683b46b985404b75751

Contents?: true

Size: 947 Bytes

Versions: 1

Compression:

Stored size: 947 Bytes

Contents

require "spec_helper"

describe WildcardMatchers::Matchers::HashIncludes do
  [ [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b ],
    [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b => 1 ],
    [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b => Integer ],
  ].each do |actual, matcher, *args|
    it_behaves_like "wildcard match", actual, matcher, *args
  end

  [ [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :d ],
    [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b => 2 ],
    [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b => String ],
    [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b => String, :d => nil ],
  ].each do |actual, matcher, *args|
    it_behaves_like "not wildcard match", actual, matcher, *args
  end

  # bug
  it "cannot be corrupted" do
    matcher = hash_includes(a: 1)
    2.times { expect(wildcard_match?({ a: 2 }, matcher, &debugger)).to be false }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wildcard_matchers-0.9.2 spec/wildcard_matchers/matchers/hash_includes_spec.rb