defmastership 1.0.1 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.gitlab-ci.yml +20 -0
  4. data/.rubocop.yml +5 -4
  5. data/Gemfile +1 -0
  6. data/LICENSE +22 -0
  7. data/Rakefile +2 -2
  8. data/bin/defmastership +25 -17
  9. data/cucumber.yml +2 -0
  10. data/defmastership.gemspec +18 -11
  11. data/features/changeref.feature +82 -129
  12. data/features/export.feature +102 -31
  13. data/features/modify.feature +143 -0
  14. data/features/rename_included_files.feature +121 -0
  15. data/features/step_definitions/defmastership_steps.rb +1 -0
  16. data/features/support/env.rb +1 -0
  17. data/lib/defmastership.rb +12 -3
  18. data/lib/defmastership/batch_modifier.rb +33 -0
  19. data/lib/defmastership/{ref_changer.rb → change_ref_line_modifier.rb} +19 -35
  20. data/lib/defmastership/change_ref_modifier.rb +15 -0
  21. data/lib/defmastership/comment_filter.rb +1 -0
  22. data/lib/defmastership/constants.rb +15 -1
  23. data/lib/defmastership/csv_formatter.rb +19 -18
  24. data/lib/defmastership/csv_formatter_body.rb +12 -6
  25. data/lib/defmastership/csv_formatter_header.rb +12 -10
  26. data/lib/defmastership/definition.rb +12 -0
  27. data/lib/defmastership/definition_parser.rb +46 -0
  28. data/lib/defmastership/document.rb +44 -75
  29. data/lib/defmastership/filters.rb +30 -0
  30. data/lib/defmastership/line_modifier_base.rb +29 -0
  31. data/lib/defmastership/modifier_base.rb +29 -0
  32. data/lib/defmastership/rename_included_files_line_modifier.rb +126 -0
  33. data/lib/defmastership/rename_included_files_modifier.rb +30 -0
  34. data/lib/defmastership/version.rb +2 -1
  35. data/spec/spec_helper.rb +2 -0
  36. data/spec/unit/defmastership/batch_modifier_spec.rb +115 -0
  37. data/spec/unit/defmastership/{ref_changer_spec.rb → change_ref_line_modifier_spec.rb} +49 -26
  38. data/spec/unit/defmastership/change_ref_modifier_spec.rb +76 -0
  39. data/spec/unit/defmastership/comment_filter_spec.rb +9 -4
  40. data/spec/unit/defmastership/csv_formatter_body_spec.rb +62 -37
  41. data/spec/unit/defmastership/csv_formatter_header_spec.rb +47 -22
  42. data/spec/unit/defmastership/csv_formatter_spec.rb +67 -105
  43. data/spec/unit/defmastership/definition_parser_spec.rb +63 -0
  44. data/spec/unit/defmastership/definition_spec.rb +31 -4
  45. data/spec/unit/defmastership/document_spec.rb +113 -35
  46. data/spec/unit/defmastership/rename_included_files_line_modifier_spec.rb +203 -0
  47. data/spec/unit/defmastership/rename_included_files_modifier_spec.rb +67 -0
  48. data/spec/unit/defmastership_spec.rb +1 -0
  49. metadata +44 -17
  50. data/Gemfile.lock +0 -140
  51. data/lib/defmastership/batch_changer.rb +0 -40
  52. data/lib/defmastership/project_ref_changer.rb +0 -27
  53. data/spec/unit/defmastership/batch_changer_spec.rb +0 -108
  54. data/spec/unit/defmastership/project_ref_changer_spec.rb +0 -79
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::RefChanger) do
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 '.from_h' do
18
+ describe '.from_config' do
18
19
  subject(:refchanger) do
19
- described_class.from_h(
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 '#from_h' do
33
+ describe '#from_config' do
33
34
  before do
34
- refchanger.from_h(
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 '#to_h' do
49
+ describe '#config' do
49
50
  context 'when not initalized' do
50
51
  it do
51
- expect(refchanger.to_h).to(include(
52
- from_regexp: '',
53
- to_template: '',
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.from_h(
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.to_h).to(include(from_regexp: '')) }
68
- it { expect(refchanger.to_h).to(include(to_template: '')) }
69
- it { expect(refchanger.to_h).to(include(next_ref: 1256)) }
70
- it { expect(refchanger.to_h).to(include(user_defined_attribute: 'Tadaam')) }
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 '#replace_definitions' do
73
+ describe '#replace_def' do
75
74
  context 'when really simple rule' do
76
75
  before do
77
- refchanger.from_h(
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.from_h(
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.from_h(
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.from_h(
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.from_h(
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.from_h(
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(refchanger.replace_irefs('defs:iref[TOTO-TEMP123] ' \
201
- 'defs:iref[TITI-TEMP421] bla'))
202
- .to(eq('defs:iref[TOTO-0132] defs:iref[TITI-0133] bla'))
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
@@ -1,3 +1,4 @@
1
+ # Copyright (c) 2020 Jerome Arbez-Gindre
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require('defmastership')
@@ -74,8 +75,10 @@ RSpec.describe(DefMastership::CommentFilter) do
74
75
  end
75
76
 
76
77
  before do
77
- allow(DefMastership).to(receive(:comment_filter)
78
- .and_return(comment_filter))
78
+ allow(DefMastership).to(
79
+ receive(:comment_filter)
80
+ .and_return(comment_filter)
81
+ )
79
82
  end
80
83
 
81
84
  context 'when not .commented?' do
@@ -93,8 +96,10 @@ RSpec.describe(DefMastership::CommentFilter) do
93
96
 
94
97
  context 'when .commented?' do
95
98
  before do
96
- allow(comment_filter).to(receive(:accept?)
97
- .with('blabla').and_return(false))
99
+ allow(comment_filter).to(
100
+ receive(:accept?)
101
+ .with('blabla').and_return(false)
102
+ )
98
103
  end
99
104
 
100
105
  it do
@@ -1,3 +1,4 @@
1
+ # Copyright (c) 2020 Jerome Arbez-Gindre
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require('defmastership')
@@ -12,12 +13,13 @@ RSpec.describe(DefMastership::CSVFormatterBody) do
12
13
  it { is_expected.not_to(be(nil)) }
13
14
  end
14
15
 
15
- describe '#fixed_body' do
16
+ describe '#fixed' do
16
17
  before do
17
18
  allow(definition).to(receive(:type).with(no_args).and_return('a'))
18
19
  allow(definition).to(receive(:reference).with(no_args).and_return('b'))
19
20
  allow(definition).to(receive(:value).with(no_args).and_return('c'))
20
- formatter.fixed_body(definition)
21
+ allow(definition).to(receive(:sha256).with(no_args).and_return('d'))
22
+ formatter.fixed(definition)
21
23
  end
22
24
 
23
25
  it { expect(definition).to(have_received(:type).with(no_args)) }
@@ -26,19 +28,43 @@ RSpec.describe(DefMastership::CSVFormatterBody) do
26
28
 
27
29
  it { expect(definition).to(have_received(:value).with(no_args)) }
28
30
 
29
- it { expect(formatter.fixed_body(definition)).to(eq(%w[a b c])) }
31
+ it { expect(definition).to(have_received(:sha256).with(no_args)) }
32
+
33
+ it { expect(formatter.fixed(definition)).to(eq(%w[a b c d])) }
34
+ end
35
+
36
+ describe '#wrong_explicit_checksum' do
37
+ context 'when no wrong_explicit checksum' do
38
+ before do
39
+ allow(definition).to(receive(:wrong_explicit_checksum).with(no_args).and_return(nil))
40
+ formatter.wrong_explicit_checksum(definition)
41
+ end
42
+
43
+ it { expect(definition).to(have_received(:wrong_explicit_checksum).with(no_args)) }
44
+
45
+ it { expect(formatter.wrong_explicit_checksum(definition)).to(eq([''])) }
46
+ end
47
+
48
+ context 'when explicit checksum' do
49
+ before do
50
+ allow(definition).to(receive(:wrong_explicit_checksum).with(no_args).and_return('ab12'))
51
+ formatter.wrong_explicit_checksum(definition)
52
+ end
53
+
54
+ it { expect(formatter.wrong_explicit_checksum(definition)).to(eq(['ab12'])) }
55
+ end
30
56
  end
31
57
 
32
- describe '#labels_body' do
58
+ describe '#labels' do
33
59
  context 'when no labels on document' do
34
60
  before do
35
61
  allow(document).to(receive(:labels).with(no_args).and_return([]))
36
- formatter.labels_body(definition)
62
+ formatter.labels(definition)
37
63
  end
38
64
 
39
65
  it { expect(document).to(have_received(:labels).once.with(no_args)) }
40
66
 
41
- it { expect(formatter.labels_body(definition)).to(eq([])) }
67
+ it { expect(formatter.labels(definition)).to(eq([])) }
42
68
  end
43
69
 
44
70
  context 'when labels on document' do
@@ -47,66 +73,66 @@ RSpec.describe(DefMastership::CSVFormatterBody) do
47
73
  context 'when no labels on definition' do
48
74
  before do
49
75
  allow(definition).to(receive(:labels).with(no_args).and_return([]))
50
- formatter.labels_body(definition)
76
+ formatter.labels(definition)
51
77
  end
52
78
 
53
79
  it { expect(definition).to(have_received(:labels).once.with(no_args)) }
54
80
 
55
- it { expect(formatter.labels_body(definition)).to(eq([''])) }
81
+ it { expect(formatter.labels(definition)).to(eq([''])) }
56
82
  end
57
83
 
58
84
  context 'when labels on definition' do
59
85
  before do
60
86
  allow(definition).to(receive(:labels).with(no_args).and_return(%w[toto tutu]))
61
- formatter.labels_body(definition)
87
+ formatter.labels(definition)
62
88
  end
63
89
 
64
90
  it { expect(definition).to(have_received(:labels).once.with(no_args)) }
65
91
 
66
- it { expect(formatter.labels_body(definition)).to(eq(["toto\ntutu"])) }
92
+ it { expect(formatter.labels(definition)).to(eq(["toto\ntutu"])) }
67
93
  end
68
94
  end
69
95
  end
70
96
 
71
- describe '#eref_body' do
97
+ describe '#eref' do
72
98
  context 'when no eref on the document' do
73
99
  before do
74
100
  allow(document).to(receive(:eref).with(no_args).and_return({}))
75
- formatter.eref_body(definition)
101
+ formatter.eref(definition)
76
102
  end
77
103
 
78
104
  it { expect(document).to(have_received(:eref).with(no_args)) }
79
105
 
80
- it { expect(formatter.eref_body(nil)).to(eq([])) }
106
+ it { expect(formatter.eref(nil)).to(eq([])) }
81
107
  end
82
108
 
83
109
  context 'when eref on the document' do
84
110
  before do
85
- allow(document).to(receive(:eref).with(no_args).and_return(
86
- a: 'whatever',
87
- b: 'whatever',
88
- c: 'whatever'
89
- ))
111
+ allow(document).to(
112
+ receive(:eref).with(no_args).and_return(
113
+ a: 'whatever', b: 'whatever', c: 'whatever'
114
+ )
115
+ )
90
116
  allow(definition).to(receive(:eref).with(no_args).and_return(a: %w[A B], b: [], c: ['C']))
91
- formatter.eref_body(definition)
117
+ formatter.eref(definition)
92
118
  end
93
119
 
94
120
  it { expect(definition).to(have_received(:eref).exactly(3).times.with(no_args)) }
95
121
 
96
- it { expect(formatter.eref_body(definition)).to(eq(["A\nB", '', 'C'])) }
122
+ it { expect(formatter.eref(definition)).to(eq(["A\nB", '', 'C'])) }
97
123
  end
98
124
  end
99
125
 
100
- describe '#iref_body' do
126
+ describe '#iref' do
101
127
  context 'when no iref on the document' do
102
128
  before do
103
129
  allow(document).to(receive(:iref).with(no_args).and_return(false))
104
- formatter.iref_body(definition)
130
+ formatter.iref(definition)
105
131
  end
106
132
 
107
133
  it { expect(document).to(have_received(:iref).with(no_args)) }
108
134
 
109
- it { expect(formatter.iref_body(definition)).to(eq([])) }
135
+ it { expect(formatter.iref(definition)).to(eq([])) }
110
136
  end
111
137
 
112
138
  context 'when iref on the document' do
@@ -115,53 +141,52 @@ RSpec.describe(DefMastership::CSVFormatterBody) do
115
141
  context 'when no iref on the definition' do
116
142
  before do
117
143
  allow(definition).to(receive(:iref).with(no_args).and_return([]))
118
- formatter.iref_body(definition)
144
+ formatter.iref(definition)
119
145
  end
120
146
 
121
147
  it { expect(definition).to(have_received(:iref).with(no_args)) }
122
148
 
123
- it { expect(formatter.iref_body(definition)).to(eq([''])) }
149
+ it { expect(formatter.iref(definition)).to(eq([''])) }
124
150
  end
125
151
 
126
152
  context 'when iref on the definition' do
127
153
  before do
128
154
  allow(definition).to(receive(:iref).with(no_args).and_return(%w[A B]))
129
- formatter.iref_body(definition)
155
+ formatter.iref(definition)
130
156
  end
131
157
 
132
158
  it { expect(definition).to(have_received(:iref).with(no_args)) }
133
159
 
134
- it { expect(formatter.iref_body(definition)).to(eq(["A\nB"])) }
160
+ it { expect(formatter.iref(definition)).to(eq(["A\nB"])) }
135
161
  end
136
162
  end
137
163
  end
138
164
 
139
- describe '#attributes_body' do
165
+ describe '#attributes' do
140
166
  context 'when no attributes on the document' do
141
167
  before do
142
168
  allow(document).to(receive(:attributes).with(no_args).and_return({}))
143
- formatter.attributes_body(definition)
169
+ formatter.attributes(definition)
144
170
  end
145
171
 
146
172
  it { expect(document).to(have_received(:attributes).with(no_args)) }
147
173
 
148
- it { expect(formatter.attributes_body(nil)).to(eq([])) }
174
+ it { expect(formatter.attributes(nil)).to(eq([])) }
149
175
  end
150
176
 
151
177
  context 'when attributes on the document' do
152
178
  before do
153
- allow(document).to(receive(:attributes).with(no_args).and_return(
154
- a: 'whatever',
155
- b: 'whatever',
156
- c: 'whatever'
157
- ))
179
+ allow(document).to(
180
+ receive(:attributes).with(no_args)
181
+ .and_return(a: 'whatever', b: 'whatever', c: 'whatever')
182
+ )
158
183
  allow(definition).to(receive(:attributes).and_return(a: 'X', b: '', c: 'Y'))
159
- formatter.attributes_body(definition)
184
+ formatter.attributes(definition)
160
185
  end
161
186
 
162
187
  it { expect(definition).to(have_received(:attributes).exactly(3).times) }
163
188
 
164
- it { expect(formatter.attributes_body(definition)).to(eq(['X', '', 'Y'])) }
189
+ it { expect(formatter.attributes(definition)).to(eq(['X', '', 'Y'])) }
165
190
  end
166
191
  end
167
192
  end