defmastership 1.0.4 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.gitlab-ci.yml +0 -1
- data/.rubocop.yml +1 -1
- data/Rakefile +1 -2
- data/bin/defmastership +36 -24
- data/cucumber.yml +2 -0
- data/defmastership.gemspec +14 -8
- data/features/changeref.feature +82 -129
- data/features/definition_checksum.feature +298 -0
- data/features/definition_version.feature +24 -0
- data/features/export.feature +49 -31
- data/features/modify.feature +165 -0
- data/features/rename_included_files.feature +121 -0
- data/lib/defmastership.rb +14 -3
- data/lib/defmastership/batch_modifier.rb +35 -0
- data/lib/defmastership/{ref_changer.rb → change_ref_line_modifier.rb} +18 -35
- data/lib/defmastership/change_ref_modifier.rb +15 -0
- data/lib/defmastership/constants.rb +14 -1
- data/lib/defmastership/csv_formatter.rb +25 -19
- data/lib/defmastership/csv_formatter_body.rb +19 -11
- data/lib/defmastership/csv_formatter_header.rb +15 -10
- data/lib/defmastership/definition.rb +14 -3
- data/lib/defmastership/definition_parser.rb +46 -0
- data/lib/defmastership/document.rb +59 -85
- data/lib/defmastership/filters.rb +30 -0
- data/lib/defmastership/line_modifier_base.rb +29 -0
- data/lib/defmastership/modifier_base.rb +29 -0
- data/lib/defmastership/rename_included_files_line_modifier.rb +126 -0
- data/lib/defmastership/rename_included_files_modifier.rb +15 -0
- data/lib/defmastership/update_def_checksum_line_modifier.rb +38 -0
- data/lib/defmastership/update_def_checksum_modifier.rb +21 -0
- data/lib/defmastership/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/defmastership/batch_modifier_spec.rb +123 -0
- data/spec/unit/defmastership/{ref_changer_spec.rb → change_ref_line_modifier_spec.rb} +48 -26
- data/spec/unit/defmastership/change_ref_modifier_spec.rb +76 -0
- data/spec/unit/defmastership/comment_filter_spec.rb +8 -4
- data/spec/unit/defmastership/csv_formatter_body_spec.rb +88 -82
- data/spec/unit/defmastership/csv_formatter_header_spec.rb +68 -22
- data/spec/unit/defmastership/csv_formatter_spec.rb +208 -110
- data/spec/unit/defmastership/definition_parser_spec.rb +63 -0
- data/spec/unit/defmastership/definition_spec.rb +45 -4
- data/spec/unit/defmastership/document_spec.rb +236 -35
- data/spec/unit/defmastership/rename_included_files_line_modifier_spec.rb +203 -0
- data/spec/unit/defmastership/rename_included_files_modifier_spec.rb +67 -0
- data/spec/unit/defmastership/update_def_checksum_line_modifier_spec.rb +78 -0
- data/spec/unit/defmastership/update_def_checksum_modifier_spec.rb +75 -0
- metadata +47 -16
- data/Gemfile.lock +0 -140
- data/lib/defmastership/batch_changer.rb +0 -41
- data/lib/defmastership/project_ref_changer.rb +0 -28
- data/spec/unit/defmastership/batch_changer_spec.rb +0 -109
- data/spec/unit/defmastership/project_ref_changer_spec.rb +0 -80
@@ -0,0 +1,76 @@
|
|
1
|
+
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require('defmastership')
|
5
|
+
|
6
|
+
RSpec.describe(DefMastership::ChangeRefModifier) do
|
7
|
+
subject(:modifier) do
|
8
|
+
described_class.new(
|
9
|
+
'fake config'
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:adoc_texts) do
|
14
|
+
{
|
15
|
+
'file1.adoc' => "file1 line1\nfile1 line2",
|
16
|
+
'file2.adoc' => "file2 line1\nfile2 line2"
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.new' do
|
21
|
+
it { is_expected.not_to(be(nil)) }
|
22
|
+
it { is_expected.to(have_attributes(config: 'fake config')) }
|
23
|
+
it { is_expected.to(have_attributes(changes: [])) }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#do_modifications' do
|
27
|
+
let(:line_modifier) { instance_double(DefMastership::ChangeRefLineModifier, 'lineModifier') }
|
28
|
+
|
29
|
+
before do
|
30
|
+
allow(DefMastership::ChangeRefLineModifier).to(
|
31
|
+
receive(:from_config).with('fake config').and_return(line_modifier)
|
32
|
+
)
|
33
|
+
allow(line_modifier).to(receive(:replace_refdef).with("file1 line1\n").and_return("new file1 line1\n"))
|
34
|
+
allow(line_modifier).to(receive(:replace_refdef).with('file1 line2').and_return('new file1 line2'))
|
35
|
+
allow(line_modifier).to(receive(:replace_refdef).with("file2 line1\n").and_return("new file2 line1\n"))
|
36
|
+
allow(line_modifier).to(receive(:replace_refdef).with('file2 line2').and_return('new file2 line2'))
|
37
|
+
allow(line_modifier).to(receive(:replace_irefs).with("new file1 line1\n").and_return("new2 file1 line1\n"))
|
38
|
+
allow(line_modifier).to(receive(:replace_irefs).with('new file1 line2').and_return('new2 file1 line2'))
|
39
|
+
allow(line_modifier).to(receive(:replace_irefs).with("new file2 line1\n").and_return("new2 file2 line1\n"))
|
40
|
+
allow(line_modifier).to(receive(:replace_irefs).with('new file2 line2').and_return('new2 file2 line2'))
|
41
|
+
allow(line_modifier).to(receive(:config).and_return('new fake config'))
|
42
|
+
allow(line_modifier).to(receive(:changes).and_return([%w[from1 to1], %w[from2 to2]]))
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when detailed expectations' do
|
46
|
+
before { modifier.do_modifications(adoc_texts) }
|
47
|
+
|
48
|
+
it do
|
49
|
+
expect(DefMastership::ChangeRefLineModifier).to(
|
50
|
+
have_received(:from_config).with('fake config')
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
it { expect(line_modifier).to(have_received(:replace_refdef).with("file1 line1\n")) }
|
55
|
+
it { expect(line_modifier).to(have_received(:replace_refdef).with('file1 line2')) }
|
56
|
+
it { expect(line_modifier).to(have_received(:replace_refdef).with("file2 line1\n")) }
|
57
|
+
it { expect(line_modifier).to(have_received(:replace_refdef).with('file2 line2')) }
|
58
|
+
it { expect(line_modifier).to(have_received(:replace_irefs).with("new file1 line1\n")) }
|
59
|
+
it { expect(line_modifier).to(have_received(:replace_irefs).with('new file1 line2')) }
|
60
|
+
it { expect(line_modifier).to(have_received(:replace_irefs).with("new file2 line1\n")) }
|
61
|
+
it { expect(line_modifier).to(have_received(:replace_irefs).with('new file2 line2')) }
|
62
|
+
it { expect(line_modifier).to(have_received(:config)) }
|
63
|
+
it { expect(line_modifier).to(have_received(:changes)) }
|
64
|
+
it { is_expected.to(have_attributes(config: 'new fake config')) }
|
65
|
+
it { is_expected.to(have_attributes(changes: [%w[from1 to1], %w[from2 to2]])) }
|
66
|
+
end
|
67
|
+
|
68
|
+
it do
|
69
|
+
expected_adoc = {
|
70
|
+
'file1.adoc' => "new2 file1 line1\nnew2 file1 line2",
|
71
|
+
'file2.adoc' => "new2 file2 line1\nnew2 file2 line2"
|
72
|
+
}
|
73
|
+
expect(modifier.do_modifications(adoc_texts)).to(eq(expected_adoc))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -75,8 +75,10 @@ RSpec.describe(DefMastership::CommentFilter) do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
before do
|
78
|
-
allow(DefMastership).to(
|
79
|
-
|
78
|
+
allow(DefMastership).to(
|
79
|
+
receive(:comment_filter)
|
80
|
+
.and_return(comment_filter)
|
81
|
+
)
|
80
82
|
end
|
81
83
|
|
82
84
|
context 'when not .commented?' do
|
@@ -94,8 +96,10 @@ RSpec.describe(DefMastership::CommentFilter) do
|
|
94
96
|
|
95
97
|
context 'when .commented?' do
|
96
98
|
before do
|
97
|
-
allow(comment_filter).to(
|
98
|
-
|
99
|
+
allow(comment_filter).to(
|
100
|
+
receive(:accept?)
|
101
|
+
.with('blabla').and_return(false)
|
102
|
+
)
|
99
103
|
end
|
100
104
|
|
101
105
|
it do
|
@@ -13,156 +13,162 @@ RSpec.describe(DefMastership::CSVFormatterBody) do
|
|
13
13
|
it { is_expected.not_to(be(nil)) }
|
14
14
|
end
|
15
15
|
|
16
|
-
describe '#
|
16
|
+
describe '#fixed' do
|
17
17
|
before do
|
18
18
|
allow(definition).to(receive(:type).with(no_args).and_return('a'))
|
19
19
|
allow(definition).to(receive(:reference).with(no_args).and_return('b'))
|
20
20
|
allow(definition).to(receive(:value).with(no_args).and_return('c'))
|
21
|
-
|
21
|
+
allow(definition).to(receive(:sha256).with(no_args).and_return('d'))
|
22
|
+
formatter.fixed(definition)
|
22
23
|
end
|
23
24
|
|
24
25
|
it { expect(definition).to(have_received(:type).with(no_args)) }
|
25
|
-
|
26
26
|
it { expect(definition).to(have_received(:reference).with(no_args)) }
|
27
|
-
|
28
27
|
it { expect(definition).to(have_received(:value).with(no_args)) }
|
29
|
-
|
30
|
-
it { expect(formatter.
|
28
|
+
it { expect(definition).to(have_received(:sha256).with(no_args)) }
|
29
|
+
it { expect(formatter.fixed(definition)).to(eq(%w[a b c d])) }
|
31
30
|
end
|
32
31
|
|
33
|
-
describe '#
|
34
|
-
context 'when no
|
32
|
+
describe '#wrong_explicit_checksum' do
|
33
|
+
context 'when no wrong_explicit checksum' do
|
35
34
|
before do
|
36
|
-
allow(
|
37
|
-
formatter.
|
35
|
+
allow(definition).to(receive(:wrong_explicit_checksum).with(no_args).and_return(nil))
|
36
|
+
formatter.wrong_explicit_checksum(definition)
|
38
37
|
end
|
39
38
|
|
40
|
-
it { expect(
|
41
|
-
|
42
|
-
it { expect(formatter.labels_body(definition)).to(eq([])) }
|
39
|
+
it { expect(definition).to(have_received(:wrong_explicit_checksum).with(no_args)) }
|
40
|
+
it { expect(formatter.wrong_explicit_checksum(definition)).to(eq([''])) }
|
43
41
|
end
|
44
42
|
|
45
|
-
context 'when
|
46
|
-
before
|
43
|
+
context 'when explicit checksum' do
|
44
|
+
before do
|
45
|
+
allow(definition).to(receive(:wrong_explicit_checksum).with(no_args).and_return('ab12'))
|
46
|
+
formatter.wrong_explicit_checksum(definition)
|
47
|
+
end
|
48
|
+
|
49
|
+
it { expect(formatter.wrong_explicit_checksum(definition)).to(eq(['ab12'])) }
|
50
|
+
end
|
51
|
+
end
|
47
52
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
+
describe '#explicit_version' do
|
54
|
+
context 'when no explicit_version' do
|
55
|
+
before do
|
56
|
+
allow(definition).to(receive(:explicit_version).with(no_args).and_return(nil))
|
57
|
+
formatter.explicit_version(definition)
|
58
|
+
end
|
53
59
|
|
54
|
-
|
60
|
+
it { expect(definition).to(have_received(:explicit_version).with(no_args)) }
|
61
|
+
it { expect(formatter.explicit_version(definition)).to(eq([''])) }
|
62
|
+
end
|
55
63
|
|
56
|
-
|
64
|
+
context 'when explicit_version' do
|
65
|
+
before do
|
66
|
+
allow(definition).to(receive(:explicit_version).with(no_args).and_return('ab12'))
|
67
|
+
formatter.explicit_version(definition)
|
57
68
|
end
|
58
69
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
formatter.labels_body(definition)
|
63
|
-
end
|
70
|
+
it { expect(formatter.explicit_version(definition)).to(eq(['ab12'])) }
|
71
|
+
end
|
72
|
+
end
|
64
73
|
|
65
|
-
|
74
|
+
describe '#labels' do
|
75
|
+
before { allow(document).to(receive(:labels).with(no_args).and_return(['whatever'])) }
|
66
76
|
|
67
|
-
|
77
|
+
context 'when no labels on definition' do
|
78
|
+
before do
|
79
|
+
allow(definition).to(receive(:labels).with(no_args).and_return([]))
|
80
|
+
formatter.labels(definition)
|
68
81
|
end
|
82
|
+
|
83
|
+
it { expect(definition).to(have_received(:labels).once.with(no_args)) }
|
84
|
+
it { expect(formatter.labels(definition)).to(eq([''])) }
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when labels on definition' do
|
88
|
+
before do
|
89
|
+
allow(definition).to(receive(:labels).with(no_args).and_return(%w[toto tutu]))
|
90
|
+
formatter.labels(definition)
|
91
|
+
end
|
92
|
+
|
93
|
+
it { expect(definition).to(have_received(:labels).once.with(no_args)) }
|
94
|
+
it { expect(formatter.labels(definition)).to(eq(["toto\ntutu"])) }
|
69
95
|
end
|
70
96
|
end
|
71
97
|
|
72
|
-
describe '#
|
98
|
+
describe '#eref' do
|
73
99
|
context 'when no eref on the document' do
|
74
100
|
before do
|
75
101
|
allow(document).to(receive(:eref).with(no_args).and_return({}))
|
76
|
-
formatter.
|
102
|
+
formatter.eref(definition)
|
77
103
|
end
|
78
104
|
|
79
105
|
it { expect(document).to(have_received(:eref).with(no_args)) }
|
80
|
-
|
81
|
-
it { expect(formatter.eref_body(nil)).to(eq([])) }
|
106
|
+
it { expect(formatter.eref(nil)).to(eq([])) }
|
82
107
|
end
|
83
108
|
|
84
109
|
context 'when eref on the document' do
|
85
110
|
before do
|
86
|
-
allow(document).to(
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
111
|
+
allow(document).to(
|
112
|
+
receive(:eref).with(no_args).and_return(
|
113
|
+
a: 'whatever', b: 'whatever', c: 'whatever'
|
114
|
+
)
|
115
|
+
)
|
91
116
|
allow(definition).to(receive(:eref).with(no_args).and_return(a: %w[A B], b: [], c: ['C']))
|
92
|
-
formatter.
|
117
|
+
formatter.eref(definition)
|
93
118
|
end
|
94
119
|
|
95
120
|
it { expect(definition).to(have_received(:eref).exactly(3).times.with(no_args)) }
|
96
|
-
|
97
|
-
it { expect(formatter.eref_body(definition)).to(eq(["A\nB", '', 'C'])) }
|
121
|
+
it { expect(formatter.eref(definition)).to(eq(["A\nB", '', 'C'])) }
|
98
122
|
end
|
99
123
|
end
|
100
124
|
|
101
|
-
describe '#
|
102
|
-
|
125
|
+
describe '#iref' do
|
126
|
+
before { allow(document).to(receive(:iref).with(no_args).and_return(true)) }
|
127
|
+
|
128
|
+
context 'when no iref on the definition' do
|
103
129
|
before do
|
104
|
-
allow(
|
105
|
-
formatter.
|
130
|
+
allow(definition).to(receive(:iref).with(no_args).and_return([]))
|
131
|
+
formatter.iref(definition)
|
106
132
|
end
|
107
133
|
|
108
|
-
it { expect(
|
109
|
-
|
110
|
-
it { expect(formatter.iref_body(definition)).to(eq([])) }
|
134
|
+
it { expect(definition).to(have_received(:iref).with(no_args)) }
|
135
|
+
it { expect(formatter.iref(definition)).to(eq([''])) }
|
111
136
|
end
|
112
137
|
|
113
|
-
context 'when iref on the
|
114
|
-
before
|
115
|
-
|
116
|
-
|
117
|
-
before do
|
118
|
-
allow(definition).to(receive(:iref).with(no_args).and_return([]))
|
119
|
-
formatter.iref_body(definition)
|
120
|
-
end
|
121
|
-
|
122
|
-
it { expect(definition).to(have_received(:iref).with(no_args)) }
|
123
|
-
|
124
|
-
it { expect(formatter.iref_body(definition)).to(eq([''])) }
|
138
|
+
context 'when iref on the definition' do
|
139
|
+
before do
|
140
|
+
allow(definition).to(receive(:iref).with(no_args).and_return(%w[A B]))
|
141
|
+
formatter.iref(definition)
|
125
142
|
end
|
126
143
|
|
127
|
-
|
128
|
-
|
129
|
-
allow(definition).to(receive(:iref).with(no_args).and_return(%w[A B]))
|
130
|
-
formatter.iref_body(definition)
|
131
|
-
end
|
132
|
-
|
133
|
-
it { expect(definition).to(have_received(:iref).with(no_args)) }
|
134
|
-
|
135
|
-
it { expect(formatter.iref_body(definition)).to(eq(["A\nB"])) }
|
136
|
-
end
|
144
|
+
it { expect(definition).to(have_received(:iref).with(no_args)) }
|
145
|
+
it { expect(formatter.iref(definition)).to(eq(["A\nB"])) }
|
137
146
|
end
|
138
147
|
end
|
139
148
|
|
140
|
-
describe '#
|
149
|
+
describe '#attributes' do
|
141
150
|
context 'when no attributes on the document' do
|
142
151
|
before do
|
143
152
|
allow(document).to(receive(:attributes).with(no_args).and_return({}))
|
144
|
-
formatter.
|
153
|
+
formatter.attributes(definition)
|
145
154
|
end
|
146
155
|
|
147
156
|
it { expect(document).to(have_received(:attributes).with(no_args)) }
|
148
|
-
|
149
|
-
it { expect(formatter.attributes_body(nil)).to(eq([])) }
|
157
|
+
it { expect(formatter.attributes(nil)).to(eq([])) }
|
150
158
|
end
|
151
159
|
|
152
160
|
context 'when attributes on the document' do
|
153
161
|
before do
|
154
|
-
allow(document).to(
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
))
|
162
|
+
allow(document).to(
|
163
|
+
receive(:attributes).with(no_args)
|
164
|
+
.and_return(a: 'whatever', b: 'whatever', c: 'whatever')
|
165
|
+
)
|
159
166
|
allow(definition).to(receive(:attributes).and_return(a: 'X', b: '', c: 'Y'))
|
160
|
-
formatter.
|
167
|
+
formatter.attributes(definition)
|
161
168
|
end
|
162
169
|
|
163
170
|
it { expect(definition).to(have_received(:attributes).exactly(3).times) }
|
164
|
-
|
165
|
-
it { expect(formatter.attributes_body(definition)).to(eq(['X', '', 'Y'])) }
|
171
|
+
it { expect(formatter.attributes(definition)).to(eq(['X', '', 'Y'])) }
|
166
172
|
end
|
167
173
|
end
|
168
174
|
end
|
@@ -13,88 +13,134 @@ RSpec.describe(DefMastership::CSVFormatterHeader) do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '#header' do
|
16
|
-
describe '#
|
17
|
-
it { expect(formatter.
|
16
|
+
describe '#fixed' do
|
17
|
+
it { expect(formatter.fixed).to(eq(%w[Type Reference Value Checksum])) }
|
18
18
|
end
|
19
19
|
|
20
|
-
describe '#
|
20
|
+
describe '#explicit_version' do
|
21
|
+
context 'when no explicit version' do
|
22
|
+
before do
|
23
|
+
allow(document).to(receive(:explicit_version?).and_return(false))
|
24
|
+
formatter.explicit_version
|
25
|
+
end
|
26
|
+
|
27
|
+
it { expect(document).to(have_received(:explicit_version?)) }
|
28
|
+
|
29
|
+
it { expect(formatter.explicit_version).to(eq([])) }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when explicit version' do
|
33
|
+
before do
|
34
|
+
allow(document).to(receive(:explicit_version?).and_return(true))
|
35
|
+
formatter.explicit_version
|
36
|
+
end
|
37
|
+
|
38
|
+
it { expect(formatter.explicit_version).to(eq(['Version'])) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#wrong_explicit_checksum' do
|
43
|
+
context 'when no wrong explicit checksum' do
|
44
|
+
before do
|
45
|
+
allow(document).to(receive(:wrong_explicit_checksum?).and_return(false))
|
46
|
+
formatter.wrong_explicit_checksum
|
47
|
+
end
|
48
|
+
|
49
|
+
it { expect(document).to(have_received(:wrong_explicit_checksum?)) }
|
50
|
+
|
51
|
+
it { expect(formatter.wrong_explicit_checksum).to(eq([])) }
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when wrong explicit checksum' do
|
55
|
+
before do
|
56
|
+
allow(document).to(receive(:wrong_explicit_checksum?).and_return(true))
|
57
|
+
formatter.wrong_explicit_checksum
|
58
|
+
end
|
59
|
+
|
60
|
+
it { expect(formatter.wrong_explicit_checksum).to(eq(['Wrong explicit checksum'])) }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#labels' do
|
21
65
|
context 'when no labels' do
|
22
66
|
before do
|
23
67
|
allow(document).to(receive(:labels).and_return([]))
|
24
|
-
formatter.
|
68
|
+
formatter.labels
|
25
69
|
end
|
26
70
|
|
27
71
|
it { expect(document).to(have_received(:labels)) }
|
28
72
|
|
29
|
-
it { expect(formatter.
|
73
|
+
it { expect(formatter.labels).to(eq([])) }
|
30
74
|
end
|
31
75
|
|
32
76
|
context 'when there is labels' do
|
33
77
|
before { allow(document).to(receive(:labels).and_return(['Whatever'])) }
|
34
78
|
|
35
|
-
it { expect(formatter.
|
79
|
+
it { expect(formatter.labels).to(eq(['Labels'])) }
|
36
80
|
end
|
37
81
|
end
|
38
82
|
|
39
|
-
describe '#
|
83
|
+
describe '#eref' do
|
40
84
|
context 'when no eref' do
|
41
85
|
before do
|
42
86
|
allow(document).to(receive(:eref).and_return({}))
|
43
|
-
formatter.
|
87
|
+
formatter.eref
|
44
88
|
end
|
45
89
|
|
46
90
|
it { expect(document).to(have_received(:eref)) }
|
47
91
|
|
48
|
-
it { expect(formatter.
|
92
|
+
it { expect(formatter.eref).to(eq([])) }
|
49
93
|
end
|
50
94
|
|
51
95
|
context 'when eref' do
|
52
96
|
before do
|
53
|
-
allow(document).to(
|
54
|
-
|
55
|
-
|
56
|
-
|
97
|
+
allow(document).to(
|
98
|
+
receive(:eref).and_return(
|
99
|
+
whatever: { prefix: 'A' },
|
100
|
+
other: { prefix: 'C', url: 'D' }
|
101
|
+
)
|
102
|
+
)
|
57
103
|
end
|
58
104
|
|
59
|
-
it { expect(formatter.
|
105
|
+
it { expect(formatter.eref).to(eq(%w[A C])) }
|
60
106
|
end
|
61
107
|
end
|
62
108
|
|
63
|
-
describe '#
|
109
|
+
describe '#iref' do
|
64
110
|
context 'when no iref' do
|
65
111
|
before do
|
66
112
|
allow(document).to(receive(:iref).and_return(false))
|
67
|
-
formatter.
|
113
|
+
formatter.iref
|
68
114
|
end
|
69
115
|
|
70
116
|
it { expect(document).to(have_received(:iref)) }
|
71
117
|
|
72
|
-
it { expect(formatter.
|
118
|
+
it { expect(formatter.iref).to(eq([])) }
|
73
119
|
end
|
74
120
|
|
75
121
|
context 'when iref' do
|
76
122
|
before { allow(document).to(receive(:iref).and_return(true)) }
|
77
123
|
|
78
|
-
it { expect(formatter.
|
124
|
+
it { expect(formatter.iref).to(eq(['Internal links'])) }
|
79
125
|
end
|
80
126
|
end
|
81
127
|
|
82
|
-
describe '#
|
128
|
+
describe '#attributes' do
|
83
129
|
context 'when no attributes' do
|
84
130
|
before do
|
85
131
|
allow(document).to(receive(:attributes).and_return({}))
|
86
|
-
formatter.
|
132
|
+
formatter.attributes
|
87
133
|
end
|
88
134
|
|
89
135
|
it { expect(document).to(have_received(:attributes)) }
|
90
136
|
|
91
|
-
it { expect(formatter.
|
137
|
+
it { expect(formatter.attributes).to(eq([])) }
|
92
138
|
end
|
93
139
|
|
94
140
|
context 'when attributes' do
|
95
141
|
before { allow(document).to(receive(:attributes).and_return(whatever: 'A', other: 'B')) }
|
96
142
|
|
97
|
-
it { expect(formatter.
|
143
|
+
it { expect(formatter.attributes).to(eq(%w[A B])) }
|
98
144
|
end
|
99
145
|
end
|
100
146
|
end
|