blob: 326800e6dc20259867eba1dbb077373af89e0ae3 (
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
48
49
50
51
52
53
54
55
56
57
58
59
|
# frozen_string_literal: true
RSpec.shared_examples "position formatter" do
let(:formatter) { described_class.new(attrs) }
describe '#key' do
let(:key) { [123, 456, 789, Digest::SHA1.hexdigest(formatter.old_path), Digest::SHA1.hexdigest(formatter.new_path), 1, 2] }
subject { formatter.key }
it { is_expected.to eq(key) }
end
describe '#complete?' do
subject { formatter.complete? }
context 'when there are missing key attributes' do
it { is_expected.to be_truthy }
end
context 'when old_line and new_line are nil' do
let(:attrs) { base_attrs }
it { is_expected.to be_falsy }
end
end
describe '#to_h' do
let(:formatter_hash) do
attrs.merge(position_type: base_attrs[:position_type] || 'text' )
end
subject { formatter.to_h }
context 'when file_identifier_hash is disabled' do
before do
stub_feature_flags(file_identifier_hash: false)
end
it { is_expected.to eq(formatter_hash.except(:file_identifier_hash)) }
end
context 'when file_identifier_hash is enabled' do
before do
stub_feature_flags(file_identifier_hash: true)
end
it { is_expected.to eq(formatter_hash) }
end
end
describe '#==' do
subject { formatter }
let(:other_formatter) { described_class.new(attrs) }
it { is_expected.to eq(other_formatter) }
end
end
|