debian-mirror-gitlab/spec/lib/peek/views/bullet_detailed_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.5 KiB
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Peek::Views::BulletDetailed do
2020-06-23 00:09:42 +05:30
subject { described_class.new }
before do
allow(Bullet).to receive(:enable?).and_return(bullet_enabled)
end
context 'bullet disabled' do
let(:bullet_enabled) { false }
it 'returns empty results' do
expect(subject.results).to eq({})
end
end
context 'bullet enabled' do
let(:bullet_enabled) { true }
before do
allow(Bullet).to receive_message_chain(:notification_collector, :collection).and_return(notifications)
end
context 'where there are no notifications' do
let(:notifications) { [] }
it 'returns empty results' do
expect(subject.results).to eq({})
end
end
context 'when notifications exist' do
let(:notifications) do
[
double(title: 'Title 1', body: 'Body 1', body_with_caller: "first\nsecond\n"),
double(title: 'Title 2', body: 'Body 2', body_with_caller: "first\nsecond\n")
]
end
it 'returns empty results' do
expect(subject.key).to eq('bullet')
expect(subject.results[:calls]).to eq(2)
expect(subject.results[:warnings]).to eq([Peek::Views::BulletDetailed::WARNING_MESSAGE])
2022-11-25 23:54:43 +05:30
expect(subject.results[:details]).to eq(
[
{ notification: 'Title 1: Body 1', backtrace: "first\nsecond\n" },
{ notification: 'Title 2: Body 2', backtrace: "first\nsecond\n" }
])
2020-06-23 00:09:42 +05:30
end
end
end
end