Sha256: 848594871b9f8a89b1e278412c2eff25d2ef3cf44cc547b731ced5e4c9847092

Contents?: true

Size: 609 Bytes

Versions: 9

Compression:

Stored size: 609 Bytes

Contents

class HasEntry
  def initialize(expected)
    @expected = expected
  end

  def matches?(target)
    @target = target
    @expected.all? do |key, value|
      @target[key] == value
    end
  end

  def failure_message_for_should
    "expected #{@target.inspect} to have entries #{@expected.inspect}"
  end

  def failure_message_for_should_not
    "expected #{@target.inspect} not to have entries #{@expected.inspect}"
  end
end

module HashMatchers
  def has_entry(expected)
    HasEntry.new(expected)
  end
  alias :has_entries :has_entry
  alias :have_entries :has_entry
  alias :have_entry :has_entry
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mongo_doc-0.6.26 spec/hash_matchers.rb
mongo_doc-0.6.25 spec/hash_matchers.rb
mongo_doc-0.6.23 spec/hash_matchers.rb
mongo_doc-0.6.22 spec/hash_matchers.rb
mongo_doc-0.6.21 spec/hash_matchers.rb
mongo_doc-0.6.20 spec/hash_matchers.rb
mongo_doc-0.6.19 spec/hash_matchers.rb
mongo_doc-0.6.18 spec/hash_matchers.rb
mongo_doc-0.6.17 spec/hash_matchers.rb