seeing_is_believing 3.0.0.beta.4 → 3.0.0.beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -8
- data/Rakefile +1 -1
- data/Readme.md +65 -25
- data/bin/seeing_is_believing +1 -0
- data/docs/sib-streaming.gif +0 -0
- data/features/deprecated-flags.feature +62 -2
- data/features/errors.feature +12 -7
- data/features/examples.feature +143 -4
- data/features/flags.feature +89 -29
- data/features/regression.feature +58 -14
- data/features/support/env.rb +4 -0
- data/features/xmpfilter-style.feature +181 -36
- data/lib/seeing_is_believing.rb +44 -33
- data/lib/seeing_is_believing/binary.rb +31 -88
- data/lib/seeing_is_believing/binary/align_chunk.rb +30 -11
- data/lib/seeing_is_believing/binary/annotate_end_of_file.rb +10 -16
- data/lib/seeing_is_believing/binary/annotate_every_line.rb +5 -25
- data/lib/seeing_is_believing/binary/annotate_marked_lines.rb +136 -0
- data/lib/seeing_is_believing/binary/comment_lines.rb +8 -10
- data/lib/seeing_is_believing/binary/commentable_lines.rb +20 -26
- data/lib/seeing_is_believing/binary/config.rb +392 -0
- data/lib/seeing_is_believing/binary/data_structures.rb +57 -0
- data/lib/seeing_is_believing/binary/engine.rb +104 -0
- data/lib/seeing_is_believing/binary/{comment_formatter.rb → format_comment.rb} +6 -6
- data/lib/seeing_is_believing/binary/remove_annotations.rb +29 -28
- data/lib/seeing_is_believing/binary/rewrite_comments.rb +42 -43
- data/lib/seeing_is_believing/code.rb +105 -49
- data/lib/seeing_is_believing/debugger.rb +6 -5
- data/lib/seeing_is_believing/error.rb +6 -17
- data/lib/seeing_is_believing/evaluate_by_moving_files.rb +78 -129
- data/lib/seeing_is_believing/event_stream/consumer.rb +114 -64
- data/lib/seeing_is_believing/event_stream/events.rb +169 -11
- data/lib/seeing_is_believing/event_stream/handlers/debug.rb +57 -0
- data/lib/seeing_is_believing/event_stream/handlers/record_exitstatus.rb +18 -0
- data/lib/seeing_is_believing/event_stream/handlers/stream_json_events.rb +45 -0
- data/lib/seeing_is_believing/event_stream/handlers/update_result.rb +39 -0
- data/lib/seeing_is_believing/event_stream/producer.rb +25 -24
- data/lib/seeing_is_believing/hash_struct.rb +206 -0
- data/lib/seeing_is_believing/result.rb +20 -3
- data/lib/seeing_is_believing/the_matrix.rb +20 -12
- data/lib/seeing_is_believing/version.rb +1 -1
- data/lib/seeing_is_believing/wrap_expressions.rb +55 -115
- data/lib/seeing_is_believing/wrap_expressions_with_inspect.rb +14 -0
- data/seeing_is_believing.gemspec +1 -1
- data/spec/binary/alignment_specs.rb +27 -0
- data/spec/binary/comment_lines_spec.rb +3 -2
- data/spec/binary/config_spec.rb +657 -0
- data/spec/binary/engine_spec.rb +97 -0
- data/spec/binary/{comment_formatter_spec.rb → format_comment_spec.rb} +2 -2
- data/spec/binary/marker_spec.rb +71 -0
- data/spec/binary/options_spec.rb +0 -0
- data/spec/binary/remove_annotations_spec.rb +31 -18
- data/spec/binary/rewrite_comments_spec.rb +26 -11
- data/spec/code_spec.rb +190 -6
- data/spec/debugger_spec.rb +4 -0
- data/spec/evaluate_by_moving_files_spec.rb +38 -20
- data/spec/event_stream_spec.rb +265 -116
- data/spec/hash_struct_spec.rb +514 -0
- data/spec/seeing_is_believing_spec.rb +108 -46
- data/spec/spec_helper.rb +9 -0
- data/spec/wrap_expressions_spec.rb +207 -172
- metadata +30 -18
- data/docs/for-presentations +0 -33
- data/lib/seeing_is_believing/binary/annotate_xmpfilter_style.rb +0 -128
- data/lib/seeing_is_believing/binary/interpret_flags.rb +0 -156
- data/lib/seeing_is_believing/binary/parse_args.rb +0 -263
- data/lib/seeing_is_believing/event_stream/update_result.rb +0 -24
- data/lib/seeing_is_believing/inspect_expressions.rb +0 -21
- data/lib/seeing_is_believing/parser_helpers.rb +0 -82
- data/spec/binary/interpret_flags_spec.rb +0 -332
- data/spec/binary/parse_args_spec.rb +0 -415
data/features/flags.feature
CHANGED
@@ -85,21 +85,21 @@ Feature: Using flags
|
|
85
85
|
Then stdout is "12345"
|
86
86
|
|
87
87
|
|
88
|
-
Scenario: --
|
89
|
-
Given the file "
|
88
|
+
Scenario: --max-line-captures determines how many times a line will be recorded
|
89
|
+
Given the file "max_line_captures.rb":
|
90
90
|
"""
|
91
91
|
5.times do |i|
|
92
92
|
i
|
93
93
|
end
|
94
94
|
"""
|
95
|
-
When I run "seeing_is_believing --
|
95
|
+
When I run "seeing_is_believing --max-line-captures 4 max_line_captures.rb"
|
96
96
|
Then stdout is:
|
97
97
|
"""
|
98
98
|
5.times do |i| # => 5
|
99
99
|
i # => 0, 1, 2, 3, ...
|
100
100
|
end # => 5
|
101
101
|
"""
|
102
|
-
When I run "seeing_is_believing --
|
102
|
+
When I run "seeing_is_believing --max-line-captures 5 max_line_captures.rb"
|
103
103
|
Then stdout is:
|
104
104
|
"""
|
105
105
|
5.times do |i| # => 5
|
@@ -251,17 +251,17 @@ Feature: Using flags
|
|
251
251
|
And stdout includes "Examples:"
|
252
252
|
|
253
253
|
|
254
|
-
Scenario: --timeout
|
254
|
+
Scenario: --timeout-seconds
|
255
255
|
Given the file "will_timeout.rb" "sleep 1"
|
256
|
-
When I run "seeing_is_believing --timeout 0.1 will_timeout.rb"
|
256
|
+
When I run "seeing_is_believing --timeout-seconds 0.1 will_timeout.rb"
|
257
257
|
Then stdout is empty
|
258
258
|
And the exit status is 2
|
259
259
|
And stderr is "Timeout Error after 0.1 seconds!"
|
260
260
|
|
261
261
|
|
262
|
-
Scenario: --timeout
|
262
|
+
Scenario: --timeout-seconds
|
263
263
|
Given the file "will_not_timeout.rb" "1 + 1"
|
264
|
-
When I run "seeing_is_believing --timeout 1.0 will_not_timeout.rb"
|
264
|
+
When I run "seeing_is_believing --timeout-seconds 1.0 will_not_timeout.rb"
|
265
265
|
Then stderr is empty
|
266
266
|
And the exit status is 0
|
267
267
|
And stdout is "1 + 1 # => 2"
|
@@ -367,28 +367,60 @@ Feature: Using flags
|
|
367
367
|
"""
|
368
368
|
|
369
369
|
|
370
|
-
Scenario: --inherit-exit
|
371
|
-
Given the file "
|
372
|
-
|
370
|
+
Scenario: --inherit-exitstatus causes SiB to exit with the status of the evaluated file
|
371
|
+
Given the file "exitstatus.rb" "exit 123"
|
372
|
+
|
373
|
+
When I run "seeing_is_believing exitstatus.rb"
|
373
374
|
Then the exit status is 1
|
374
|
-
|
375
|
+
And stderr is empty
|
376
|
+
And stdout is "exit 123"
|
377
|
+
|
378
|
+
When I run "seeing_is_believing -i exitstatus.rb"
|
375
379
|
Then the exit status is 123
|
380
|
+
And stderr is empty
|
381
|
+
And stdout is "exit 123"
|
382
|
+
|
383
|
+
|
384
|
+
Scenario: --inherit-exitstatus works with exit!
|
385
|
+
Given the file "exit_bang.rb":
|
386
|
+
"""
|
387
|
+
:hello
|
388
|
+
exit! 100
|
389
|
+
"""
|
390
|
+
|
391
|
+
When I run "seeing_is_believing exit_bang.rb"
|
392
|
+
Then stderr is empty
|
393
|
+
And the exit status is 1
|
394
|
+
And stdout is:
|
395
|
+
"""
|
396
|
+
:hello # => :hello
|
397
|
+
exit! 100
|
398
|
+
"""
|
399
|
+
|
400
|
+
When I run "seeing_is_believing -i exit_bang.rb"
|
401
|
+
Then stderr is empty
|
402
|
+
And the exit status is 100
|
403
|
+
And stdout is:
|
404
|
+
"""
|
405
|
+
:hello # => :hello
|
406
|
+
exit! 100
|
407
|
+
"""
|
376
408
|
|
377
409
|
|
378
|
-
# Show that Ruby exceptions exit with 1, and --inherit-
|
379
|
-
Scenario: --inherit-
|
380
|
-
Given the file "
|
381
|
-
When I run "ruby
|
410
|
+
# Show that Ruby exceptions exit with 1, and --inherit-exitstatus does as well
|
411
|
+
Scenario: --inherit-exitstatus
|
412
|
+
Given the file "exception_exitstatus.rb" "raise Exception"
|
413
|
+
When I run "ruby exception_exitstatus.rb"
|
382
414
|
Then the exit status is 1
|
383
|
-
When I run "seeing_is_believing
|
415
|
+
When I run "seeing_is_believing -i exception_exitstatus.rb"
|
384
416
|
Then the exit status is 1
|
385
417
|
|
386
418
|
|
387
|
-
Scenario: --inherit-
|
388
|
-
Given the file "
|
389
|
-
When I run "seeing_is_believing
|
419
|
+
Scenario: --inherit-exitstatus in an at_exit block
|
420
|
+
Given the file "exitstatus_in_at_exit_block.rb" "at_exit { exit 10 }"
|
421
|
+
When I run "seeing_is_believing exitstatus_in_at_exit_block.rb"
|
390
422
|
Then the exit status is 1
|
391
|
-
When I run "seeing_is_believing
|
423
|
+
When I run "seeing_is_believing -i exitstatus_in_at_exit_block.rb"
|
392
424
|
Then the exit status is 10
|
393
425
|
|
394
426
|
|
@@ -400,14 +432,13 @@ Feature: Using flags
|
|
400
432
|
2
|
401
433
|
"""
|
402
434
|
When I run "seeing_is_believing --debug simple_program.rb"
|
403
|
-
Then
|
435
|
+
Then stdout is empty
|
404
436
|
And the exit status is 0
|
405
|
-
And
|
406
|
-
And
|
407
|
-
And
|
408
|
-
And
|
409
|
-
And
|
410
|
-
And stdout includes:
|
437
|
+
And stderr includes "REWRITTEN PROGRAM:"
|
438
|
+
And stderr includes "$SiB"
|
439
|
+
And stderr includes "EVENTS:"
|
440
|
+
And stderr includes "OUTPUT:"
|
441
|
+
And stderr includes:
|
411
442
|
"""
|
412
443
|
# encoding: utf-8
|
413
444
|
1# 123
|
@@ -445,7 +476,36 @@ Feature: Using flags
|
|
445
476
|
},
|
446
477
|
"stdout": "b\n",
|
447
478
|
"stderr": "c\n",
|
448
|
-
"
|
479
|
+
"exitstatus": 1
|
449
480
|
}
|
450
481
|
"""
|
451
482
|
|
483
|
+
Scenario: --stream prints events from the event stream as they are seen
|
484
|
+
Given the file "record_event_stream.rb" "3.times { |i| p i }"
|
485
|
+
When I run "seeing_is_believing record_event_stream.rb --stream"
|
486
|
+
Then stderr is empty
|
487
|
+
And the exit status is 0
|
488
|
+
And stdout includes:
|
489
|
+
"""
|
490
|
+
["stdout",{"value":"0\n"}]
|
491
|
+
"""
|
492
|
+
And stdout includes:
|
493
|
+
"""
|
494
|
+
["exitstatus",{"value":0}]
|
495
|
+
"""
|
496
|
+
And stdout includes:
|
497
|
+
"""
|
498
|
+
["max_line_captures",{"value":-1,"is_infinity":true}]
|
499
|
+
"""
|
500
|
+
|
501
|
+
Scenario: --stream respects the exit status
|
502
|
+
When I run "seeing_is_believing -ie 'exit 12' --stream"
|
503
|
+
Then stderr is empty
|
504
|
+
And the exit status is 12
|
505
|
+
|
506
|
+
Scenario: --stream sees leading data even with a hostile BEGIN block.
|
507
|
+
When I run "seeing_is_believing -e 'BEGIN { exit! }' --stream"
|
508
|
+
Then stdout includes:
|
509
|
+
"""
|
510
|
+
["sib_version",{"value":"{{SeeingIsBelieving::VERSION}}"}]
|
511
|
+
"""
|
data/features/regression.feature
CHANGED
@@ -184,7 +184,7 @@ Feature:
|
|
184
184
|
"""
|
185
185
|
class CreditCard
|
186
186
|
|
187
|
-
end
|
187
|
+
end # => nil
|
188
188
|
|
189
189
|
describe CreditCard do # ~> NoMethodError: undefined method `describe' for main:Object
|
190
190
|
|
@@ -224,7 +224,7 @@ Feature:
|
|
224
224
|
def inspect
|
225
225
|
"<PROC>" # => "<PROC>", "<PROC>", "<PROC>", "<PROC>", "<PROC>", "<PROC>", "<PROC>", "<PROC>", "<PROC>", "<PROC>", "<PROC>", "<PROC>"
|
226
226
|
end # => {{method_result :inspect}}
|
227
|
-
end
|
227
|
+
end # => {{method_result :inspect}}
|
228
228
|
|
229
229
|
generic_fib_gen = -> current, prev {
|
230
230
|
-> {
|
@@ -290,7 +290,11 @@ Feature:
|
|
290
290
|
{{'.' * 100_000}}
|
291
291
|
"""
|
292
292
|
When I run "seeing_is_believing long_invalid_data_segment.rb"
|
293
|
-
Then stderr
|
293
|
+
Then stderr is:
|
294
|
+
"""
|
295
|
+
Syntax Error: long_invalid_data_segment.rb:1
|
296
|
+
unterminated string meets end of file
|
297
|
+
"""
|
294
298
|
And the exit status is 2
|
295
299
|
And stdout is empty
|
296
300
|
|
@@ -390,7 +394,7 @@ Feature:
|
|
390
394
|
class Object
|
391
395
|
def !(a)
|
392
396
|
end # => {{method_result :!}}
|
393
|
-
end
|
397
|
+
end # => {{method_result :!}}
|
394
398
|
"""
|
395
399
|
|
396
400
|
|
@@ -441,22 +445,62 @@ Feature:
|
|
441
445
|
Thread.new { Queue.new.shift }.join # ~> fatal
|
442
446
|
"""
|
443
447
|
|
444
|
-
|
448
|
+
|
445
449
|
Scenario: Xmpfilter does not write the error messages inside of strings
|
446
450
|
Given the file "error_within_string.rb":
|
447
451
|
"""
|
448
|
-
|
449
|
-
|
452
|
+
1.send "a
|
453
|
+
b"
|
450
454
|
"""
|
451
455
|
When I run "seeing_is_believing --xmpfilter-style error_within_string.rb"
|
456
|
+
Then stdout includes:
|
457
|
+
"""
|
458
|
+
1.send "a
|
459
|
+
b"
|
460
|
+
|
461
|
+
# ~> NoMethodError
|
462
|
+
# ~> undefined method `a
|
463
|
+
# ~> b' for 1:Fixnum
|
464
|
+
"""
|
465
|
+
|
466
|
+
|
467
|
+
# not going to get too detailed on what it prints, b/c that message seems pretty fragile,
|
468
|
+
# but just generally that it doesn't fkn blow up
|
469
|
+
Scenario: https://github.com/JoshCheek/seeing_is_believing/issues/46
|
470
|
+
Given the file "json_and_encodings.rb":
|
471
|
+
"""
|
472
|
+
# encoding: utf-8
|
473
|
+
require 'json'
|
474
|
+
JSON.parse JSON.dump("√")
|
475
|
+
"""
|
476
|
+
When I run "seeing_is_believing json_and_encodings.rb"
|
477
|
+
Then stderr is empty
|
478
|
+
And the exit status is 1
|
479
|
+
And stdout includes:
|
480
|
+
"""
|
481
|
+
require 'json' # => true
|
482
|
+
JSON.parse JSON.dump("√")
|
483
|
+
"""
|
484
|
+
|
485
|
+
|
486
|
+
Scenario: Correctly identify end of file
|
487
|
+
Given the file "fake_data_segment.rb":
|
488
|
+
"""
|
489
|
+
puts "output"
|
490
|
+
"
|
491
|
+
__END__
|
492
|
+
"
|
493
|
+
__END__
|
494
|
+
"""
|
495
|
+
When I run "seeing_is_believing fake_data_segment.rb"
|
452
496
|
Then stdout is:
|
453
497
|
"""
|
454
|
-
|
455
|
-
|
498
|
+
puts "output" # => nil
|
499
|
+
"
|
500
|
+
__END__
|
501
|
+
" # => "\n__END__\n"
|
456
502
|
|
457
|
-
#
|
458
|
-
|
459
|
-
# ~> line2
|
460
|
-
# ~>
|
461
|
-
# ~> f4.rb:1:in `<main>'
|
503
|
+
# >> output
|
504
|
+
__END__
|
462
505
|
"""
|
506
|
+
|
data/features/support/env.rb
CHANGED
@@ -27,6 +27,10 @@ Then 'stdout is exactly:' do |code|
|
|
27
27
|
expect(@last_executed.stdout).to eq eval_curlies(code)
|
28
28
|
end
|
29
29
|
|
30
|
+
Then 'stdout is exactly "$code"' do |code|
|
31
|
+
expect(@last_executed.stdout).to eq eval_curlies(code)
|
32
|
+
end
|
33
|
+
|
30
34
|
Then 'stdout is the JSON:' do |json|
|
31
35
|
require 'json'
|
32
36
|
expected = JSON.parse(json)
|
@@ -3,13 +3,6 @@ Feature: Xmpfilter style
|
|
3
3
|
Support the same (or highly similar) interface as xmpfilter,
|
4
4
|
so that people who use that lib can easily transition to SiB.
|
5
5
|
|
6
|
-
TODO:
|
7
|
-
* multiple values on pp lines
|
8
|
-
* show that exceptions respect line-length restriction flags
|
9
|
-
* Scenario: pp output on line with exception
|
10
|
-
* when input has previously identified exception
|
11
|
-
|
12
|
-
|
13
6
|
Scenario: --xmpfilter-style Generic updating of marked lines
|
14
7
|
Given the file "magic_comments.rb":
|
15
8
|
"""
|
@@ -149,7 +142,7 @@ Feature: Xmpfilter style
|
|
149
142
|
"""
|
150
143
|
|
151
144
|
|
152
|
-
Scenario: Cleaning previous output
|
145
|
+
Scenario: Cleaning previous output does not clean the xmpfilter annotations
|
153
146
|
Given the file "xmpfilter_cleaning.rb":
|
154
147
|
"""
|
155
148
|
# commented out # => previous annotation
|
@@ -157,55 +150,60 @@ Feature: Xmpfilter style
|
|
157
150
|
# => "1111111111...
|
158
151
|
# "1111111111...
|
159
152
|
# normal comment
|
160
|
-
|
153
|
+
|
154
|
+
{foo: 42, bar: {baz: 1, buz: 2, fuz: 3}, wibble: {magic_word: "xyzzy"}}
|
155
|
+
# => {:foo=>42,
|
156
|
+
# :bar=>{:baz=>1, :buz=>2, :fuz=>3},
|
157
|
+
# :wibble=>{:magic_word=>"xyzzy"}}
|
161
158
|
"""
|
162
159
|
When I run "seeing_is_believing --xmpfilter-style --clean xmpfilter_cleaning.rb"
|
163
160
|
Then stdout is:
|
164
161
|
"""
|
165
162
|
# commented out # => previous annotation
|
166
|
-
1
|
163
|
+
1 # =>
|
164
|
+
# =>
|
167
165
|
# normal comment
|
166
|
+
|
167
|
+
{foo: 42, bar: {baz: 1, buz: 2, fuz: 3}, wibble: {magic_word: "xyzzy"}}
|
168
|
+
# =>
|
168
169
|
"""
|
169
170
|
|
170
171
|
|
171
|
-
|
172
|
-
Scenario:
|
173
|
-
Given the file "
|
172
|
+
# Not totally in love with this, but it'll do unless I can think of something better.
|
173
|
+
Scenario: Error raised on an annotated line preserves the annotation
|
174
|
+
Given the file "error_on_annotated_line.a.rb":
|
174
175
|
"""
|
175
|
-
|
176
|
-
def obj.inspect
|
177
|
-
" 1 \n2 2\n"
|
178
|
-
end
|
179
|
-
obj
|
176
|
+
"a"+1 # =>
|
180
177
|
# =>
|
181
178
|
"""
|
182
|
-
When I run "seeing_is_believing -
|
183
|
-
Then stdout
|
179
|
+
When I run "seeing_is_believing --xmpfilter-style error_on_annotated_line.a.rb"
|
180
|
+
Then stdout includes:
|
184
181
|
"""
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
end
|
189
|
-
obj
|
190
|
-
# => 1
|
191
|
-
# 2 2
|
182
|
+
"a"+1 # => TypeError:
|
183
|
+
"""
|
184
|
+
And stdout includes:
|
192
185
|
"""
|
186
|
+
# =>
|
193
187
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
Given the file "error_on_annotated_line.rb":
|
188
|
+
# ~> TypeError
|
189
|
+
"""
|
190
|
+
Given the file "error_on_annotated_line.b.rb":
|
198
191
|
"""
|
199
|
-
a # =>
|
192
|
+
"a"+"1" # => TypeError: no implicit conversion of Fixnum into String
|
193
|
+
# =>
|
194
|
+
|
195
|
+
# ~> TypeError
|
196
|
+
# ~> no implicit conversion of Fixnum into String
|
200
197
|
"""
|
201
|
-
When I run "seeing_is_believing --xmpfilter-style error_on_annotated_line.rb"
|
202
|
-
Then
|
198
|
+
When I run "seeing_is_believing --xmpfilter-style error_on_annotated_line.b.rb"
|
199
|
+
Then stdout is:
|
203
200
|
"""
|
204
|
-
|
205
|
-
|
201
|
+
"a"+"1" # => "a1"
|
202
|
+
# => "a1"
|
206
203
|
"""
|
207
204
|
|
208
205
|
|
206
|
+
# maybe can't fix this as it depends on the implementation of PP.pp
|
209
207
|
@not-implemented
|
210
208
|
Scenario: It can record values even when method is overridden
|
211
209
|
Given the file "pretty_inspect_with_method_overridden.rb":
|
@@ -219,3 +217,150 @@ Feature: Xmpfilter style
|
|
219
217
|
def method()end; self # => main
|
220
218
|
# => main
|
221
219
|
"""
|
220
|
+
|
221
|
+
|
222
|
+
# Choosing this output style b/c it's what xmpfilter chooses,
|
223
|
+
# and it works conveniently with what's already in place.
|
224
|
+
#
|
225
|
+
# It looks better with the comma on the preceding line, but harder to identify the individual results.
|
226
|
+
#
|
227
|
+
# It looks better with an empty line between the results, but if the user strips trailing whitespace inbetween runs,
|
228
|
+
# it will confuse the annotations for normal comments.
|
229
|
+
#
|
230
|
+
# Might be cool to have it do a value comment before each result, instead of a comma.
|
231
|
+
# But at present, it doesn't wipe out "useless" value comments,
|
232
|
+
# e.g. cleaning this would leave three value markers after the hash.
|
233
|
+
Scenario: Multiline output that is repeatedly invoked
|
234
|
+
Given the file "mutltiline_output_repeatedly_invoked.rb":
|
235
|
+
"""
|
236
|
+
3.times do
|
237
|
+
{foo: 42, bar: {baz: 1, buz: 2, fuz: 3}, wibble: {magic_word: "xyzzy"}}
|
238
|
+
# =>
|
239
|
+
end
|
240
|
+
"""
|
241
|
+
When I run "seeing_is_believing -x mutltiline_output_repeatedly_invoked.rb"
|
242
|
+
Then stdout is:
|
243
|
+
"""
|
244
|
+
3.times do
|
245
|
+
{foo: 42, bar: {baz: 1, buz: 2, fuz: 3}, wibble: {magic_word: "xyzzy"}}
|
246
|
+
# => {:foo=>42,
|
247
|
+
# :bar=>{:baz=>1, :buz=>2, :fuz=>3},
|
248
|
+
# :wibble=>{:magic_word=>"xyzzy"}}
|
249
|
+
# ,{:foo=>42,
|
250
|
+
# :bar=>{:baz=>1, :buz=>2, :fuz=>3},
|
251
|
+
# :wibble=>{:magic_word=>"xyzzy"}}
|
252
|
+
# ,{:foo=>42,
|
253
|
+
# :bar=>{:baz=>1, :buz=>2, :fuz=>3},
|
254
|
+
# :wibble=>{:magic_word=>"xyzzy"}}
|
255
|
+
end
|
256
|
+
"""
|
257
|
+
When I run "seeing_is_believing -x mutltiline_output_repeatedly_invoked.rb | seeing_is_believing -x"
|
258
|
+
Then stdout is:
|
259
|
+
"""
|
260
|
+
3.times do
|
261
|
+
{foo: 42, bar: {baz: 1, buz: 2, fuz: 3}, wibble: {magic_word: "xyzzy"}}
|
262
|
+
# => {:foo=>42,
|
263
|
+
# :bar=>{:baz=>1, :buz=>2, :fuz=>3},
|
264
|
+
# :wibble=>{:magic_word=>"xyzzy"}}
|
265
|
+
# ,{:foo=>42,
|
266
|
+
# :bar=>{:baz=>1, :buz=>2, :fuz=>3},
|
267
|
+
# :wibble=>{:magic_word=>"xyzzy"}}
|
268
|
+
# ,{:foo=>42,
|
269
|
+
# :bar=>{:baz=>1, :buz=>2, :fuz=>3},
|
270
|
+
# :wibble=>{:magic_word=>"xyzzy"}}
|
271
|
+
end
|
272
|
+
"""
|
273
|
+
|
274
|
+
|
275
|
+
Scenario: Multiline values where the first line is indented more than the successive lines use a nonbreaking space
|
276
|
+
Given the file "inspect_tree.rb":
|
277
|
+
"""
|
278
|
+
bst = Object.new
|
279
|
+
def bst.inspect
|
280
|
+
" 4\n"\
|
281
|
+
" 2 6\n"\
|
282
|
+
"1 3 5 7\n"
|
283
|
+
end
|
284
|
+
bst
|
285
|
+
# =>
|
286
|
+
"""
|
287
|
+
When I run "seeing_is_believing --xmpfilter-style inspect_tree.rb"
|
288
|
+
# NOTE: The first space after the => is a nonbreaking space
|
289
|
+
Then stdout is:
|
290
|
+
"""
|
291
|
+
bst = Object.new
|
292
|
+
def bst.inspect
|
293
|
+
" 4\n"\
|
294
|
+
" 2 6\n"\
|
295
|
+
"1 3 5 7\n"
|
296
|
+
end
|
297
|
+
bst
|
298
|
+
# => 4
|
299
|
+
# 2 6
|
300
|
+
# 1 3 5 7
|
301
|
+
"""
|
302
|
+
|
303
|
+
|
304
|
+
Scenario: Leading whitespace on nextline, but not multiline uses normal spaces
|
305
|
+
Given the file "nextline_with_leading_whitespace_but_not_multiline.rb":
|
306
|
+
"""
|
307
|
+
o = Object.new
|
308
|
+
def o.inspect; " o" end
|
309
|
+
o
|
310
|
+
# =>
|
311
|
+
"""
|
312
|
+
When I run "seeing_is_believing --xmpfilter-style nextline_with_leading_whitespace_but_not_multiline.rb"
|
313
|
+
Then stdout is:
|
314
|
+
"""
|
315
|
+
o = Object.new
|
316
|
+
def o.inspect; " o" end
|
317
|
+
o
|
318
|
+
# => o
|
319
|
+
"""
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
Scenario: Xmpfilter uses the same comment formatting as normal
|
324
|
+
Given the file "xmpfilter_result_lengths.rb":
|
325
|
+
"""
|
326
|
+
$stdout.puts "a"*100
|
327
|
+
$stderr.puts "a"*100
|
328
|
+
|
329
|
+
"a" # =>
|
330
|
+
"aa" # =>
|
331
|
+
"aaa" # =>
|
332
|
+
"aaaa" # =>
|
333
|
+
|
334
|
+
{foo: 42, bar: {baz: 1, buz: 2, fuz: 3}, wibble: {magic_word: "xyzzy"}}
|
335
|
+
# =>
|
336
|
+
|
337
|
+
raise "a"*100
|
338
|
+
"""
|
339
|
+
When I run "seeing_is_believing -x --result-length 10 xmpfilter_result_lengths.rb"
|
340
|
+
Then stderr is empty
|
341
|
+
And stdout is:
|
342
|
+
"""
|
343
|
+
$stdout.puts "a"*100
|
344
|
+
$stderr.puts "a"*100
|
345
|
+
|
346
|
+
"a" # => "a"
|
347
|
+
"aa" # => "aa"
|
348
|
+
"aaa" # => "aaa"
|
349
|
+
"aaaa" # => "a...
|
350
|
+
|
351
|
+
{foo: 42, bar: {baz: 1, buz: 2, fuz: 3}, wibble: {magic_word: "xyzzy"}}
|
352
|
+
# => {:...
|
353
|
+
# :...
|
354
|
+
# :...
|
355
|
+
|
356
|
+
raise "a"*100 # ~> Ru...
|
357
|
+
|
358
|
+
# >> aa...
|
359
|
+
|
360
|
+
# !> aa...
|
361
|
+
|
362
|
+
# ~> Ru...
|
363
|
+
# ~> aa...
|
364
|
+
# ~>
|
365
|
+
# ~> xm...
|
366
|
+
"""
|