defmastership 1.0.2 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.gitlab-ci.yml +20 -0
- data/.rubocop.yml +6 -8
- data/Gemfile +1 -0
- data/LICENSE +22 -0
- data/Rakefile +2 -2
- data/bin/defmastership +37 -24
- data/cucumber.yml +2 -0
- data/defmastership.gemspec +17 -10
- data/features/changeref.feature +82 -129
- data/features/checksum.feature +244 -0
- data/features/export.feature +49 -31
- data/features/modify.feature +143 -0
- data/features/rename_included_files.feature +121 -0
- data/features/step_definitions/defmastership_steps.rb +1 -0
- data/features/support/env.rb +1 -0
- data/lib/defmastership.rb +15 -3
- data/lib/defmastership/batch_modifier.rb +33 -0
- data/lib/defmastership/{ref_changer.rb → change_ref_line_modifier.rb} +19 -35
- data/lib/defmastership/change_ref_modifier.rb +15 -0
- data/lib/defmastership/comment_filter.rb +1 -0
- data/lib/defmastership/constants.rb +15 -1
- data/lib/defmastership/csv_formatter.rb +19 -18
- data/lib/defmastership/csv_formatter_body.rb +12 -6
- data/lib/defmastership/csv_formatter_header.rb +12 -10
- data/lib/defmastership/definition.rb +12 -0
- data/lib/defmastership/definition_parser.rb +46 -0
- data/lib/defmastership/document.rb +54 -75
- 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 +39 -0
- data/lib/defmastership/update_def_checksum_modifier.rb +21 -0
- data/lib/defmastership/version.rb +2 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/defmastership/batch_modifier_spec.rb +115 -0
- data/spec/unit/defmastership/{ref_changer_spec.rb → change_ref_line_modifier_spec.rb} +49 -26
- data/spec/unit/defmastership/change_ref_modifier_spec.rb +76 -0
- data/spec/unit/defmastership/comment_filter_spec.rb +9 -4
- data/spec/unit/defmastership/csv_formatter_body_spec.rb +62 -37
- data/spec/unit/defmastership/csv_formatter_header_spec.rb +47 -22
- data/spec/unit/defmastership/csv_formatter_spec.rb +67 -105
- data/spec/unit/defmastership/definition_parser_spec.rb +63 -0
- data/spec/unit/defmastership/definition_spec.rb +31 -4
- data/spec/unit/defmastership/document_spec.rb +170 -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 +68 -0
- data/spec/unit/defmastership/update_def_checksum_modifier_spec.rb +75 -0
- data/spec/unit/defmastership_spec.rb +1 -0
- metadata +50 -18
- data/Gemfile.lock +0 -137
- data/lib/defmastership/batch_changer.rb +0 -40
- data/lib/defmastership/project_ref_changer.rb +0 -27
- data/spec/unit/defmastership/batch_changer_spec.rb +0 -108
- data/spec/unit/defmastership/project_ref_changer_spec.rb +0 -79
@@ -0,0 +1,15 @@
|
|
1
|
+
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module DefMastership
|
5
|
+
# Change included filenames
|
6
|
+
class RenameIncludedFilesModifier < ModifierBase
|
7
|
+
def replacements
|
8
|
+
%i[replace]
|
9
|
+
end
|
10
|
+
|
11
|
+
def new_line_modifier(config, _adoc_texts)
|
12
|
+
RenameIncludedFilesLineModifier.from_config(config)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module DefMastership
|
5
|
+
# modify one line after another
|
6
|
+
class UpdateDefChecksumLineModifier < LineModifierBase
|
7
|
+
attr_accessor :document
|
8
|
+
|
9
|
+
def self.from_config(hash)
|
10
|
+
new.from_config(hash)
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
@config = {
|
16
|
+
def_type: ''
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def replace(line)
|
21
|
+
match = matched?(line)
|
22
|
+
|
23
|
+
return line unless match
|
24
|
+
return line unless match[:type] == def_type
|
25
|
+
|
26
|
+
explicit_checksum_str = match[:explicit_checksum].nil? ? '' : "(#{match[:explicit_checksum]})"
|
27
|
+
line.gsub("#{match[:reference]}#{explicit_checksum_str}") do
|
28
|
+
"#{match[:reference]}(#{@document.ref_to_def(match[:reference]).sha256})"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def matched?(line)
|
33
|
+
return if line.commented?
|
34
|
+
return unless line =~ DMRegexp::DEFINITION
|
35
|
+
|
36
|
+
Regexp.last_match
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module DefMastership
|
5
|
+
# Update definition checksum wih calculated one
|
6
|
+
class UpdateDefChecksumModifier < ModifierBase
|
7
|
+
def replacements
|
8
|
+
%i[replace]
|
9
|
+
end
|
10
|
+
|
11
|
+
def new_line_modifier(config, adoc_texts)
|
12
|
+
document = Document.new
|
13
|
+
adoc_texts.each do |adoc_file, _|
|
14
|
+
document.parse_file_with_preprocessor(adoc_file)
|
15
|
+
end
|
16
|
+
line_modifier = UpdateDefChecksumLineModifier.from_config(config)
|
17
|
+
line_modifier.document = document
|
18
|
+
line_modifier
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# Copyright (c) 2020 Jerome Arbez-Gindre
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require('bundler/setup')
|
4
5
|
require('aruba/rspec')
|
6
|
+
require('aasm/rspec')
|
5
7
|
|
6
8
|
# formatter = [SimpleCov::Formatter::HTMLFormatter]
|
7
9
|
# SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(formatter)
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require('defmastership')
|
5
|
+
|
6
|
+
module DefMastership
|
7
|
+
class TotoClassModifier < ModifierBase
|
8
|
+
end
|
9
|
+
|
10
|
+
class TutuClassModifier < ModifierBase
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
RSpec.describe(DefMastership::BatchModifier) do
|
15
|
+
subject(:batchmodifier) do
|
16
|
+
described_class.new(config, adoc_texts)
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:config) do
|
20
|
+
{
|
21
|
+
modifier1: { type: 'toto_class', config: { p: 1 } },
|
22
|
+
modifier2: { type: 'toto_class', config: { p: 'whatever1' } },
|
23
|
+
modifier3: { type: 'tutu_class', config: { p1: 'whatever2', p2: 'whatever3' } }
|
24
|
+
}
|
25
|
+
end
|
26
|
+
let(:adoc_texts) do
|
27
|
+
{
|
28
|
+
'file1.adoc' => 'some text',
|
29
|
+
'file2.adoc' => 'another text'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '.new' do
|
34
|
+
it { is_expected.not_to(be(nil)) }
|
35
|
+
it { is_expected.to(have_attributes(config: config)) }
|
36
|
+
|
37
|
+
it do
|
38
|
+
expect(batchmodifier).to(have_attributes(adoc_texts: adoc_texts))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#apply' do
|
43
|
+
context 'with only one modification' do
|
44
|
+
let(:toto1) { instance_double(DefMastership::TotoClassModifier, 'toto1') }
|
45
|
+
let(:adoc_texts_modified) do
|
46
|
+
{
|
47
|
+
'file1.adoc' => 'some text modified',
|
48
|
+
'file2.adoc' => 'another text'
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
let(:config_modified) do
|
53
|
+
{
|
54
|
+
modifier1: { type: 'toto_class', config: { p: 'modified_param' } },
|
55
|
+
modifier2: { type: 'toto_class', config: { p: 'whatever1' } },
|
56
|
+
modifier3: { type: 'tutu_class', config: { p1: 'whatever2', p2: 'whatever3' } }
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
before do
|
61
|
+
allow(DefMastership::TotoClassModifier).to(receive(:new).once.and_return(toto1))
|
62
|
+
allow(toto1).to(receive(:do_modifications).once.and_return(adoc_texts_modified))
|
63
|
+
allow(toto1).to(receive(:config).once.and_return(p: 'modified_param'))
|
64
|
+
allow(toto1).to(receive(:changes).once.and_return([%w[from1 to1], %w[from2 to2]]))
|
65
|
+
batchmodifier.apply('modifier1')
|
66
|
+
end
|
67
|
+
|
68
|
+
it do
|
69
|
+
expect(DefMastership::TotoClassModifier).to(have_received(:new).with(p: 1))
|
70
|
+
end
|
71
|
+
|
72
|
+
it { expect(toto1).to(have_received(:do_modifications).with(adoc_texts)) }
|
73
|
+
it { is_expected.to(have_attributes(adoc_texts: adoc_texts_modified)) }
|
74
|
+
it { expect(toto1).to(have_received(:config).with(no_args)) }
|
75
|
+
|
76
|
+
it { is_expected.to(have_attributes(config: config_modified)) }
|
77
|
+
it { is_expected.to(have_attributes(changes: [%w[modifier1 from1 to1], %w[modifier1 from2 to2]])) }
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'with two modifications' do
|
81
|
+
let(:toto2) { instance_double(DefMastership::TotoClassModifier, 'toto2') }
|
82
|
+
let(:tutu3) { instance_double(DefMastership::TutuClassModifier, 'tutu3') }
|
83
|
+
|
84
|
+
let(:config_modified) do
|
85
|
+
{
|
86
|
+
modifier1: { type: 'toto_class', config: { p: 1 } },
|
87
|
+
modifier2: { type: 'toto_class', config: :whatever },
|
88
|
+
modifier3: { type: 'tutu_class', config: :pouet }
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
before do
|
93
|
+
allow(DefMastership::TotoClassModifier).to(receive(:new).once.and_return(toto2))
|
94
|
+
allow(toto2).to(receive(:do_modifications).once.and_return(:adoc_texts_modified_mod2))
|
95
|
+
allow(toto2).to(receive(:config).once.and_return(:whatever))
|
96
|
+
allow(DefMastership::TutuClassModifier).to(receive(:new).once.and_return(tutu3))
|
97
|
+
allow(tutu3).to(receive(:do_modifications).once.and_return(:adoc_texts_modified_mod3))
|
98
|
+
allow(tutu3).to(receive(:config).once.and_return(:pouet))
|
99
|
+
allow(toto2).to(receive(:changes).once.and_return([%w[from1 to1]]))
|
100
|
+
allow(tutu3).to(receive(:changes).once.and_return([%w[from2 to2]]))
|
101
|
+
batchmodifier.apply('modifier2, modifier3')
|
102
|
+
end
|
103
|
+
|
104
|
+
it { expect(DefMastership::TotoClassModifier).to(have_received(:new).with(p: 'whatever1')) }
|
105
|
+
it { expect(DefMastership::TutuClassModifier).to(have_received(:new).with(p1: 'whatever2', p2: 'whatever3')) }
|
106
|
+
it { expect(toto2).to(have_received(:do_modifications).with(adoc_texts)) }
|
107
|
+
it { expect(toto2).to(have_received(:config).with(no_args)) }
|
108
|
+
it { expect(tutu3).to(have_received(:do_modifications).with(:adoc_texts_modified_mod2)) }
|
109
|
+
it { expect(tutu3).to(have_received(:config).with(no_args)) }
|
110
|
+
it { is_expected.to(have_attributes(adoc_texts: :adoc_texts_modified_mod3)) }
|
111
|
+
it { is_expected.to(have_attributes(config: config_modified)) }
|
112
|
+
it { is_expected.to(have_attributes(changes: [%w[modifier2 from1 to1], %w[modifier3 from2 to2]])) }
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# Copyright (c) 2020 Jerome Arbez-Gindre
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require('defmastership')
|
4
5
|
|
5
|
-
RSpec.describe(DefMastership::
|
6
|
+
RSpec.describe(DefMastership::ChangeRefLineModifier) do
|
6
7
|
subject(:refchanger) { described_class.new }
|
7
8
|
|
8
9
|
describe '.new' do
|
@@ -14,9 +15,9 @@ RSpec.describe(DefMastership::RefChanger) do
|
|
14
15
|
it { expect { refchanger.user_defined_attribute }.to(raise_error(NoMethodError)) }
|
15
16
|
end
|
16
17
|
|
17
|
-
describe '.
|
18
|
+
describe '.from_config' do
|
18
19
|
subject(:refchanger) do
|
19
|
-
described_class.
|
20
|
+
described_class.from_config(
|
20
21
|
from_regexp: 'Whatever.+',
|
21
22
|
to_template: 'Whatever',
|
22
23
|
next_ref: 17
|
@@ -29,9 +30,9 @@ RSpec.describe(DefMastership::RefChanger) do
|
|
29
30
|
it { is_expected.to(have_attributes(next_ref: 17)) }
|
30
31
|
end
|
31
32
|
|
32
|
-
describe '#
|
33
|
+
describe '#from_config' do
|
33
34
|
before do
|
34
|
-
refchanger.
|
35
|
+
refchanger.from_config(
|
35
36
|
from_regexp: 'Whatever.+',
|
36
37
|
to_template: 'Whatever',
|
37
38
|
next_ref: 17,
|
@@ -45,36 +46,34 @@ RSpec.describe(DefMastership::RefChanger) do
|
|
45
46
|
it { is_expected.to(have_attributes(user_defined_attribute: 'Tadaam')) }
|
46
47
|
end
|
47
48
|
|
48
|
-
describe '#
|
49
|
+
describe '#config' do
|
49
50
|
context 'when not initalized' do
|
50
51
|
it do
|
51
|
-
expect(refchanger.
|
52
|
-
|
53
|
-
|
54
|
-
next_ref: 0
|
55
|
-
))
|
52
|
+
expect(refchanger.config).to(
|
53
|
+
include(from_regexp: '', to_template: '', next_ref: 0)
|
54
|
+
)
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
59
58
|
context 'when initalized with additionnal keys' do
|
60
59
|
before do
|
61
|
-
refchanger.
|
60
|
+
refchanger.from_config(
|
62
61
|
next_ref: 1256,
|
63
62
|
user_defined_attribute: 'Tadaam'
|
64
63
|
)
|
65
64
|
end
|
66
65
|
|
67
|
-
it { expect(refchanger.
|
68
|
-
it { expect(refchanger.
|
69
|
-
it { expect(refchanger.
|
70
|
-
it { expect(refchanger.
|
66
|
+
it { expect(refchanger.config).to(include(from_regexp: '')) }
|
67
|
+
it { expect(refchanger.config).to(include(to_template: '')) }
|
68
|
+
it { expect(refchanger.config).to(include(next_ref: 1256)) }
|
69
|
+
it { expect(refchanger.config).to(include(user_defined_attribute: 'Tadaam')) }
|
71
70
|
end
|
72
71
|
end
|
73
72
|
|
74
|
-
describe '#
|
73
|
+
describe '#replace_def' do
|
75
74
|
context 'when really simple rule' do
|
76
75
|
before do
|
77
|
-
refchanger.
|
76
|
+
refchanger.from_config(
|
78
77
|
from_regexp: 'TEMP',
|
79
78
|
to_template: 'TUTU'
|
80
79
|
)
|
@@ -97,7 +96,7 @@ RSpec.describe(DefMastership::RefChanger) do
|
|
97
96
|
|
98
97
|
context 'when template is variable' do
|
99
98
|
before do
|
100
|
-
refchanger.
|
99
|
+
refchanger.from_config(
|
101
100
|
from_regexp: 'TEMP',
|
102
101
|
to_template: 'TOTO-%<next_ref>04d',
|
103
102
|
next_ref: 124
|
@@ -117,7 +116,7 @@ RSpec.describe(DefMastership::RefChanger) do
|
|
117
116
|
|
118
117
|
context 'when capture group in regexp' do
|
119
118
|
before do
|
120
|
-
refchanger.
|
119
|
+
refchanger.from_config(
|
121
120
|
from_regexp: '(?<cg>TOTO|TITI)-TEMP[\d]*',
|
122
121
|
to_template: '%<cg>s-%<next_ref>04d',
|
123
122
|
next_ref: 132
|
@@ -144,7 +143,7 @@ RSpec.describe(DefMastership::RefChanger) do
|
|
144
143
|
|
145
144
|
context 'when definition is in literal block' do
|
146
145
|
before do
|
147
|
-
refchanger.
|
146
|
+
refchanger.from_config(
|
148
147
|
from_regexp: 'TEMP',
|
149
148
|
to_template: 'TUTU'
|
150
149
|
)
|
@@ -159,7 +158,7 @@ RSpec.describe(DefMastership::RefChanger) do
|
|
159
158
|
|
160
159
|
context 'when defintion is after literal block' do
|
161
160
|
before do
|
162
|
-
refchanger.
|
161
|
+
refchanger.from_config(
|
163
162
|
from_regexp: 'TEMP',
|
164
163
|
to_template: 'TUTU'
|
165
164
|
)
|
@@ -177,7 +176,7 @@ RSpec.describe(DefMastership::RefChanger) do
|
|
177
176
|
|
178
177
|
describe '#replace_irefs' do
|
179
178
|
before do
|
180
|
-
refchanger.
|
179
|
+
refchanger.from_config(
|
181
180
|
from_regexp: '(?<cg>TOTO|TITI)-TEMP[\d]*',
|
182
181
|
to_template: '%<cg>s-%<next_ref>04d',
|
183
182
|
next_ref: 132
|
@@ -197,9 +196,33 @@ RSpec.describe(DefMastership::RefChanger) do
|
|
197
196
|
end
|
198
197
|
|
199
198
|
it do
|
200
|
-
expect(
|
201
|
-
|
202
|
-
|
199
|
+
expect(
|
200
|
+
refchanger.replace_irefs(
|
201
|
+
'defs:iref[TOTO-TEMP123] defs:iref[TITI-TEMP421] bla'
|
202
|
+
)
|
203
|
+
).to(eq('defs:iref[TOTO-0132] defs:iref[TITI-0133] bla'))
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
describe '#replace' do
|
208
|
+
before do
|
209
|
+
refchanger.from_config(
|
210
|
+
from_regexp: 'TEMP',
|
211
|
+
to_template: 'TUTU'
|
212
|
+
)
|
213
|
+
end
|
214
|
+
|
215
|
+
it do
|
216
|
+
expect(refchanger.replace(:refdef, '[define, whatever, TEMP]'))
|
217
|
+
.to(eq('[define, whatever, TUTU]'))
|
203
218
|
end
|
219
|
+
|
220
|
+
it do
|
221
|
+
refchanger.replace(:refdef, '[define, whatever, TEMP]')
|
222
|
+
expect(refchanger.replace(:irefs, 'defs:iref[TEMP]'))
|
223
|
+
.to(eq('defs:iref[TUTU]'))
|
224
|
+
end
|
225
|
+
|
226
|
+
it { expect { refchanger.replace(:pouet, 'whatever') }.to(raise_error(NoMethodError)) }
|
204
227
|
end
|
205
228
|
end
|
@@ -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
|