Sha256: 6afe72b455f4f5c890469051e948cd193bba9021ab7195dd1beb2a872c5426dd

Contents?: true

Size: 668 Bytes

Versions: 11

Compression:

Stored size: 668 Bytes

Contents

RSpec::Matchers.define :a_notice_with do |access_keys, expected_val|
  match do |notice|
    payload = notice[access_keys.shift]
    break(false) unless payload

    actual_val =
      if payload.respond_to?(:dig)
        payload.dig(*access_keys)
      else
        dig_pre_23(payload, *access_keys)
      end

    if expected_val.is_a?(Regexp)
      actual_val =~ expected_val
    else
      actual_val == expected_val
    end
  end

  # TODO: Use the normal "dig" version once we support Ruby 2.3 and above.
  def dig_pre_23(hash, *keys)
    v = hash[keys.shift]
    while keys.any?
      return unless v.is_a?(Hash)
      v = v[keys.shift]
    end
    v
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
airbrake-9.2.1 spec/support/matchers/a_notice_with.rb
airbrake-9.2.0 spec/support/matchers/a_notice_with.rb
airbrake-9.1.0 spec/support/matchers/a_notice_with.rb
airbrake-9.0.2 spec/support/matchers/a_notice_with.rb
airbrake-9.0.1 spec/support/matchers/a_notice_with.rb
airbrake-9.0.0 spec/support/matchers/a_notice_with.rb
airbrake-8.3.2 spec/support/matchers/a_notice_with.rb
airbrake-8.3.1 spec/support/matchers/a_notice_with.rb
airbrake-8.3.0 spec/support/matchers/a_notice_with.rb
airbrake-8.2.1 spec/support/matchers/a_notice_with.rb
airbrake-8.2.0 spec/support/matchers/a_notice_with.rb