Sha256: f06295d82eee332a2733c5f1ba642f8113d029024f025d0978fad035234b5a53

Contents?: true

Size: 909 Bytes

Versions: 2

Compression:

Stored size: 909 Bytes

Contents

require 'spec_helper'

describe Honeybadger::Payload do
  its(:max_depth) { should eq 20 }

  context "when max_depth option is passed to #initialize" do
    subject { described_class.new({}, :max_depth => 5) }
    its(:max_depth) { should eq 5 }

    context "when initialized with a bad object" do
      it "raises ArgumentError" do
        expect { described_class.new([], :max_depth => 5) }.to raise_error(ArgumentError)
      end
    end
  end

  describe "#sanitize" do
    let(:deep_hash) { {}.tap {|h| 30.times.each {|i| h = h[i.to_s] = {:string => 'string'} }} }
    let(:expected_hash) { {}.tap {|h| max_depth.times.each {|i| h = h[i.to_s] = {:string => 'string'} }} }
    let(:sanitized_hash) { described_class.new(deep_hash, :max_depth => max_depth) }
    let(:max_depth) { 10 }

    it "truncates nested hashes to max_depth" do
      expect(sanitized_hash).to eq(expected_hash)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
honeybadger-1.12.0.beta3 spec/honeybadger/payload_spec.rb
honeybadger-1.12.0.beta2 spec/honeybadger/payload_spec.rb