Sha256: 32d5e093556caf10701869850615d566cebb5c91bb5ee9587734a85968eb714c

Contents?: true

Size: 912 Bytes

Versions: 3

Compression:

Stored size: 912 Bytes

Contents

require_relative '../spec_helper'

module Barometer::Utils
  describe Payload do
    describe '#fetch' do
      it 'returns the value for the key provided' do
        hash = {one: 1}
        parser = Payload.new(hash)
        expect( parser.fetch(:one) ).to eq 1
      end

      it 'traverses multiple levels to get the value' do
        hash = {one: {two: {three: 3}}}
        parser = Payload.new(hash)
        expect( parser.fetch(:one, :two, :three) ).to eq 3
      end
    end

    describe '#units' do
      it 'returns the query units when the query is present' do
        units = double(:units)
        query = double(:query, units: units)

        payload = Payload.new({}, query)

        expect( payload.units ).to eq units
      end

      it 'returns nil when the query is not present' do
        payload = Payload.new({}, nil)
        expect( payload.units ).to be_nil
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
barometer-0.9.7 spec/utils/payload_spec.rb
barometer-0.9.6 spec/utils/payload_spec.rb
barometer-0.9.5 spec/utils/payload_spec.rb