Sha256: f8bdc9927916923e43cf5de38dacf7d8acf44852a2d179a8817f4dda0bd864e9

Contents?: true

Size: 1.92 KB

Versions: 3

Compression:

Stored size: 1.92 KB

Contents

require 'spec_helper'
require 'rollbar/truncation/frames_strategy'

describe Rollbar::Truncation::FramesStrategy do
  def expand_frames(frames)
    frames * (1 + 300 / frames.count)
  end

  describe '.call', :fixture => :payload do
    context 'with trace key' do
      let(:payload_fixture) { 'payloads/sample.trace.json' }
      let(:frames) { payload['data']['body']['trace']['frames'].clone }

      before do
        payload['data']['body']['trace']['frames'] = expand_frames(frames)
      end

      it 'returns a new payload with 300 frames' do
        result = MultiJson.load(described_class.call(payload))

        new_frames = result['data']['body']['trace']['frames']

        expect(new_frames.count).to be_eql(300)
        expect(new_frames.first).to be_eql(frames.first)
        expect(new_frames.last).to be_eql(frames.last)
      end
    end

    context 'with trace_chain key' do
      let(:payload_fixture) { 'payloads/sample.trace_chain.json' }

      let(:frames1) { payload['data']['body']['trace_chain'][0]['frames'].clone }
      let(:frames2) { payload['data']['body']['trace_chain'][1]['frames'].clone }

      before do
        payload['data']['body']['trace_chain'][0]['frames'] = expand_frames(frames1)
        payload['data']['body']['trace_chain'][1]['frames'] = expand_frames(frames2)
      end

      it 'returns a new payload with 300 frames for each chain item' do
        result = MultiJson.load(described_class.call(payload))

        new_frames1 = result['data']['body']['trace_chain'][0]['frames']
        new_frames2 = result['data']['body']['trace_chain'][1]['frames']

        expect(new_frames1.count).to be_eql(300)
        expect(new_frames1.first).to be_eql(frames1.first)
        expect(new_frames1.last).to be_eql(frames1.last)

        expect(new_frames2.count).to be_eql(300)
        expect(new_frames2.first).to be_eql(frames2.first)
        expect(new_frames2.last).to be_eql(frames2.last)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rollbar-1.3.0 spec/rollbar/truncation/frames_strategy_spec.rb
rollbar-1.2.13 spec/rollbar/truncation/frames_strategy_spec.rb
rollbar-1.2.12 spec/rollbar/truncation/frames_strategy_spec.rb