Sha256: 2a074f51ae9a1340ea551e31c12528890ce723cd133ddac4414ac055c34bb13a

Contents?: true

Size: 545 Bytes

Versions: 30

Compression:

Stored size: 545 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
end

Version data entries

30 entries across 30 versions & 3 rubygems

Version Path
mongo_doc-0.6.16 spec/hash_matchers.rb
mongo_doc-0.6.15 spec/hash_matchers.rb
mongo_doc-0.6.14 spec/hash_matchers.rb
mongo_doc-0.6.13 spec/hash_matchers.rb
mongo_doc-0.6.12 spec/hash_matchers.rb
mongo_doc-0.6.11 spec/hash_matchers.rb
mongo_doc-0.6.10 spec/hash_matchers.rb
mongo_doc-0.6.9 spec/hash_matchers.rb
mongo_doc-0.6.8 spec/hash_matchers.rb
mongo_doc-0.6.7 spec/hash_matchers.rb
mongo_doc-0.6.6 spec/hash_matchers.rb
mongo_doc-0.6.5 spec/hash_matchers.rb
mongo_doc-0.6.4 spec/hash_matchers.rb
mongo_doc_rails2-0.6.2 spec/hash_matchers.rb
mongo_doc-0.6.3 spec/hash_matchers.rb
mongo_doc-0.6.2 spec/hash_matchers.rb
mongo_doc-0.6.1 spec/hash_matchers.rb
mongo_doc-0.6.0 spec/hash_matchers.rb
mongo_doc_rails2-0.6.1 spec/hash_matchers.rb
mongo_doc-0.5.5 spec/hash_matchers.rb