summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/services/incident_shared_examples.rb
blob: d6e79931df57d14bc37b8009d0afc2c14f614ffd (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true

# This shared_example requires the following variables:
# - issue (required)
#
# Usage:
#
#   it_behaves_like 'incident issue' do
#     let(:issue) { ... }
#   end
#
#   include_examples 'incident issue'
RSpec.shared_examples 'incident issue' do
  let(:label_properties) { attributes_for(:label, :incident) }

  it 'has incident as issue type' do
    expect(issue.issue_type).to eq('incident')
  end

  it 'has exactly one incident label' do
    expect(issue.labels).to be_one do |label|
      label.slice(*label_properties.keys).symbolize_keys == label_properties
    end
  end
end

# This shared_example requires the following variables:
# - issue (required)
#
# Usage:
#
#   it_behaves_like 'not an incident issue' do
#     let(:issue) { ... }
#   end
#
#   include_examples 'not an incident issue'
RSpec.shared_examples 'not an incident issue' do
  let(:label_properties) { attributes_for(:label, :incident) }

  it 'has not incident as issue type' do
    expect(issue.issue_type).not_to eq('incident')
  end

  it 'has not an incident label' do
    expect(issue.labels).not_to include(have_attributes(label_properties))
  end
end