summaryrefslogtreecommitdiff
path: root/spec/presenters/sentry_error_presenter_spec.rb
blob: af9e7c8a2b2dab9d1da65c542b16827ae3ea9964 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe SentryErrorPresenter do
  let(:error) { build(:detailed_error_tracking_error) }
  let(:presenter) { described_class.new(error) }

  describe '#frequency' do
    subject { presenter.frequency }

    it 'returns an array of frequency structs' do
      expect(subject).to include(a_kind_of(SentryErrorPresenter::FrequencyStruct))
    end

    it 'converts the times into UTC time objects' do
      time = subject.first.time

      expect(time).to be_a(Time)
      expect(time.strftime('%z')).to eq '+0000'
    end

    it 'returns the correct counts' do
      count = subject.first.count

      expect(count).to eq error.frequency.first[1]
    end
  end
end