@@ -32,6 +32,7 @@ module RSpec::Core
32
32
|
33
33
| 1) Example
34
34
| Failure/Error: # The failure happened here!#{ encoding_check }
35
+ |
35
36
| Boom
36
37
| Bam
37
38
| # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{ line_num }
@@ -43,6 +44,7 @@ module RSpec::Core
43
44
|
44
45
| 100) Example
45
46
| Failure/Error: # The failure happened here!#{ encoding_check }
47
+ |
46
48
| Boom
47
49
| Bam
48
50
| # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{ line_num }
@@ -56,6 +58,7 @@ module RSpec::Core
56
58
|
57
59
| 1) Example
58
60
| Failure/Error: # The failure happened here!#{ encoding_check }
61
+ |
59
62
| Boom
60
63
| Bam
61
64
| # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{ line_num }
@@ -72,6 +75,7 @@ module RSpec::Core
72
75
| 1) Example
73
76
| Some Detail
74
77
| Failure/Error: # The failure happened here!#{ encoding_check }
78
+ |
75
79
| Boom
76
80
| Bam
77
81
| # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{ line_num }
@@ -87,6 +91,7 @@ module RSpec::Core
87
91
|
88
92
| 1) Detail!
89
93
| Failure/Error: # The failure happened here!#{ encoding_check }
94
+ |
90
95
| Boom
91
96
| Bam
92
97
| # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{ line_num }
@@ -99,6 +104,7 @@ module RSpec::Core
99
104
expect ( the_presenter . fully_formatted ( 1 ) ) . to eq ( <<-EOS . gsub ( /^ +\| / , '' ) )
100
105
|
101
106
| 1) Failure/Error: # The failure happened here!#{ encoding_check }
107
+ |
102
108
| Boom
103
109
| Bam
104
110
| # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{ line_num }
@@ -116,6 +122,7 @@ module RSpec::Core
116
122
|
117
123
| 2) Example
118
124
| Failure/Error: # The failure happened here!#{ encoding_check }
125
+ |
119
126
| Boom
120
127
| Bam
121
128
| # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{ line_num }
@@ -140,14 +147,15 @@ module RSpec::Core
140
147
|
141
148
| 1) Example
142
149
| Failure/Error: # The failure happened here!#{ encoding_check }
150
+ |
143
151
| Boom
144
152
| Bam
145
153
| # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{ line_num }
146
154
| # ------------------
147
155
| # --- Caused by: ---
148
156
| # Real
149
157
| # culprit
150
- | # ./spec/rspec/core/formatters/exception_presenter_spec.rb:133
158
+ | # ./spec/rspec/core/formatters/exception_presenter_spec.rb:140
151
159
EOS
152
160
end
153
161
@@ -160,6 +168,7 @@ module RSpec::Core
160
168
|
161
169
| 1) Example
162
170
| Failure/Error: # The failure happened here!#{ encoding_check }
171
+ |
163
172
| Boom
164
173
| Bam
165
174
|
@@ -168,7 +177,175 @@ module RSpec::Core
168
177
| # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{ line_num }
169
178
EOS
170
179
end
180
+
181
+ describe 'line format' do
182
+ let ( :exception ) do
183
+ begin
184
+ expression
185
+ rescue RSpec ::Support ::AllExceptionsExceptOnesWeMustNotRescue => exception
186
+ exception
187
+ end
188
+ end
189
+
190
+ context 'with single line expression and single line RSpec exception message' do
191
+ let ( :expression ) do
192
+ expect ( 'RSpec' ) . to be_a ( Integer )
193
+ end
194
+
195
+ it 'crams them without blank line' do
196
+ expect ( presenter . fully_formatted ( 1 ) ) . to start_with ( <<-EOS . gsub ( /^ +\| / , '' ) . chomp )
197
+ |
198
+ | 1) Example
199
+ | Failure/Error: expect('RSpec').to be_a(Integer)
200
+ | expected "RSpec" to be a kind of Integer
201
+ | # ./spec/rspec/core/formatters/exception_presenter_spec.rb:
202
+ EOS
203
+ end
204
+ end
205
+
206
+ context 'with multiline expression and single line RSpec exception message' , :if => RSpec ::Support ::RubyFeatures . ripper_supported? do
207
+ let ( :expression ) do
208
+ expect ( 'RSpec' ) .
209
+ to be_a ( Integer )
210
+ end
211
+
212
+ it 'inserts a blank line between the expression and the message' do
213
+ expect ( presenter . fully_formatted ( 1 ) ) . to start_with ( <<-EOS . gsub ( /^ +\| / , '' ) . chomp )
214
+ |
215
+ | 1) Example
216
+ | Failure/Error:
217
+ | expect('RSpec').
218
+ | to be_a(Integer)
219
+ |
220
+ | expected "RSpec" to be a kind of Integer
221
+ | # ./spec/rspec/core/formatters/exception_presenter_spec.rb:
222
+ EOS
223
+ end
224
+ end
225
+
226
+ context 'with single line expression and multiline RSpec exception message' do
227
+ let ( :expression ) do
228
+ expect ( 'RSpec' ) . to be_falsey
229
+ end
230
+
231
+ it 'inserts a blank line between the expression and the message' do
232
+ expect ( presenter . fully_formatted ( 1 ) ) . to start_with ( <<-EOS . gsub ( /^ +\| / , '' ) . chomp )
233
+ |
234
+ | 1) Example
235
+ | Failure/Error: expect('RSpec').to be_falsey
236
+ |
237
+ | expected: falsey value
238
+ | got: "RSpec"
239
+ | # ./spec/rspec/core/formatters/exception_presenter_spec.rb:
240
+ EOS
241
+ end
242
+ end
243
+
244
+ context 'with multiline expression and multiline RSpec exception message' , :if => RSpec ::Support ::RubyFeatures . ripper_supported? do
245
+ let ( :expression ) do
246
+ expect ( 'RSpec' ) .
247
+ to be_falsey
248
+ end
249
+
250
+ it 'inserts a blank line between the expression and the message' do
251
+ expect ( presenter . fully_formatted ( 1 ) ) . to start_with ( <<-EOS . gsub ( /^ +\| / , '' ) . chomp )
252
+ |
253
+ | 1) Example
254
+ | Failure/Error:
255
+ | expect('RSpec').
256
+ | to be_falsey
257
+ |
258
+ | expected: falsey value
259
+ | got: "RSpec"
260
+ | # ./spec/rspec/core/formatters/exception_presenter_spec.rb:
261
+ EOS
262
+ end
263
+ end
264
+
265
+ context 'with single line expression and RSpec exception message starting with linefeed (like `eq` matcher)' do
266
+ let ( :expression ) do
267
+ expect ( 'Rspec' ) . to eq ( 'RSpec' )
268
+ end
269
+
270
+ it 'does not insert a superfluous blank line' do
271
+ expect ( presenter . fully_formatted ( 1 ) ) . to start_with ( <<-EOS . gsub ( /^ +\| / , '' ) . chomp )
272
+ |
273
+ | 1) Example
274
+ | Failure/Error: expect('Rspec').to eq('RSpec')
275
+ |
276
+ | expected: "RSpec"
277
+ | got: "Rspec"
278
+ |
279
+ | (compared using ==)
280
+ | # ./spec/rspec/core/formatters/exception_presenter_spec.rb:
281
+ EOS
282
+ end
283
+ end
284
+
285
+ context 'with multiline expression and RSpec exception message starting with linefeed (like `eq` matcher)' , :if => RSpec ::Support ::RubyFeatures . ripper_supported? do
286
+ let ( :expression ) do
287
+ expect ( 'Rspec' ) .
288
+ to eq ( 'RSpec' )
289
+ end
290
+
291
+ it 'does not insert a superfluous blank line' do
292
+ expect ( presenter . fully_formatted ( 1 ) ) . to start_with ( <<-EOS . gsub ( /^ +\| / , '' ) . chomp )
293
+ |
294
+ | 1) Example
295
+ | Failure/Error:
296
+ | expect('Rspec').
297
+ | to eq('RSpec')
298
+ |
299
+ | expected: "RSpec"
300
+ | got: "Rspec"
301
+ |
302
+ | (compared using ==)
303
+ | # ./spec/rspec/core/formatters/exception_presenter_spec.rb:
304
+ EOS
305
+ end
306
+ end
307
+
308
+ context 'with single line expression and single line non-RSpec exception message' do
309
+ let ( :expression ) do
310
+ expect { fail 'Something is wrong!' } . to change { RSpec }
311
+ end
312
+
313
+ it 'inserts a blank line between the expression and the message' do
314
+ expect ( presenter . fully_formatted ( 1 ) ) . to start_with ( <<-EOS . gsub ( /^ +\| / , '' ) . chomp )
315
+ |
316
+ | 1) Example
317
+ | Failure/Error: expect { fail 'Something is wrong!' }.to change { RSpec }
318
+ |
319
+ | RuntimeError:
320
+ | Something is wrong!
321
+ | # ./spec/rspec/core/formatters/exception_presenter_spec.rb:
322
+ EOS
323
+ end
324
+ end
325
+
326
+ context 'with multiline expression and single line non-RSpec exception message' , :if => RSpec ::Support ::RubyFeatures . ripper_supported? do
327
+ let ( :expression ) do
328
+ expect { fail 'Something is wrong!' } .
329
+ to change { RSpec }
330
+ end
331
+
332
+ it 'inserts a blank line between the expression and the message' do
333
+ expect ( presenter . fully_formatted ( 1 ) ) . to start_with ( <<-EOS . gsub ( /^ +\| / , '' ) . chomp )
334
+ |
335
+ | 1) Example
336
+ | Failure/Error:
337
+ | expect { fail 'Something is wrong!' }.
338
+ | to change { RSpec }
339
+ |
340
+ | RuntimeError:
341
+ | Something is wrong!
342
+ | # ./spec/rspec/core/formatters/exception_presenter_spec.rb:
343
+ EOS
344
+ end
345
+ end
346
+ end
171
347
end
348
+
172
349
describe "#read_failed_lines" do
173
350
def read_failed_lines
174
351
presenter . send ( :read_failed_lines )
0 commit comments