defmastership 1.0.5 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/bin/defmastership +33 -22
- data/cucumber.yml +1 -1
- data/defmastership.gemspec +12 -6
- data/features/changeref.feature +82 -129
- data/features/definition_checksum.feature +298 -0
- data/features/definition_version.feature +204 -0
- data/features/export.feature +35 -34
- data/features/modify.feature +165 -0
- data/features/rename_included_files.feature +121 -0
- data/lib/defmastership.rb +17 -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 +22 -17
- 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/update_def_version_line_modifier.rb +58 -0
- data/lib/defmastership/update_def_version_modifier.rb +25 -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 +207 -109
- 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
- data/spec/unit/defmastership/update_def_version_line_modifier_spec.rb +127 -0
- data/spec/unit/defmastership/update_def_version_modifier_spec.rb +80 -0
- metadata +44 -9
- 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,80 @@
|
|
1
|
+
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require('defmastership')
|
5
|
+
|
6
|
+
RSpec.describe(DefMastership::UpdateDefVersionModifier) do
|
7
|
+
subject(:modifier) do
|
8
|
+
described_class.new(
|
9
|
+
ref_document: 'ref.adoc'
|
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: { ref_document: 'ref.adoc' })) }
|
23
|
+
it { is_expected.to(have_attributes(changes: [])) }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#do_modifications' do
|
27
|
+
let(:line_modifier) { instance_double(DefMastership::UpdateDefVersionLineModifier, 'lineModifier') }
|
28
|
+
let(:document) { instance_double(DefMastership::Document, 'document') }
|
29
|
+
let(:ref_document) { instance_double(DefMastership::Document, 'ref_document') }
|
30
|
+
|
31
|
+
before do
|
32
|
+
allow(DefMastership::UpdateDefVersionLineModifier).to(
|
33
|
+
receive(:from_config).with(ref_document: 'ref.adoc').and_return(line_modifier)
|
34
|
+
)
|
35
|
+
allow(DefMastership::Document).to(receive(:new).and_return(document, ref_document))
|
36
|
+
allow(document).to(receive(:parse_file_with_preprocessor))
|
37
|
+
allow(ref_document).to(receive(:parse_file_with_preprocessor))
|
38
|
+
allow(line_modifier).to(receive(:'document=').with(document))
|
39
|
+
allow(line_modifier).to(receive(:'ref_document=').with(ref_document))
|
40
|
+
allow(line_modifier).to(receive(:replace).with("file1 line1\n").and_return("new file1 line1\n"))
|
41
|
+
allow(line_modifier).to(receive(:replace).with('file1 line2').and_return('new file1 line2'))
|
42
|
+
allow(line_modifier).to(receive(:replace).with("file2 line1\n").and_return("new file2 line1\n"))
|
43
|
+
allow(line_modifier).to(receive(:replace).with('file2 line2').and_return('new file2 line2'))
|
44
|
+
allow(line_modifier).to(receive(:config).and_return(ref_document: 'ref.adoc'))
|
45
|
+
allow(line_modifier).to(receive(:changes).and_return([%w[from1 to1], %w[from2 to2]]))
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when detailed expectations' do
|
49
|
+
before { modifier.do_modifications(adoc_texts) }
|
50
|
+
|
51
|
+
it do
|
52
|
+
expect(DefMastership::UpdateDefVersionLineModifier).to(
|
53
|
+
have_received(:from_config).with(ref_document: 'ref.adoc')
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
it { expect(document).to(have_received(:parse_file_with_preprocessor).with('file1.adoc')) }
|
58
|
+
it { expect(document).to(have_received(:parse_file_with_preprocessor).with('file2.adoc')) }
|
59
|
+
it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('ref.adoc')) }
|
60
|
+
it { expect(line_modifier).to(have_received(:'document=').with(document)) }
|
61
|
+
it { expect(line_modifier).to(have_received(:'ref_document=').with(ref_document)) }
|
62
|
+
it { expect(line_modifier).to(have_received(:replace).with("file1 line1\n")) }
|
63
|
+
it { expect(line_modifier).to(have_received(:replace).with('file1 line2')) }
|
64
|
+
it { expect(line_modifier).to(have_received(:replace).with("file2 line1\n")) }
|
65
|
+
it { expect(line_modifier).to(have_received(:replace).with('file2 line2')) }
|
66
|
+
it { expect(line_modifier).to(have_received(:config)) }
|
67
|
+
it { expect(line_modifier).to(have_received(:changes)) }
|
68
|
+
it { is_expected.to(have_attributes(config: { ref_document: 'ref.adoc' })) }
|
69
|
+
it { is_expected.to(have_attributes(changes: [%w[from1 to1], %w[from2 to2]])) }
|
70
|
+
end
|
71
|
+
|
72
|
+
it do
|
73
|
+
expected_adoc = {
|
74
|
+
'file1.adoc' => "new file1 line1\nnew file1 line2",
|
75
|
+
'file2.adoc' => "new file2 line1\nnew file2 line2"
|
76
|
+
}
|
77
|
+
expect(modifier.do_modifications(adoc_texts)).to(eq(expected_adoc))
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: defmastership
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jérôme Arbez-Gindre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aruba
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.5'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.5'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rubocop-rspec
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,32 +193,53 @@ files:
|
|
179
193
|
- defmastership.gemspec
|
180
194
|
- defmastership.rdoc
|
181
195
|
- features/changeref.feature
|
196
|
+
- features/definition_checksum.feature
|
197
|
+
- features/definition_version.feature
|
182
198
|
- features/defmastership.feature
|
183
199
|
- features/export.feature
|
200
|
+
- features/modify.feature
|
201
|
+
- features/rename_included_files.feature
|
184
202
|
- features/step_definitions/defmastership_steps.rb
|
185
203
|
- features/support/env.rb
|
186
204
|
- lib/defmastership.rb
|
187
|
-
- lib/defmastership/
|
205
|
+
- lib/defmastership/batch_modifier.rb
|
206
|
+
- lib/defmastership/change_ref_line_modifier.rb
|
207
|
+
- lib/defmastership/change_ref_modifier.rb
|
188
208
|
- lib/defmastership/comment_filter.rb
|
189
209
|
- lib/defmastership/constants.rb
|
190
210
|
- lib/defmastership/csv_formatter.rb
|
191
211
|
- lib/defmastership/csv_formatter_body.rb
|
192
212
|
- lib/defmastership/csv_formatter_header.rb
|
193
213
|
- lib/defmastership/definition.rb
|
214
|
+
- lib/defmastership/definition_parser.rb
|
194
215
|
- lib/defmastership/document.rb
|
195
|
-
- lib/defmastership/
|
196
|
-
- lib/defmastership/
|
216
|
+
- lib/defmastership/filters.rb
|
217
|
+
- lib/defmastership/line_modifier_base.rb
|
218
|
+
- lib/defmastership/modifier_base.rb
|
219
|
+
- lib/defmastership/rename_included_files_line_modifier.rb
|
220
|
+
- lib/defmastership/rename_included_files_modifier.rb
|
221
|
+
- lib/defmastership/update_def_checksum_line_modifier.rb
|
222
|
+
- lib/defmastership/update_def_checksum_modifier.rb
|
223
|
+
- lib/defmastership/update_def_version_line_modifier.rb
|
224
|
+
- lib/defmastership/update_def_version_modifier.rb
|
197
225
|
- lib/defmastership/version.rb
|
198
226
|
- spec/spec_helper.rb
|
199
|
-
- spec/unit/defmastership/
|
227
|
+
- spec/unit/defmastership/batch_modifier_spec.rb
|
228
|
+
- spec/unit/defmastership/change_ref_line_modifier_spec.rb
|
229
|
+
- spec/unit/defmastership/change_ref_modifier_spec.rb
|
200
230
|
- spec/unit/defmastership/comment_filter_spec.rb
|
201
231
|
- spec/unit/defmastership/csv_formatter_body_spec.rb
|
202
232
|
- spec/unit/defmastership/csv_formatter_header_spec.rb
|
203
233
|
- spec/unit/defmastership/csv_formatter_spec.rb
|
234
|
+
- spec/unit/defmastership/definition_parser_spec.rb
|
204
235
|
- spec/unit/defmastership/definition_spec.rb
|
205
236
|
- spec/unit/defmastership/document_spec.rb
|
206
|
-
- spec/unit/defmastership/
|
207
|
-
- spec/unit/defmastership/
|
237
|
+
- spec/unit/defmastership/rename_included_files_line_modifier_spec.rb
|
238
|
+
- spec/unit/defmastership/rename_included_files_modifier_spec.rb
|
239
|
+
- spec/unit/defmastership/update_def_checksum_line_modifier_spec.rb
|
240
|
+
- spec/unit/defmastership/update_def_checksum_modifier_spec.rb
|
241
|
+
- spec/unit/defmastership/update_def_version_line_modifier_spec.rb
|
242
|
+
- spec/unit/defmastership/update_def_version_modifier_spec.rb
|
208
243
|
- spec/unit/defmastership_spec.rb
|
209
244
|
homepage: https://gitlab.com/jjag/defmastership/
|
210
245
|
licenses:
|
@@ -229,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
264
|
- !ruby/object:Gem::Version
|
230
265
|
version: '0'
|
231
266
|
requirements: []
|
232
|
-
rubygems_version: 3.2.
|
267
|
+
rubygems_version: 3.2.5
|
233
268
|
signing_key:
|
234
269
|
specification_version: 4
|
235
270
|
summary: Handling of references and definitions with asciidoctor
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module DefMastership
|
5
|
-
# Change references from temporary to definitive with multiple RefChangers
|
6
|
-
class BatchChanger
|
7
|
-
attr_reader :refchangers
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
@refchangers = {}
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.from_h(hash)
|
14
|
-
new.from_h(hash)
|
15
|
-
end
|
16
|
-
|
17
|
-
def from_h(hash)
|
18
|
-
@refchangers =
|
19
|
-
hash.transform_values do |value|
|
20
|
-
DefMastership::RefChanger.from_h(value)
|
21
|
-
end
|
22
|
-
self
|
23
|
-
end
|
24
|
-
|
25
|
-
def to_h
|
26
|
-
@refchangers.transform_values(&:to_h)
|
27
|
-
end
|
28
|
-
|
29
|
-
def replace(symb, line)
|
30
|
-
@refchangers.reduce(line) do |res_line, (_, refchanger)|
|
31
|
-
refchanger.public_send("replace_#{symb}".to_sym, res_line)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def changes
|
36
|
-
@refchangers.reduce([]) do |all_changes, (_, refchanger)|
|
37
|
-
all_changes + refchanger.changes
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module DefMastership
|
5
|
-
# Change all refs of a given project
|
6
|
-
class ProjectRefChanger
|
7
|
-
attr_reader :yaml_config, :adoc_texts, :changes
|
8
|
-
|
9
|
-
def initialize(yaml_config, adoc_texts)
|
10
|
-
@yaml_config = yaml_config
|
11
|
-
@adoc_texts = adoc_texts
|
12
|
-
end
|
13
|
-
|
14
|
-
def replace_all
|
15
|
-
batch = BatchChanger.from_h(@yaml_config)
|
16
|
-
|
17
|
-
@adoc_texts =
|
18
|
-
%i[refdef irefs].reduce(@adoc_texts) do |texts, method|
|
19
|
-
texts.transform_values do |text|
|
20
|
-
text.lines.map { |line| batch.replace(method, line) }.join
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
@yaml_config = batch.to_h.to_yaml
|
25
|
-
@changes = batch.changes
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require('defmastership')
|
5
|
-
|
6
|
-
RSpec.describe(DefMastership::BatchChanger) do
|
7
|
-
subject(:batchchanger) { described_class.new }
|
8
|
-
|
9
|
-
describe '.new' do
|
10
|
-
it { is_expected.not_to(be(nil)) }
|
11
|
-
it { is_expected.to(have_attributes(refchangers: {})) }
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '.from_h' do
|
15
|
-
before do
|
16
|
-
allow(DefMastership::RefChanger).to(receive(:from_h).once
|
17
|
-
.with(:whatever_a).and_return(:toto_a))
|
18
|
-
end
|
19
|
-
|
20
|
-
it { expect(described_class.from_h(a: :whatever_a)).not_to(be(nil)) }
|
21
|
-
|
22
|
-
it {
|
23
|
-
batchchanger = described_class.from_h(a: :whatever_a)
|
24
|
-
expect(batchchanger).to(have_attributes(refchangers: { a: :toto_a }))
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#from_h' do
|
29
|
-
before do
|
30
|
-
allow(DefMastership::RefChanger).to(receive(:from_h).with(:whatever_a).and_return(:one))
|
31
|
-
allow(DefMastership::RefChanger).to(receive(:from_h).with(:whatever_b).and_return(:two))
|
32
|
-
batchchanger.from_h(a: :whatever_a, b: :whatever_b)
|
33
|
-
end
|
34
|
-
|
35
|
-
it { expect(DefMastership::RefChanger).to(have_received(:from_h).with(:whatever_a)) }
|
36
|
-
|
37
|
-
it { expect(DefMastership::RefChanger).to(have_received(:from_h).with(:whatever_b)) }
|
38
|
-
|
39
|
-
it { expect(batchchanger).to(have_attributes(refchangers: { a: :one, b: :two })) }
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '#to_h' do
|
43
|
-
subject(:batchchanger) { described_class.from_h(a: :a, b: :b) }
|
44
|
-
|
45
|
-
let(:refchanger_a) { instance_double(DefMastership::RefChanger, 'refchanger_a') }
|
46
|
-
let(:refchanger_b) { instance_double(DefMastership::RefChanger, 'refchanger_b') }
|
47
|
-
|
48
|
-
before do
|
49
|
-
allow(DefMastership::RefChanger).to(receive(:from_h).with(:a).and_return(refchanger_a))
|
50
|
-
allow(DefMastership::RefChanger).to(receive(:from_h).with(:b).and_return(refchanger_b))
|
51
|
-
allow(refchanger_a).to(receive(:to_h).and_return(a_a: :a_a))
|
52
|
-
allow(refchanger_b).to(receive(:to_h).and_return(b_b: :b_b))
|
53
|
-
batchchanger.to_h
|
54
|
-
end
|
55
|
-
|
56
|
-
it { expect(refchanger_a).to(have_received(:to_h)) }
|
57
|
-
|
58
|
-
it { expect(refchanger_b).to(have_received(:to_h)) }
|
59
|
-
|
60
|
-
it do
|
61
|
-
expect(batchchanger.to_h).to(eq(
|
62
|
-
a: { a_a: :a_a },
|
63
|
-
b: { b_b: :b_b }
|
64
|
-
))
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe 'replace' do
|
69
|
-
subject(:batchchanger) { described_class.from_h(a: :a, b: :b) }
|
70
|
-
|
71
|
-
let(:refchanger_a) { instance_double(DefMastership::RefChanger, 'refchanger_a') }
|
72
|
-
let(:refchanger_b) { instance_double(DefMastership::RefChanger, 'refchanger_b') }
|
73
|
-
|
74
|
-
before do
|
75
|
-
allow(DefMastership::RefChanger).to(receive(:from_h).with(:a).and_return(refchanger_a))
|
76
|
-
allow(DefMastership::RefChanger).to(receive(:from_h).with(:b).and_return(refchanger_b))
|
77
|
-
allow(refchanger_a).to(receive(:public_send).with(:replace_toto, 'a line').and_return('b line'))
|
78
|
-
allow(refchanger_b).to(receive(:public_send).with(:replace_toto, 'b line').and_return('c line'))
|
79
|
-
batchchanger.replace(:toto, 'a line')
|
80
|
-
end
|
81
|
-
|
82
|
-
it { expect(refchanger_a).to(have_received(:public_send).with(:replace_toto, 'a line')) }
|
83
|
-
|
84
|
-
it { expect(refchanger_b).to(have_received(:public_send).with(:replace_toto, 'b line')) }
|
85
|
-
|
86
|
-
it { expect(batchchanger.replace(:toto, 'a line')).to(eq('c line')) }
|
87
|
-
end
|
88
|
-
|
89
|
-
describe 'changes' do
|
90
|
-
subject(:batchchanger) { described_class.from_h(a: :a, b: :b) }
|
91
|
-
|
92
|
-
let(:refchanger_a) { instance_double(DefMastership::RefChanger, 'refchanger_a') }
|
93
|
-
let(:refchanger_b) { instance_double(DefMastership::RefChanger, 'refchanger_b') }
|
94
|
-
|
95
|
-
before do
|
96
|
-
allow(DefMastership::RefChanger).to(receive(:from_h).with(:a).and_return(refchanger_a))
|
97
|
-
allow(DefMastership::RefChanger).to(receive(:from_h).with(:b).and_return(refchanger_b))
|
98
|
-
allow(refchanger_a).to(receive(:changes).and_return([%w[a1 a2]]))
|
99
|
-
allow(refchanger_b).to(receive(:changes).and_return([%w[b1 b2]]))
|
100
|
-
end
|
101
|
-
|
102
|
-
it do
|
103
|
-
expect(batchchanger.changes).to(eq([
|
104
|
-
%w[a1 a2],
|
105
|
-
%w[b1 b2]
|
106
|
-
]))
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require('defmastership')
|
5
|
-
require('yaml')
|
6
|
-
|
7
|
-
RSpec.describe(DefMastership::ProjectRefChanger) do
|
8
|
-
subject(:projectrefchanger) do
|
9
|
-
described_class.new(
|
10
|
-
'fake yaml config',
|
11
|
-
{
|
12
|
-
'file1.adoc' => "file1 line1\nfile1 line2",
|
13
|
-
'file2.adoc' => "file2 line1\nfile2 line2"
|
14
|
-
}
|
15
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '.new' do
|
19
|
-
it { is_expected.not_to(be(nil)) }
|
20
|
-
it { is_expected.to(have_attributes(yaml_config: 'fake yaml config')) }
|
21
|
-
|
22
|
-
it do
|
23
|
-
expect(projectrefchanger).to(have_attributes(adoc_texts:
|
24
|
-
{
|
25
|
-
'file1.adoc' => "file1 line1\nfile1 line2",
|
26
|
-
'file2.adoc' => "file2 line1\nfile2 line2"
|
27
|
-
}))
|
28
|
-
end
|
29
|
-
|
30
|
-
it { is_expected.to(have_attributes(changes: nil)) }
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '#replace_all' do
|
34
|
-
let(:batch_changer) { instance_double(DefMastership::BatchChanger, 'batch_changer') }
|
35
|
-
let(:config_hash) { instance_double(Hash, 'config_hash') }
|
36
|
-
|
37
|
-
before do
|
38
|
-
allow(DefMastership::BatchChanger).to(receive(:from_h).with('fake yaml config').and_return(batch_changer))
|
39
|
-
allow(batch_changer).to(receive(:replace).with(:refdef, "file1 line1\n").and_return("new file1 line1\n"))
|
40
|
-
allow(batch_changer).to(receive(:replace).with(:refdef, 'file1 line2').and_return('new file1 line2'))
|
41
|
-
allow(batch_changer).to(receive(:replace).with(:refdef, "file2 line1\n").and_return("new file2 line1\n"))
|
42
|
-
allow(batch_changer).to(receive(:replace).with(:refdef, 'file2 line2').and_return('new file2 line2'))
|
43
|
-
allow(batch_changer).to(receive(:replace).with(:irefs, "new file1 line1\n").and_return("new2 file1 line1\n"))
|
44
|
-
allow(batch_changer).to(receive(:replace).with(:irefs, 'new file1 line2').and_return('new2 file1 line2'))
|
45
|
-
allow(batch_changer).to(receive(:replace).with(:irefs, "new file2 line1\n").and_return("new2 file2 line1\n"))
|
46
|
-
allow(batch_changer).to(receive(:replace).with(:irefs, 'new file2 line2').and_return('new2 file2 line2'))
|
47
|
-
allow(batch_changer).to(receive(:to_h).and_return(config_hash))
|
48
|
-
allow(batch_changer).to(receive(:changes).and_return('pouet'))
|
49
|
-
allow(config_hash).to(receive(:to_yaml).with(no_args).and_return('new fake yaml config'))
|
50
|
-
projectrefchanger.replace_all
|
51
|
-
end
|
52
|
-
|
53
|
-
it { expect(DefMastership::BatchChanger).to(have_received(:from_h).with('fake yaml config')) }
|
54
|
-
|
55
|
-
it { expect(batch_changer).to(have_received(:replace).with(:refdef, "file1 line1\n")) }
|
56
|
-
it { expect(batch_changer).to(have_received(:replace).with(:refdef, 'file1 line2')) }
|
57
|
-
it { expect(batch_changer).to(have_received(:replace).with(:refdef, "file2 line1\n")) }
|
58
|
-
it { expect(batch_changer).to(have_received(:replace).with(:refdef, 'file2 line2')) }
|
59
|
-
it { expect(batch_changer).to(have_received(:replace).with(:irefs, "new file1 line1\n")) }
|
60
|
-
it { expect(batch_changer).to(have_received(:replace).with(:irefs, 'new file1 line2')) }
|
61
|
-
it { expect(batch_changer).to(have_received(:replace).with(:irefs, "new file2 line1\n")) }
|
62
|
-
it { expect(batch_changer).to(have_received(:replace).with(:irefs, 'new file2 line2')) }
|
63
|
-
|
64
|
-
it { expect(batch_changer).to(have_received(:to_h)) }
|
65
|
-
|
66
|
-
it { expect(config_hash).to(have_received(:to_yaml).with(no_args)) }
|
67
|
-
|
68
|
-
it { expect(projectrefchanger).to(have_attributes(yaml_config: 'new fake yaml config')) }
|
69
|
-
|
70
|
-
it do
|
71
|
-
expect(projectrefchanger).to(have_attributes(adoc_texts: {
|
72
|
-
'file1.adoc' => "new2 file1 line1\nnew2 file1 line2",
|
73
|
-
'file2.adoc' => "new2 file2 line1\nnew2 file2 line2"
|
74
|
-
}))
|
75
|
-
end
|
76
|
-
|
77
|
-
it { expect(batch_changer).to(have_received(:changes)) }
|
78
|
-
it { expect(projectrefchanger).to(have_attributes(changes: 'pouet')) }
|
79
|
-
end
|
80
|
-
end
|