defmastership 1.0.5 → 1.0.10

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/.rubocop.yml +1 -1
  3. data/bin/defmastership +33 -22
  4. data/cucumber.yml +1 -1
  5. data/defmastership.gemspec +12 -6
  6. data/features/changeref.feature +82 -129
  7. data/features/definition_checksum.feature +298 -0
  8. data/features/definition_version.feature +204 -0
  9. data/features/export.feature +35 -34
  10. data/features/modify.feature +165 -0
  11. data/features/rename_included_files.feature +121 -0
  12. data/lib/defmastership.rb +17 -3
  13. data/lib/defmastership/batch_modifier.rb +35 -0
  14. data/lib/defmastership/{ref_changer.rb → change_ref_line_modifier.rb} +18 -35
  15. data/lib/defmastership/change_ref_modifier.rb +15 -0
  16. data/lib/defmastership/constants.rb +14 -1
  17. data/lib/defmastership/csv_formatter.rb +22 -17
  18. data/lib/defmastership/csv_formatter_body.rb +19 -11
  19. data/lib/defmastership/csv_formatter_header.rb +15 -10
  20. data/lib/defmastership/definition.rb +14 -3
  21. data/lib/defmastership/definition_parser.rb +46 -0
  22. data/lib/defmastership/document.rb +59 -85
  23. data/lib/defmastership/filters.rb +30 -0
  24. data/lib/defmastership/line_modifier_base.rb +29 -0
  25. data/lib/defmastership/modifier_base.rb +29 -0
  26. data/lib/defmastership/rename_included_files_line_modifier.rb +126 -0
  27. data/lib/defmastership/rename_included_files_modifier.rb +15 -0
  28. data/lib/defmastership/update_def_checksum_line_modifier.rb +38 -0
  29. data/lib/defmastership/update_def_checksum_modifier.rb +21 -0
  30. data/lib/defmastership/update_def_version_line_modifier.rb +58 -0
  31. data/lib/defmastership/update_def_version_modifier.rb +25 -0
  32. data/lib/defmastership/version.rb +1 -1
  33. data/spec/spec_helper.rb +1 -0
  34. data/spec/unit/defmastership/batch_modifier_spec.rb +123 -0
  35. data/spec/unit/defmastership/{ref_changer_spec.rb → change_ref_line_modifier_spec.rb} +48 -26
  36. data/spec/unit/defmastership/change_ref_modifier_spec.rb +76 -0
  37. data/spec/unit/defmastership/comment_filter_spec.rb +8 -4
  38. data/spec/unit/defmastership/csv_formatter_body_spec.rb +88 -82
  39. data/spec/unit/defmastership/csv_formatter_header_spec.rb +68 -22
  40. data/spec/unit/defmastership/csv_formatter_spec.rb +207 -109
  41. data/spec/unit/defmastership/definition_parser_spec.rb +63 -0
  42. data/spec/unit/defmastership/definition_spec.rb +45 -4
  43. data/spec/unit/defmastership/document_spec.rb +236 -35
  44. data/spec/unit/defmastership/rename_included_files_line_modifier_spec.rb +203 -0
  45. data/spec/unit/defmastership/rename_included_files_modifier_spec.rb +67 -0
  46. data/spec/unit/defmastership/update_def_checksum_line_modifier_spec.rb +78 -0
  47. data/spec/unit/defmastership/update_def_checksum_modifier_spec.rb +75 -0
  48. data/spec/unit/defmastership/update_def_version_line_modifier_spec.rb +127 -0
  49. data/spec/unit/defmastership/update_def_version_modifier_spec.rb +80 -0
  50. metadata +44 -9
  51. data/lib/defmastership/batch_changer.rb +0 -41
  52. data/lib/defmastership/project_ref_changer.rb +0 -28
  53. data/spec/unit/defmastership/batch_changer_spec.rb +0 -109
  54. data/spec/unit/defmastership/project_ref_changer_spec.rb +0 -80
@@ -3,7 +3,7 @@
3
3
 
4
4
  require('defmastership')
5
5
 
6
- RSpec.describe(DefMastership::RefChanger) do
6
+ RSpec.describe(DefMastership::ChangeRefLineModifier) do
7
7
  subject(:refchanger) { described_class.new }
8
8
 
9
9
  describe '.new' do
@@ -15,9 +15,9 @@ RSpec.describe(DefMastership::RefChanger) do
15
15
  it { expect { refchanger.user_defined_attribute }.to(raise_error(NoMethodError)) }
16
16
  end
17
17
 
18
- describe '.from_h' do
18
+ describe '.from_config' do
19
19
  subject(:refchanger) do
20
- described_class.from_h(
20
+ described_class.from_config(
21
21
  from_regexp: 'Whatever.+',
22
22
  to_template: 'Whatever',
23
23
  next_ref: 17
@@ -30,9 +30,9 @@ RSpec.describe(DefMastership::RefChanger) do
30
30
  it { is_expected.to(have_attributes(next_ref: 17)) }
31
31
  end
32
32
 
33
- describe '#from_h' do
33
+ describe '#from_config' do
34
34
  before do
35
- refchanger.from_h(
35
+ refchanger.from_config(
36
36
  from_regexp: 'Whatever.+',
37
37
  to_template: 'Whatever',
38
38
  next_ref: 17,
@@ -46,36 +46,34 @@ RSpec.describe(DefMastership::RefChanger) do
46
46
  it { is_expected.to(have_attributes(user_defined_attribute: 'Tadaam')) }
47
47
  end
48
48
 
49
- describe '#to_h' do
49
+ describe '#config' do
50
50
  context 'when not initalized' do
51
51
  it do
52
- expect(refchanger.to_h).to(include(
53
- from_regexp: '',
54
- to_template: '',
55
- next_ref: 0
56
- ))
52
+ expect(refchanger.config).to(
53
+ include(from_regexp: '', to_template: '', next_ref: 0)
54
+ )
57
55
  end
58
56
  end
59
57
 
60
58
  context 'when initalized with additionnal keys' do
61
59
  before do
62
- refchanger.from_h(
60
+ refchanger.from_config(
63
61
  next_ref: 1256,
64
62
  user_defined_attribute: 'Tadaam'
65
63
  )
66
64
  end
67
65
 
68
- it { expect(refchanger.to_h).to(include(from_regexp: '')) }
69
- it { expect(refchanger.to_h).to(include(to_template: '')) }
70
- it { expect(refchanger.to_h).to(include(next_ref: 1256)) }
71
- 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')) }
72
70
  end
73
71
  end
74
72
 
75
- describe '#replace_definitions' do
73
+ describe '#replace_def' do
76
74
  context 'when really simple rule' do
77
75
  before do
78
- refchanger.from_h(
76
+ refchanger.from_config(
79
77
  from_regexp: 'TEMP',
80
78
  to_template: 'TUTU'
81
79
  )
@@ -98,7 +96,7 @@ RSpec.describe(DefMastership::RefChanger) do
98
96
 
99
97
  context 'when template is variable' do
100
98
  before do
101
- refchanger.from_h(
99
+ refchanger.from_config(
102
100
  from_regexp: 'TEMP',
103
101
  to_template: 'TOTO-%<next_ref>04d',
104
102
  next_ref: 124
@@ -118,7 +116,7 @@ RSpec.describe(DefMastership::RefChanger) do
118
116
 
119
117
  context 'when capture group in regexp' do
120
118
  before do
121
- refchanger.from_h(
119
+ refchanger.from_config(
122
120
  from_regexp: '(?<cg>TOTO|TITI)-TEMP[\d]*',
123
121
  to_template: '%<cg>s-%<next_ref>04d',
124
122
  next_ref: 132
@@ -145,7 +143,7 @@ RSpec.describe(DefMastership::RefChanger) do
145
143
 
146
144
  context 'when definition is in literal block' do
147
145
  before do
148
- refchanger.from_h(
146
+ refchanger.from_config(
149
147
  from_regexp: 'TEMP',
150
148
  to_template: 'TUTU'
151
149
  )
@@ -160,7 +158,7 @@ RSpec.describe(DefMastership::RefChanger) do
160
158
 
161
159
  context 'when defintion is after literal block' do
162
160
  before do
163
- refchanger.from_h(
161
+ refchanger.from_config(
164
162
  from_regexp: 'TEMP',
165
163
  to_template: 'TUTU'
166
164
  )
@@ -178,7 +176,7 @@ RSpec.describe(DefMastership::RefChanger) do
178
176
 
179
177
  describe '#replace_irefs' do
180
178
  before do
181
- refchanger.from_h(
179
+ refchanger.from_config(
182
180
  from_regexp: '(?<cg>TOTO|TITI)-TEMP[\d]*',
183
181
  to_template: '%<cg>s-%<next_ref>04d',
184
182
  next_ref: 132
@@ -198,9 +196,33 @@ RSpec.describe(DefMastership::RefChanger) do
198
196
  end
199
197
 
200
198
  it do
201
- expect(refchanger.replace_irefs('defs:iref[TOTO-TEMP123] ' \
202
- 'defs:iref[TITI-TEMP421] bla'))
203
- .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]'))
204
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)) }
205
227
  end
206
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
@@ -75,8 +75,10 @@ RSpec.describe(DefMastership::CommentFilter) do
75
75
  end
76
76
 
77
77
  before do
78
- allow(DefMastership).to(receive(:comment_filter)
79
- .and_return(comment_filter))
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(receive(:accept?)
98
- .with('blabla').and_return(false))
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 '#fixed_body' do
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
- formatter.fixed_body(definition)
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.fixed_body(definition)).to(eq(%w[a b c])) }
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 '#labels_body' do
34
- context 'when no labels on document' do
32
+ describe '#wrong_explicit_checksum' do
33
+ context 'when no wrong_explicit checksum' do
35
34
  before do
36
- allow(document).to(receive(:labels).with(no_args).and_return([]))
37
- formatter.labels_body(definition)
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(document).to(have_received(:labels).once.with(no_args)) }
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 labels on document' do
46
- before { allow(document).to(receive(:labels).with(no_args).and_return(['whatever'])) }
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
- context 'when no labels on definition' do
49
- before do
50
- allow(definition).to(receive(:labels).with(no_args).and_return([]))
51
- formatter.labels_body(definition)
52
- end
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
- it { expect(definition).to(have_received(:labels).once.with(no_args)) }
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
- it { expect(formatter.labels_body(definition)).to(eq([''])) }
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
- context 'when labels on definition' do
60
- before do
61
- allow(definition).to(receive(:labels).with(no_args).and_return(%w[toto tutu]))
62
- formatter.labels_body(definition)
63
- end
70
+ it { expect(formatter.explicit_version(definition)).to(eq(['ab12'])) }
71
+ end
72
+ end
64
73
 
65
- it { expect(definition).to(have_received(:labels).once.with(no_args)) }
74
+ describe '#labels' do
75
+ before { allow(document).to(receive(:labels).with(no_args).and_return(['whatever'])) }
66
76
 
67
- it { expect(formatter.labels_body(definition)).to(eq(["toto\ntutu"])) }
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 '#eref_body' do
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.eref_body(definition)
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(receive(:eref).with(no_args).and_return(
87
- a: 'whatever',
88
- b: 'whatever',
89
- c: 'whatever'
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.eref_body(definition)
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 '#iref_body' do
102
- context 'when no iref on the document' do
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(document).to(receive(:iref).with(no_args).and_return(false))
105
- formatter.iref_body(definition)
130
+ allow(definition).to(receive(:iref).with(no_args).and_return([]))
131
+ formatter.iref(definition)
106
132
  end
107
133
 
108
- it { expect(document).to(have_received(:iref).with(no_args)) }
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 document' do
114
- before { allow(document).to(receive(:iref).with(no_args).and_return(true)) }
115
-
116
- context 'when no iref on the definition' do
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
- context 'when iref on the definition' do
128
- before do
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 '#attributes_body' do
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.attributes_body(definition)
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(receive(:attributes).with(no_args).and_return(
155
- a: 'whatever',
156
- b: 'whatever',
157
- c: 'whatever'
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.attributes_body(definition)
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