defmastership 1.0.16 → 1.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.gitlab-ci.yml +50 -7
  4. data/.rubocop.yml +14 -6
  5. data/Gemfile +51 -1
  6. data/Rakefile +16 -47
  7. data/bin/defmastership +12 -9
  8. data/config/mutant.yml +23 -3
  9. data/defmastership.gemspec +22 -27
  10. data/features/definition_checksum.feature +31 -1
  11. data/features/export.feature +43 -1
  12. data/features/rename_included_files.feature +28 -0
  13. data/lib/defmastership/batch_modifier.rb +17 -12
  14. data/lib/defmastership/change_ref_modifier.rb +89 -5
  15. data/lib/defmastership/comment_filter.rb +1 -1
  16. data/lib/defmastership/constants.rb +5 -4
  17. data/lib/defmastership/csv_formatter.rb +20 -16
  18. data/lib/defmastership/csv_formatter_body.rb +18 -15
  19. data/lib/defmastership/csv_formatter_header.rb +1 -1
  20. data/lib/defmastership/definition.rb +58 -19
  21. data/lib/defmastership/document.rb +109 -74
  22. data/lib/defmastership/matching_line.rb +17 -0
  23. data/lib/defmastership/modifier.rb +42 -0
  24. data/lib/defmastership/modifier_factory.rb +12 -0
  25. data/lib/defmastership/parsing_state.rb +15 -9
  26. data/lib/defmastership/rename_included_files_modifier.rb +172 -5
  27. data/lib/defmastership/set_join_hack.rb +11 -0
  28. data/lib/defmastership/update_def_checksum_modifier.rb +8 -13
  29. data/lib/defmastership/update_def_modifier.rb +49 -0
  30. data/lib/defmastership/update_def_version_modifier.rb +56 -15
  31. data/lib/defmastership/version.rb +1 -1
  32. data/lib/defmastership.rb +7 -17
  33. data/spec/spec_helper.rb +4 -2
  34. data/spec/unit/{defmastership → def_mastership}/batch_modifier_spec.rb +42 -39
  35. data/spec/unit/{defmastership/change_ref_line_modifier_spec.rb → def_mastership/change_ref_modifier_spec.rb} +44 -66
  36. data/spec/unit/{defmastership → def_mastership}/csv_formatter_body_spec.rb +61 -32
  37. data/spec/unit/{defmastership → def_mastership}/csv_formatter_header_spec.rb +2 -2
  38. data/spec/unit/{defmastership → def_mastership}/csv_formatter_spec.rb +81 -86
  39. data/spec/unit/{defmastership → def_mastership}/definition_parser_spec.rb +2 -2
  40. data/spec/unit/{defmastership → def_mastership}/definition_spec.rb +17 -7
  41. data/spec/unit/{defmastership → def_mastership}/document_spec.rb +108 -53
  42. data/spec/unit/def_mastership/matching_line_spec.rb +37 -0
  43. data/spec/unit/def_mastership/modifier_factory_spec.rb +37 -0
  44. data/spec/unit/def_mastership/modifier_spec.rb +83 -0
  45. data/spec/unit/{defmastership → def_mastership}/parsing_state_spec.rb +16 -16
  46. data/spec/unit/{defmastership/rename_included_files_line_modifier_spec.rb → def_mastership/rename_included_files_modifier_spec.rb} +72 -36
  47. data/spec/unit/{defmastership/comment_filter_spec.rb → def_mastership/string_spec.rb} +1 -1
  48. data/spec/unit/def_mastership/update_def_checksum_modifier_spec.rb +107 -0
  49. data/spec/unit/def_mastership/update_def_modifier_spec.rb +119 -0
  50. data/spec/unit/def_mastership/update_def_version_modifier_spec.rb +159 -0
  51. data/spec/unit/{defmastership_spec.rb → def_mastership_spec.rb} +1 -1
  52. data/tasks/console.rake +8 -0
  53. data/tasks/package.task +9 -0
  54. data/tasks/smelling_code.rake +38 -0
  55. data/tasks/test.rake +45 -0
  56. metadata +37 -145
  57. data/lib/defmastership/change_ref_line_modifier.rb +0 -82
  58. data/lib/defmastership/line_modifier_base.rb +0 -29
  59. data/lib/defmastership/modifier_base.rb +0 -29
  60. data/lib/defmastership/rename_included_files_line_modifier.rb +0 -126
  61. data/lib/defmastership/update_def_checksum_line_modifier.rb +0 -38
  62. data/lib/defmastership/update_def_version_line_modifier.rb +0 -58
  63. data/spec/unit/defmastership/change_ref_modifier_spec.rb +0 -76
  64. data/spec/unit/defmastership/rename_included_files_modifier_spec.rb +0 -67
  65. data/spec/unit/defmastership/update_def_checksum_line_modifier_spec.rb +0 -78
  66. data/spec/unit/defmastership/update_def_checksum_modifier_spec.rb +0 -75
  67. data/spec/unit/defmastership/update_def_version_line_modifier_spec.rb +0 -127
  68. data/spec/unit/defmastership/update_def_version_modifier_spec.rb +0 -80
@@ -1,9 +1,9 @@
1
1
  # Copyright (c) 2020 Jerome Arbez-Gindre
2
2
  # frozen_string_literal: true
3
3
 
4
- require('defmastership')
5
- require('ostruct')
6
4
  require('csv')
5
+ require('defmastership/csv_formatter')
6
+ require('ostruct')
7
7
 
8
8
  RSpec.describe(DefMastership::CSVFormatter) do
9
9
  subject(:formatter) { described_class.new(document, ';') }
@@ -11,20 +11,27 @@ RSpec.describe(DefMastership::CSVFormatter) do
11
11
  let(:document) { instance_double(DefMastership::Document, 'document') }
12
12
 
13
13
  describe '.new' do
14
- it { is_expected.not_to(be(nil)) }
14
+ it { is_expected.not_to(be_nil) }
15
15
  end
16
16
 
17
17
  describe '#export_to' do
18
18
  let(:header) { instance_double(DefMastership::CSVFormatterHeader, 'header') }
19
- let(:body) { instance_double(DefMastership::CSVFormatterBody, 'body') }
20
- let(:csv) { instance_double(CSV, 'csv') }
19
+ let(:bodies) do
20
+ [
21
+ instance_double(DefMastership::CSVFormatterBody, 'bodies[0]'),
22
+ instance_double(DefMastership::CSVFormatterBody, 'bodies[1]')
23
+ ]
24
+ end
25
+ let(:csv) { instance_double(CSV, 'csv') }
21
26
 
22
27
  before do
23
- allow(CSV).to(receive(:open).and_yield(csv))
28
+ allow(CSV).to(receive(:open).with('whatever', 'w:ISO-8859-1', col_sep: ';').and_yield(csv))
24
29
  allow(csv).to(receive(:<<))
25
30
  allow(DefMastership::CSVFormatterHeader).to(receive(:new).with(document).and_return(header))
26
- allow(DefMastership::CSVFormatterBody).to(receive(:new).with(document).and_return(body))
27
- allow(document).to(receive(:definitions).and_return(%i[def1 def2]))
31
+ bodies.each_with_index do |body, index|
32
+ allow(DefMastership::CSVFormatterBody).to(receive(:new).with(document, :"def#{index}").and_return(body))
33
+ end
34
+ allow(document).to(receive(:definitions).and_return(%i[def0 def1]))
28
35
  allow(document).to(receive(:wrong_explicit_checksum?).with(no_args).and_return(false))
29
36
  allow(document).to(receive(:explicit_version?).with(no_args).and_return(false))
30
37
  allow(document).to(receive(:labels).with(no_args).and_return([]))
@@ -39,21 +46,26 @@ RSpec.describe(DefMastership::CSVFormatter) do
39
46
  before do
40
47
  methods.each do |method|
41
48
  allow(header).to(receive(method).with(no_args).and_return(["#{method} header"]))
42
- allow(body).to(receive(method).with(:def1).and_return(["#{method} def1 body"]))
43
- allow(body).to(receive(method).with(:def2).and_return(["#{method} def2 body"]))
49
+ bodies.each_with_index do |body, index|
50
+ allow(body).to(receive(method).with(no_args).and_return(["#{method} def#{index} body"]))
51
+ end
44
52
  end
45
53
  formatter.export_to('whatever')
46
54
  end
47
55
 
56
+ it { expect(CSV).to(have_received(:open).with('whatever', 'w:ISO-8859-1', col_sep: ';')) }
57
+
48
58
  methods.each do |method|
49
59
  it { expect(header).to(have_received(method).with(no_args)) }
50
- it { expect(body).to(have_received(method).with(:def1)) }
51
- it { expect(body).to(have_received(method).with(:def2)) }
60
+
61
+ 2.times do |index|
62
+ it { expect(bodies[index]).to(have_received(method).with(no_args)) }
63
+ end
52
64
  end
53
65
 
54
66
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} header" })) }
67
+ it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def0 body" })) }
55
68
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def1 body" })) }
56
- it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def2 body" })) }
57
69
  end
58
70
 
59
71
  context 'when wrong_explicit_checksum' do
@@ -62,8 +74,9 @@ RSpec.describe(DefMastership::CSVFormatter) do
62
74
  before do
63
75
  methods.each do |method|
64
76
  allow(header).to(receive(method).with(no_args).and_return(["#{method} header"]))
65
- allow(body).to(receive(method).with(:def1).and_return(["#{method} def1 body"]))
66
- allow(body).to(receive(method).with(:def2).and_return(["#{method} def2 body"]))
77
+ bodies.each_with_index do |body, index|
78
+ allow(body).to(receive(method).with(no_args).and_return(["#{method} def#{index} body"]))
79
+ end
67
80
  end
68
81
  allow(document).to(receive(:wrong_explicit_checksum?).with(no_args).and_return(true))
69
82
  formatter.export_to('whatever')
@@ -71,13 +84,15 @@ RSpec.describe(DefMastership::CSVFormatter) do
71
84
 
72
85
  methods.each do |method|
73
86
  it { expect(header).to(have_received(method).with(no_args)) }
74
- it { expect(body).to(have_received(method).with(:def1)) }
75
- it { expect(body).to(have_received(method).with(:def2)) }
87
+
88
+ 2.times do |index|
89
+ it { expect(bodies[index]).to(have_received(method).with(no_args)) }
90
+ end
76
91
  end
77
92
 
78
93
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} header" })) }
94
+ it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def0 body" })) }
79
95
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def1 body" })) }
80
- it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def2 body" })) }
81
96
  end
82
97
 
83
98
  context 'when explicit_version' do
@@ -86,8 +101,9 @@ RSpec.describe(DefMastership::CSVFormatter) do
86
101
  before do
87
102
  methods.each do |method|
88
103
  allow(header).to(receive(method).with(no_args).and_return(["#{method} header"]))
89
- allow(body).to(receive(method).with(:def1).and_return(["#{method} def1 body"]))
90
- allow(body).to(receive(method).with(:def2).and_return(["#{method} def2 body"]))
104
+ bodies.each_with_index do |body, index|
105
+ allow(body).to(receive(method).with(no_args).and_return(["#{method} def#{index} body"]))
106
+ end
91
107
  end
92
108
  allow(document).to(receive(:explicit_version?).with(no_args).and_return(true))
93
109
  formatter.export_to('whatever')
@@ -95,13 +111,15 @@ RSpec.describe(DefMastership::CSVFormatter) do
95
111
 
96
112
  methods.each do |method|
97
113
  it { expect(header).to(have_received(method).with(no_args)) }
98
- it { expect(body).to(have_received(method).with(:def1)) }
99
- it { expect(body).to(have_received(method).with(:def2)) }
114
+
115
+ 2.times do |index|
116
+ it { expect(bodies[index]).to(have_received(method).with(no_args)) }
117
+ end
100
118
  end
101
119
 
102
120
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} header" })) }
121
+ it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def0 body" })) }
103
122
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def1 body" })) }
104
- it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def2 body" })) }
105
123
  end
106
124
 
107
125
  context 'when labels' do
@@ -110,8 +128,9 @@ RSpec.describe(DefMastership::CSVFormatter) do
110
128
  before do
111
129
  methods.each do |method|
112
130
  allow(header).to(receive(method).with(no_args).and_return(["#{method} header"]))
113
- allow(body).to(receive(method).with(:def1).and_return(["#{method} def1 body"]))
114
- allow(body).to(receive(method).with(:def2).and_return(["#{method} def2 body"]))
131
+ bodies.each_with_index do |body, index|
132
+ allow(body).to(receive(method).with(no_args).and_return(["#{method} def#{index} body"]))
133
+ end
115
134
  end
116
135
  allow(document).to(receive(:labels).with(no_args).and_return([:whatever]))
117
136
  formatter.export_to('whatever')
@@ -119,13 +138,15 @@ RSpec.describe(DefMastership::CSVFormatter) do
119
138
 
120
139
  methods.each do |method|
121
140
  it { expect(header).to(have_received(method).with(no_args)) }
122
- it { expect(body).to(have_received(method).with(:def1)) }
123
- it { expect(body).to(have_received(method).with(:def2)) }
141
+
142
+ 2.times do |index|
143
+ it { expect(bodies[index]).to(have_received(method).with(no_args)) }
144
+ end
124
145
  end
125
146
 
126
147
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} header" })) }
148
+ it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def0 body" })) }
127
149
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def1 body" })) }
128
- it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def2 body" })) }
129
150
  end
130
151
 
131
152
  context 'when eref' do
@@ -134,8 +155,9 @@ RSpec.describe(DefMastership::CSVFormatter) do
134
155
  before do
135
156
  methods.each do |method|
136
157
  allow(header).to(receive(method).with(no_args).and_return(["#{method} header"]))
137
- allow(body).to(receive(method).with(:def1).and_return(["#{method} def1 body"]))
138
- allow(body).to(receive(method).with(:def2).and_return(["#{method} def2 body"]))
158
+ bodies.each_with_index do |body, index|
159
+ allow(body).to(receive(method).with(no_args).and_return(["#{method} def#{index} body"]))
160
+ end
139
161
  end
140
162
  allow(document).to(receive(:eref).with(no_args).and_return([:whatever]))
141
163
  formatter.export_to('whatever')
@@ -143,13 +165,15 @@ RSpec.describe(DefMastership::CSVFormatter) do
143
165
 
144
166
  methods.each do |method|
145
167
  it { expect(header).to(have_received(method).with(no_args)) }
146
- it { expect(body).to(have_received(method).with(:def1)) }
147
- it { expect(body).to(have_received(method).with(:def2)) }
168
+
169
+ 2.times do |index|
170
+ it { expect(bodies[index]).to(have_received(method).with(no_args)) }
171
+ end
148
172
  end
149
173
 
150
174
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} header" })) }
175
+ it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def0 body" })) }
151
176
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def1 body" })) }
152
- it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def2 body" })) }
153
177
  end
154
178
 
155
179
  context 'when iref' do
@@ -158,8 +182,9 @@ RSpec.describe(DefMastership::CSVFormatter) do
158
182
  before do
159
183
  methods.each do |method|
160
184
  allow(header).to(receive(method).with(no_args).and_return(["#{method} header"]))
161
- allow(body).to(receive(method).with(:def1).and_return(["#{method} def1 body"]))
162
- allow(body).to(receive(method).with(:def2).and_return(["#{method} def2 body"]))
185
+ bodies.each_with_index do |body, index|
186
+ allow(body).to(receive(method).with(no_args).and_return(["#{method} def#{index} body"]))
187
+ end
163
188
  end
164
189
  allow(document).to(receive(:iref).with(no_args).and_return(true))
165
190
  formatter.export_to('whatever')
@@ -167,13 +192,15 @@ RSpec.describe(DefMastership::CSVFormatter) do
167
192
 
168
193
  methods.each do |method|
169
194
  it { expect(header).to(have_received(method).with(no_args)) }
170
- it { expect(body).to(have_received(method).with(:def1)) }
171
- it { expect(body).to(have_received(method).with(:def2)) }
195
+
196
+ 2.times do |index|
197
+ it { expect(bodies[index]).to(have_received(method).with(no_args)) }
198
+ end
172
199
  end
173
200
 
174
201
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} header" })) }
202
+ it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def0 body" })) }
175
203
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def1 body" })) }
176
- it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def2 body" })) }
177
204
  end
178
205
 
179
206
  context 'when attributes' do
@@ -182,8 +209,9 @@ RSpec.describe(DefMastership::CSVFormatter) do
182
209
  before do
183
210
  methods.each do |method|
184
211
  allow(header).to(receive(method).with(no_args).and_return(["#{method} header"]))
185
- allow(body).to(receive(method).with(:def1).and_return(["#{method} def1 body"]))
186
- allow(body).to(receive(method).with(:def2).and_return(["#{method} def2 body"]))
212
+ bodies.each_with_index do |body, index|
213
+ allow(body).to(receive(method).with(no_args).and_return(["#{method} def#{index} body"]))
214
+ end
187
215
  end
188
216
  allow(document).to(receive(:attributes).with(no_args).and_return([:whatever]))
189
217
  formatter.export_to('whatever')
@@ -191,13 +219,15 @@ RSpec.describe(DefMastership::CSVFormatter) do
191
219
 
192
220
  methods.each do |method|
193
221
  it { expect(header).to(have_received(method).with(no_args)) }
194
- it { expect(body).to(have_received(method).with(:def1)) }
195
- it { expect(body).to(have_received(method).with(:def2)) }
222
+
223
+ 2.times do |index|
224
+ it { expect(bodies[index]).to(have_received(method).with(no_args)) }
225
+ end
196
226
  end
197
227
 
198
228
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} header" })) }
229
+ it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def0 body" })) }
199
230
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def1 body" })) }
200
- it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def2 body" })) }
201
231
  end
202
232
 
203
233
  context 'when every colums' do
@@ -206,8 +236,9 @@ RSpec.describe(DefMastership::CSVFormatter) do
206
236
  before do
207
237
  methods.each do |method|
208
238
  allow(header).to(receive(method).with(no_args).and_return(["#{method} header"]))
209
- allow(body).to(receive(method).with(:def1).and_return(["#{method} def1 body"]))
210
- allow(body).to(receive(method).with(:def2).and_return(["#{method} def2 body"]))
239
+ bodies.each_with_index do |body, index|
240
+ allow(body).to(receive(method).with(no_args).and_return(["#{method} def#{index} body"]))
241
+ end
211
242
  end
212
243
  allow(document).to(receive(:wrong_explicit_checksum?).with(no_args).and_return(true))
213
244
  allow(document).to(receive(:explicit_version?).with(no_args).and_return(true))
@@ -220,51 +251,15 @@ RSpec.describe(DefMastership::CSVFormatter) do
220
251
 
221
252
  methods.each do |method|
222
253
  it { expect(header).to(have_received(method).with(no_args)) }
223
- it { expect(body).to(have_received(method).with(:def1)) }
224
- it { expect(body).to(have_received(method).with(:def2)) }
254
+
255
+ 2.times do |index|
256
+ it { expect(bodies[index]).to(have_received(method).with(no_args)) }
257
+ end
225
258
  end
226
259
 
227
260
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} header" })) }
261
+ it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def0 body" })) }
228
262
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def1 body" })) }
229
- it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def2 body" })) }
230
- end
231
- end
232
-
233
- context 'when #export_to csv file' do
234
- let(:target_file) { 'export.csv' }
235
- let(:definitions) do
236
- [
237
- OpenStruct.new(type: 'a', reference: 'b', value: 'c', sha256: 'd'),
238
- OpenStruct.new(type: 'd', reference: 'e', value: 'f', sha256: 'g')
239
- ]
240
- end
241
-
242
- before do
243
- setup_aruba
244
- allow(document).to(receive(:labels).with(no_args).and_return([]))
245
- allow(document).to(receive(:eref).with(no_args).and_return({}))
246
- allow(document).to(receive(:iref).with(no_args).and_return(false))
247
- allow(document).to(receive(:attributes).with(no_args).and_return({}))
248
- allow(document).to(receive(:definitions).with(no_args).and_return(definitions))
249
- allow(document).to(receive(:wrong_explicit_checksum?).with(no_args).and_return(false))
250
- allow(document).to(receive(:explicit_version?).with(no_args).and_return(false))
251
- formatter.export_to("#{aruba.current_directory}/#{target_file}")
252
- end
253
-
254
- it { expect(document).to(have_received(:labels).with(no_args)) }
255
- it { expect(document).to(have_received(:eref).with(no_args)) }
256
- it { expect(document).to(have_received(:iref).with(no_args)) }
257
- it { expect(document).to(have_received(:attributes).with(no_args)) }
258
- it { expect(document).to(have_received(:definitions).with(no_args)) }
259
- it { expect(document).to(have_received(:wrong_explicit_checksum?).with(no_args)) }
260
- it { expect(document).to(have_received(:explicit_version?).with(no_args)) }
261
-
262
- it do
263
- expect(target_file).to(have_file_content(<<~CSV_FILE))
264
- Type;Reference;Value;Checksum
265
- a;b;c;d
266
- d;e;f;g
267
- CSV_FILE
268
263
  end
269
264
  end
270
265
  end
@@ -1,12 +1,12 @@
1
1
  # Copyright (c) 2020 Jerome Arbez-Gindre
2
2
  # frozen_string_literal: true
3
3
 
4
- require('defmastership')
4
+ require('defmastership/definition_parser')
5
5
 
6
6
  RSpec.describe(DefMastership::DefinitionParser) do
7
7
  subject(:parser) { described_class.new(callback_object) }
8
8
 
9
- let(:callback_object) { instance_double('callback_object') }
9
+ let(:callback_object) { double }
10
10
 
11
11
  before do
12
12
  allow(callback_object).to(receive(:add_new_definition).with(any_args))
@@ -1,7 +1,7 @@
1
1
  # Copyright (c) 2020 Jerome Arbez-Gindre
2
2
  # frozen_string_literal: true
3
3
 
4
- require('defmastership')
4
+ require('defmastership/definition')
5
5
 
6
6
  RSpec.describe(DefMastership::Definition) do
7
7
  describe '.new' do
@@ -13,7 +13,7 @@ RSpec.describe(DefMastership::Definition) do
13
13
  )
14
14
  end
15
15
 
16
- it { is_expected.not_to(be(nil)) }
16
+ it { is_expected.not_to(be_nil) }
17
17
  it { is_expected.to(have_attributes(type: 'req')) }
18
18
  it { is_expected.to(have_attributes(reference: 'TUTU-001')) }
19
19
  it { is_expected.to(have_attributes(lines: [])) }
@@ -101,9 +101,14 @@ RSpec.describe(DefMastership::Definition) do
101
101
  expect(definition.lines).to(eq(['first line', 'second line']))
102
102
  end
103
103
 
104
- it 'calculates sha256 of value' do
104
+ it 'calculates sha256_short of value' do
105
105
  definition << 'first line' << 'second line'
106
- expect(definition.sha256).to(eq('~beb0535a'))
106
+ expect(definition.sha256_short).to(eq('~beb0535a'))
107
+ end
108
+
109
+ it 'returns the definition and not the "line"' do
110
+ expect { (definition << 'first line').sha256_short }
111
+ .not_to(raise_error)
107
112
  end
108
113
  end
109
114
 
@@ -115,9 +120,14 @@ RSpec.describe(DefMastership::Definition) do
115
120
  )
116
121
  end
117
122
 
118
- it 'shall accept to add one eref' do
119
- definition.add_eref(:foo, ' tutu, titi , pouet')
120
- expect(definition.eref[:foo]).to(eq(%w[tutu titi pouet]))
123
+ [
124
+ 'tutu,titi,pouet',
125
+ ' tutu , titi , pouet '
126
+ ].each do |erefs_cs|
127
+ it 'shall accept to add comma separated erefs' do
128
+ definition.add_eref(:foo, erefs_cs)
129
+ expect(definition.eref[:foo]).to(eq(%w[tutu titi pouet]))
130
+ end
121
131
  end
122
132
  end
123
133