Sha256: bb6f6a0d11165e1cee9565498dbb5fd50170ecf363010f6c0809bd0480c45093

Contents?: true

Size: 695 Bytes

Versions: 1

Compression:

Stored size: 695 Bytes

Contents

RSpec::Matchers.define :have_key do |expected|
  match do |actual|
    result = actual.key? expected
    result = actual[expected] == value if value
    result
  end

  chain :with_value, :value

  description do
    result = "have a key named '#{expected}'"
    result << " with value '#{value}'" if value
    result
  end

  failure_message do |actual|
    result = "expected that #{actual} would have a key named #{expected}"
    result << " with a value of '#{value}'" if value
    result
  end

  failure_message_when_negated do |actual|
    result = "expected that #{actual} would not have a key named #{expected}"
    result << " with a value of '#{value}'" if value
    result
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-cloud-core-0.1.0 lib/rspec/cloud/core/matchers/have_key.rb