seeing_is_believing 2.2.0 → 3.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Changelog.md +33 -0
- data/bin/seeing_is_believing +1 -1
- data/features/errors.feature +3 -3
- data/features/examples.feature +6 -6
- data/features/flags.feature +51 -196
- data/features/regression.feature +12 -3
- data/features/safe.feature +33 -0
- data/features/support/env.rb +20 -0
- data/features/xmpfilter-style.feature +156 -0
- data/lib/seeing_is_believing.rb +17 -35
- data/lib/seeing_is_believing/binary.rb +81 -176
- data/lib/seeing_is_believing/binary/align_chunk.rb +5 -7
- data/lib/seeing_is_believing/binary/align_file.rb +4 -5
- data/lib/seeing_is_believing/binary/align_line.rb +4 -4
- data/lib/seeing_is_believing/binary/annotate_end_of_file.rb +60 -0
- data/lib/seeing_is_believing/binary/annotate_every_line.rb +64 -0
- data/lib/seeing_is_believing/binary/annotate_xmpfilter_style.rb +133 -0
- data/lib/seeing_is_believing/binary/comment_formatter.rb +19 -5
- data/lib/seeing_is_believing/binary/comment_lines.rb +1 -1
- data/lib/seeing_is_believing/binary/commentable_lines.rb +1 -1
- data/lib/seeing_is_believing/binary/interpret_flags.rb +149 -0
- data/lib/seeing_is_believing/binary/parse_args.rb +96 -104
- data/lib/seeing_is_believing/binary/remove_annotations.rb +95 -0
- data/lib/seeing_is_believing/binary/rewrite_comments.rb +8 -30
- data/lib/seeing_is_believing/code.rb +99 -0
- data/lib/seeing_is_believing/evaluate_by_moving_files.rb +27 -19
- data/lib/seeing_is_believing/evaluate_with_eval_in.rb +27 -0
- data/lib/seeing_is_believing/event_stream/consumer.rb +111 -0
- data/lib/seeing_is_believing/event_stream/events.rb +16 -0
- data/lib/seeing_is_believing/event_stream/producer.rb +106 -0
- data/lib/seeing_is_believing/event_stream/update_result.rb +21 -0
- data/lib/seeing_is_believing/inspect_expressions.rb +24 -0
- data/lib/seeing_is_believing/parser_helpers.rb +1 -11
- data/lib/seeing_is_believing/result.rb +14 -56
- data/lib/seeing_is_believing/the_matrix.rb +14 -14
- data/lib/seeing_is_believing/version.rb +1 -1
- data/lib/seeing_is_believing/wrap_expressions.rb +32 -9
- data/seeing_is_believing.gemspec +7 -7
- data/spec/binary/comment_formatter_spec.rb +169 -18
- data/spec/binary/comment_lines_spec.rb +1 -1
- data/spec/binary/interpret_flags_spec.rb +307 -0
- data/spec/binary/parse_args_spec.rb +93 -91
- data/spec/binary/{clean_body_spec.rb → remove_annotations_spec.rb} +29 -22
- data/spec/binary/rewrite_comments_spec.rb +13 -13
- data/spec/code_spec.rb +49 -0
- data/spec/debugger_spec.rb +1 -1
- data/spec/evaluate_by_moving_files_spec.rb +7 -3
- data/spec/event_stream_spec.rb +390 -0
- data/spec/hard_core_ensure_spec.rb +1 -1
- data/spec/seeing_is_believing_spec.rb +137 -40
- data/spec/spec_helper.rb +3 -3
- data/spec/wrap_expressions_spec.rb +48 -35
- metadata +58 -35
- data/lib/seeing_is_believing/binary/add_annotations.rb +0 -144
- data/lib/seeing_is_believing/binary/clean_body.rb +0 -95
- data/lib/seeing_is_believing/has_exception.rb +0 -27
- data/lib/seeing_is_believing/line.rb +0 -90
- data/spec/line_spec.rb +0 -86
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4baad8edd542826d976fb5439fe4523724e25c2
|
4
|
+
data.tar.gz: 806d6b1cb7b43dc168c7653ff9995b3dd1b37220
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74cde1ec9bd35565d7e49110210fadc6e8b9eb01538e78411138babf50abf5bc299a6cb592e3e7cc0d873c97c5549d8ddb5aa0a6a3e2eb07dc76130f433f077c
|
7
|
+
data.tar.gz: 57811be453dd99be97df3c4ed6a17b7a0329178776c2bce14a4247f13d51acac04f1d9ccfc9930a7ae55983b2f285e0ad6c351c703041cab3dafa071e09f8941
|
data/.gitignore
CHANGED
data/Changelog.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
The Changelog was introduced on 2014-09-15, and is approximately in
|
4
|
+
accordance with [http://keepachangelog.com/](http://keepachangelog.com/).
|
5
|
+
I do my best to follow [Semantic Versioning](http://semver.org/).
|
6
|
+
|
7
|
+
## 3.0.0.beta - 2014-??-??
|
8
|
+
### Added
|
9
|
+
- Issue for 3.0 is at https://github.com/JoshCheek/seeing_is_believing/issues/47
|
10
|
+
- Added a [Changelog](Changelog.md) in accordance with [http://keepachangelog.com/](http://keepachangelog.com/)
|
11
|
+
- `seeing_is_believing/version` is required by default,
|
12
|
+
you can now check your version by just typing `SeeingIsBelieving::VERSION` and running it.
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
- Communication between SiB and the process running the code is no longer done by
|
16
|
+
serializing the result with JSON. Now, there is an
|
17
|
+
[EventStream](https://github.com/JoshCheek/seeing_is_believing/blob/4b9134ca45e001ebe5f139384bd1beee98b5e371/lib/seeing_is_believing/event_stream.rb)
|
18
|
+
class, which will send the information back to the parent process as soon as it
|
19
|
+
knows about it. For users who interact purely with the binary, this just means that
|
20
|
+
JSON will not already be required.
|
21
|
+
- WrapExpressions' `before_all` and `after_all` keys now point to values that are lambdas with no args.
|
22
|
+
Mostly this is for consistency since `before_each` and `after_each` are lambas,
|
23
|
+
But also, because at some point I might want to provide an argument, and this will make it easier.
|
24
|
+
And because it allows certain conveniences, such as setting local vars in the lambda.
|
25
|
+
- Loosened version constraints on parser dependency
|
26
|
+
- When you iterate over the result, it iterates over a result for each line of the file
|
27
|
+
rather than the number of lines it actually captured.
|
28
|
+
- The `--JSON` flag emits a different structure
|
29
|
+
|
30
|
+
### Removed
|
31
|
+
- Dependency on psych
|
32
|
+
- Remove HasException module. The only thing using it now is Result, so just relevant behaviour into there.
|
33
|
+
- SeeingIsBelieving::Line class
|
data/bin/seeing_is_believing
CHANGED
data/features/errors.feature
CHANGED
@@ -3,7 +3,7 @@ Feature: Running the binary unsuccessfully
|
|
3
3
|
Sometimes I mess up and use the program in a way that doesn't work.
|
4
4
|
I'd like it to be helpful in these situations so I can fix my use.
|
5
5
|
|
6
|
-
# show that it
|
6
|
+
# show that it displays next to the first place in the file
|
7
7
|
# and should maybe print the stacktrace at the bottom
|
8
8
|
Scenario: Raising exceptions
|
9
9
|
Given the file "raises_exception.rb":
|
@@ -29,11 +29,11 @@ Feature: Running the binary unsuccessfully
|
|
29
29
|
"""
|
30
30
|
def first_defined
|
31
31
|
second_defined
|
32
|
-
end
|
32
|
+
end # => {{method_result :first_defined}}
|
33
33
|
|
34
34
|
def second_defined
|
35
35
|
require_relative 'raises_exception' # ~> RuntimeError: ZOMG\n!!!!
|
36
|
-
end
|
36
|
+
end # => {{method_result :second_defined}}
|
37
37
|
|
38
38
|
first_defined
|
39
39
|
|
data/features/examples.feature
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Feature: Running the binary successfully
|
2
2
|
|
3
3
|
They say seeing is believing. So to believe that this works
|
4
|
-
I want to
|
4
|
+
I want to execute the actual binary and look at actual results.
|
5
5
|
|
6
|
-
It should
|
7
|
-
|
6
|
+
It should generally record every line of code and display the results
|
7
|
+
adjacent to the line, with output and errors displayed at the end of the file.
|
8
8
|
|
9
9
|
Scenario: Some basic functionality
|
10
10
|
Given the file "basic_functionality.rb":
|
@@ -70,7 +70,7 @@ Feature: Running the binary successfully
|
|
70
70
|
# method and invocations
|
71
71
|
def meth(n)
|
72
72
|
n # => "12", "34"
|
73
|
-
end
|
73
|
+
end # => {{method_result :meth}}
|
74
74
|
|
75
75
|
meth "12" # => "12"
|
76
76
|
meth "34" # => "34"
|
@@ -100,11 +100,11 @@ Feature: Running the binary successfully
|
|
100
100
|
class User
|
101
101
|
def initialize(name)
|
102
102
|
@name = name # => "Josh", "Rick"
|
103
|
-
end
|
103
|
+
end # => {{method_result :initialize}}
|
104
104
|
|
105
105
|
def name
|
106
106
|
@name # => "Josh", "Rick"
|
107
|
-
end
|
107
|
+
end # => {{method_result :name}}
|
108
108
|
end
|
109
109
|
|
110
110
|
User.new("Josh").name # => "Josh"
|
data/features/flags.feature
CHANGED
@@ -1,107 +1,7 @@
|
|
1
1
|
Feature: Using flags
|
2
2
|
|
3
3
|
Sometimes you want more control over what comes out, for that we give you flags.
|
4
|
-
|
5
|
-
|
6
|
-
Scenario: --start-line
|
7
|
-
Given the file "start_line.rb":
|
8
|
-
"""
|
9
|
-
1 + 1
|
10
|
-
2
|
11
|
-
3
|
12
|
-
"""
|
13
|
-
When I run "seeing_is_believing -s file --start-line 2 start_line.rb"
|
14
|
-
Then stderr is empty
|
15
|
-
And the exit status is 0
|
16
|
-
And stdout is:
|
17
|
-
"""
|
18
|
-
1 + 1
|
19
|
-
2 # => 2
|
20
|
-
3 # => 3
|
21
|
-
"""
|
22
|
-
When I run "seeing_is_believing -s chunk --start-line 2 start_line.rb"
|
23
|
-
Then stdout is:
|
24
|
-
"""
|
25
|
-
1 + 1
|
26
|
-
2 # => 2
|
27
|
-
3 # => 3
|
28
|
-
"""
|
29
|
-
When I run "seeing_is_believing -s line --start-line 2 start_line.rb"
|
30
|
-
Then stdout is:
|
31
|
-
"""
|
32
|
-
1 + 1
|
33
|
-
2 # => 2
|
34
|
-
3 # => 3
|
35
|
-
"""
|
36
|
-
|
37
|
-
|
38
|
-
Scenario: --end-line
|
39
|
-
Given the file "end_line.rb":
|
40
|
-
"""
|
41
|
-
1
|
42
|
-
2
|
43
|
-
3 + 3
|
44
|
-
"""
|
45
|
-
When I run "seeing_is_believing -s file --end-line 2 end_line.rb"
|
46
|
-
Then stderr is empty
|
47
|
-
And the exit status is 0
|
48
|
-
And stdout is:
|
49
|
-
"""
|
50
|
-
1 # => 1
|
51
|
-
2 # => 2
|
52
|
-
3 + 3
|
53
|
-
"""
|
54
|
-
When I run "seeing_is_believing -s chunk --end-line 2 end_line.rb"
|
55
|
-
Then stdout is:
|
56
|
-
"""
|
57
|
-
1 # => 1
|
58
|
-
2 # => 2
|
59
|
-
3 + 3
|
60
|
-
"""
|
61
|
-
When I run "seeing_is_believing -s line --end-line 2 end_line.rb"
|
62
|
-
Then stdout is:
|
63
|
-
"""
|
64
|
-
1 # => 1
|
65
|
-
2 # => 2
|
66
|
-
3 + 3
|
67
|
-
"""
|
68
|
-
|
69
|
-
|
70
|
-
Scenario: --start-line and --end-line
|
71
|
-
Given the file "start_and_end_line.rb":
|
72
|
-
"""
|
73
|
-
1 + 1
|
74
|
-
2
|
75
|
-
3
|
76
|
-
4 + 4
|
77
|
-
"""
|
78
|
-
When I run "seeing_is_believing -s file --start-line 2 --end-line 3 start_and_end_line.rb"
|
79
|
-
Then stderr is empty
|
80
|
-
And the exit status is 0
|
81
|
-
And stdout is:
|
82
|
-
"""
|
83
|
-
1 + 1
|
84
|
-
2 # => 2
|
85
|
-
3 # => 3
|
86
|
-
4 + 4
|
87
|
-
"""
|
88
|
-
When I run "seeing_is_believing -s chunk --start-line 2 --end-line 3 start_and_end_line.rb"
|
89
|
-
Then stdout is:
|
90
|
-
"""
|
91
|
-
1 + 1
|
92
|
-
2 # => 2
|
93
|
-
3 # => 3
|
94
|
-
4 + 4
|
95
|
-
"""
|
96
|
-
When I run "seeing_is_believing -s line --start-line 2 --end-line 3 start_and_end_line.rb"
|
97
|
-
Then stdout is:
|
98
|
-
"""
|
99
|
-
1 + 1
|
100
|
-
2 # => 2
|
101
|
-
3 # => 3
|
102
|
-
4 + 4
|
103
|
-
"""
|
104
|
-
|
4
|
+
Note that some flags are significant enough to have their own file.
|
105
5
|
|
106
6
|
Scenario: --result-length sets the length of the portion including and after the # =>
|
107
7
|
Given the file "result_lengths.rb":
|
@@ -184,6 +84,7 @@ Feature: Using flags
|
|
184
84
|
When I run "seeing_is_believing --line-length 14 line_lengths2.rb"
|
185
85
|
Then stdout is "12345"
|
186
86
|
|
87
|
+
|
187
88
|
Scenario: --number-of-captures determines how many times a line will be recorded
|
188
89
|
Given the file "number_of_captures.rb":
|
189
90
|
"""
|
@@ -206,25 +107,12 @@ Feature: Using flags
|
|
206
107
|
end # => 5
|
207
108
|
"""
|
208
109
|
|
209
|
-
Scenario: --xmpfilter-style respects the line formatting (but not currently alignment strategies, it just preserves submitted alignment)
|
210
|
-
Given the file "line_lengths3.rb":
|
211
|
-
"""
|
212
|
-
'1' * 30 # =>
|
213
|
-
# =>
|
214
|
-
"""
|
215
|
-
When I run "seeing_is_believing --xmpfilter-style --line-length 19 line_lengths3.rb"
|
216
|
-
Then stdout is:
|
217
|
-
"""
|
218
|
-
'1' * 30 # => "1...
|
219
|
-
# => "1111111111...
|
220
|
-
"""
|
221
|
-
|
222
110
|
|
223
111
|
Scenario: --require
|
224
|
-
Given the file "
|
225
|
-
Given the file "
|
226
|
-
And the file "
|
227
|
-
When I run "seeing_is_believing --require ./
|
112
|
+
Given the file "r_print_1.rb" "puts 1"
|
113
|
+
Given the file "r_print_2.rb" "puts 2"
|
114
|
+
And the file "r_print_3.rb" "puts 3"
|
115
|
+
When I run "seeing_is_believing --require ./r_print_1 --require ./r_print_2 r_print_3.rb"
|
228
116
|
Then stderr is empty
|
229
117
|
And the exit status is 0
|
230
118
|
And stdout is:
|
@@ -248,16 +136,16 @@ Feature: Using flags
|
|
248
136
|
|
249
137
|
|
250
138
|
Scenario: --load-path
|
251
|
-
Given the file "
|
252
|
-
And the file "some_dir/
|
253
|
-
And the file "
|
254
|
-
When I run "seeing_is_believing
|
139
|
+
Given the file "lp_print_1.rb" "puts 1"
|
140
|
+
And the file "some_dir/lp_print_2.rb" "puts 2"
|
141
|
+
And the file "require_lp_print_1.rb" "require 'lp_print_1'"
|
142
|
+
When I run "seeing_is_believing require_lp_print_1.rb"
|
255
143
|
Then the exit status is 1
|
256
|
-
When I run "seeing_is_believing --load-path . -I ./some_dir -r
|
144
|
+
When I run "seeing_is_believing --load-path . -I ./some_dir -r lp_print_2 require_lp_print_1.rb"
|
257
145
|
Then stderr is empty
|
258
146
|
And stdout is:
|
259
147
|
"""
|
260
|
-
require '
|
148
|
+
require 'lp_print_1' # => true
|
261
149
|
|
262
150
|
# >> 2
|
263
151
|
# >> 1
|
@@ -277,32 +165,36 @@ Feature: Using flags
|
|
277
165
|
|
278
166
|
|
279
167
|
Scenario: --as and stdin
|
280
|
-
Given the file "example.rb" "1+1"
|
281
168
|
Given the stdin content:
|
282
169
|
"""
|
283
|
-
1+1
|
284
170
|
__FILE__
|
285
171
|
"""
|
286
|
-
When I run "seeing_is_believing --as
|
172
|
+
When I run "seeing_is_believing --as as_and_stdin.rb"
|
287
173
|
Then stderr is empty
|
288
174
|
Then the exit status is 0
|
289
175
|
And stdout is:
|
290
176
|
"""
|
291
|
-
|
292
|
-
__FILE__ # => "example.rb"
|
177
|
+
__FILE__ # => "as_and_stdin.rb"
|
293
178
|
"""
|
294
179
|
|
295
180
|
|
296
181
|
Scenario: --as and -e
|
297
|
-
|
298
|
-
When I run 'seeing_is_believing --as example.rb -e "__FILE__"'
|
182
|
+
When I run 'seeing_is_believing --as as_and_e.rb -e "__FILE__"'
|
299
183
|
Then stderr is empty
|
300
184
|
And the exit status is 0
|
301
|
-
And stdout is '__FILE__ # => "
|
185
|
+
And stdout is '__FILE__ # => "as_and_e.rb"'
|
186
|
+
|
187
|
+
|
188
|
+
Scenario: --as and filename
|
189
|
+
Given the file "as_and_filename.rb" "__FILE__"
|
190
|
+
When I run 'seeing_is_believing as_and_filename.rb --as not_as_and_filename.rb'
|
191
|
+
Then stderr is empty
|
192
|
+
And the exit status is 0
|
193
|
+
And stdout is '__FILE__ # => "not_as_and_filename.rb"'
|
302
194
|
|
303
195
|
|
304
196
|
Scenario: --clean
|
305
|
-
Given the file "
|
197
|
+
Given the file "uncleaned.rb":
|
306
198
|
"""
|
307
199
|
1 + 1 # => not 2
|
308
200
|
2 + 2 # ~> Exception, something
|
@@ -314,7 +206,7 @@ Feature: Using flags
|
|
314
206
|
__END__
|
315
207
|
1
|
316
208
|
"""
|
317
|
-
When I run "seeing_is_believing --clean
|
209
|
+
When I run "seeing_is_believing --clean uncleaned.rb"
|
318
210
|
Then stderr is empty
|
319
211
|
And the exit status is 0
|
320
212
|
And stdout is:
|
@@ -348,6 +240,7 @@ Feature: Using flags
|
|
348
240
|
And stdout includes "Usage"
|
349
241
|
And stdout does not include "Examples:"
|
350
242
|
|
243
|
+
|
351
244
|
Scenario: --help+
|
352
245
|
When I run "seeing_is_believing --help+"
|
353
246
|
Then stderr is empty
|
@@ -357,16 +250,16 @@ Feature: Using flags
|
|
357
250
|
|
358
251
|
|
359
252
|
Scenario: --timeout
|
360
|
-
Given the file "
|
361
|
-
When I run "seeing_is_believing --timeout 0.1
|
253
|
+
Given the file "will_timeout.rb" "sleep 1"
|
254
|
+
When I run "seeing_is_believing --timeout 0.1 will_timeout.rb"
|
362
255
|
Then stdout is empty
|
363
256
|
And the exit status is 2
|
364
257
|
And stderr is "Timeout Error after 0.1 seconds!"
|
365
258
|
|
366
259
|
|
367
260
|
Scenario: --timeout
|
368
|
-
Given the file "
|
369
|
-
When I run "seeing_is_believing --timeout 1.0
|
261
|
+
Given the file "will_not_timeout.rb" "1 + 1"
|
262
|
+
When I run "seeing_is_believing --timeout 1.0 will_not_timeout.rb"
|
370
263
|
Then stderr is empty
|
371
264
|
And the exit status is 0
|
372
265
|
And stdout is "1 + 1 # => 2"
|
@@ -399,6 +292,7 @@ Feature: Using flags
|
|
399
292
|
1 + 1 + 1 # => 3
|
400
293
|
"""
|
401
294
|
|
295
|
+
|
402
296
|
Scenario: --alignment-strategy chunk
|
403
297
|
Given the file "chunk_alignments.rb":
|
404
298
|
"""
|
@@ -442,6 +336,7 @@ Feature: Using flags
|
|
442
336
|
1 + 1 # => 2
|
443
337
|
"""
|
444
338
|
|
339
|
+
|
445
340
|
Scenario: --alignment-strategy line
|
446
341
|
Given the file "line_alignments.rb":
|
447
342
|
"""
|
@@ -469,6 +364,7 @@ Feature: Using flags
|
|
469
364
|
1 + 1 + 1 # => 3
|
470
365
|
"""
|
471
366
|
|
367
|
+
|
472
368
|
Scenario: --inherit-exit-status
|
473
369
|
Given the file "exit_status.rb" "exit 123"
|
474
370
|
When I run "seeing_is_believing exit_status.rb"
|
@@ -494,40 +390,6 @@ Feature: Using flags
|
|
494
390
|
Then the exit status is 10
|
495
391
|
|
496
392
|
|
497
|
-
Scenario: --xmpfilter-style
|
498
|
-
Given the file "magic_comments.rb":
|
499
|
-
"""
|
500
|
-
1+1# =>
|
501
|
-
2+2 # => 10
|
502
|
-
"a
|
503
|
-
b" # =>
|
504
|
-
/a
|
505
|
-
b/ # =>
|
506
|
-
1
|
507
|
-
"omg"
|
508
|
-
# =>
|
509
|
-
"omg2"
|
510
|
-
# => "not omg2"
|
511
|
-
"""
|
512
|
-
When I run "seeing_is_believing --xmpfilter-style magic_comments.rb"
|
513
|
-
Then stderr is empty
|
514
|
-
And the exit status is 0
|
515
|
-
And stdout is:
|
516
|
-
"""
|
517
|
-
1+1# => 2
|
518
|
-
2+2 # => 4
|
519
|
-
"a
|
520
|
-
b" # => "a\n b"
|
521
|
-
/a
|
522
|
-
b/ # => /a\n b/
|
523
|
-
1
|
524
|
-
"omg"
|
525
|
-
# => "omg"
|
526
|
-
"omg2"
|
527
|
-
# => "omg2"
|
528
|
-
"""
|
529
|
-
|
530
|
-
|
531
393
|
Scenario: --debug
|
532
394
|
Given the file "simple_program.rb":
|
533
395
|
"""
|
@@ -550,24 +412,22 @@ Feature: Using flags
|
|
550
412
|
2 # => 2
|
551
413
|
"""
|
552
414
|
|
415
|
+
|
553
416
|
Scenario: --shebang
|
554
417
|
Given the file "fake_ruby":
|
555
418
|
"""
|
556
419
|
#!/usr/bin/env ruby
|
557
|
-
# yes, this uses knowledge of where the proving grounds is
|
558
420
|
$LOAD_PATH.unshift File.expand_path "{{Haiti.config.proving_grounds_dir}}/../lib", __FILE__
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
require 'json'
|
565
|
-
puts JSON.dump result.to_primitive
|
421
|
+
require 'seeing_is_believing/event_stream/producer'
|
422
|
+
sib = SeeingIsBelieving::EventStream::Producer.new($stdout)
|
423
|
+
sib.record_result(:inspect, 1, /omg/)
|
424
|
+
sib.finish!
|
566
425
|
"""
|
567
426
|
When I run "chmod +x fake_ruby"
|
568
427
|
When I run "seeing_is_believing -e 123 --shebang ./fake_ruby"
|
569
428
|
Then stdout is "123 # => /omg/"
|
570
429
|
|
430
|
+
|
571
431
|
Scenario: --json
|
572
432
|
Given the file "all_kinds_of_output.rb":
|
573
433
|
"""
|
@@ -579,22 +439,17 @@ Feature: Using flags
|
|
579
439
|
raise "omg"
|
580
440
|
"""
|
581
441
|
When I run "seeing_is_believing --json all_kinds_of_output.rb"
|
582
|
-
Then
|
583
|
-
And
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
"1":
|
588
|
-
"2":
|
589
|
-
"3":
|
590
|
-
"4":
|
591
|
-
"5":
|
592
|
-
"6":
|
593
|
-
"message": "omg",
|
594
|
-
"backtrace": ["all_kinds_of_output.rb:6:in `<main>'"]
|
595
|
-
},
|
596
|
-
"results": []
|
597
|
-
}
|
442
|
+
Then stderr is empty
|
443
|
+
And the exit status is 0
|
444
|
+
And stdout is the JSON:
|
445
|
+
"""
|
446
|
+
{ "lines": {
|
447
|
+
"1": ["3"],
|
448
|
+
"2": ["\"0\"", "\"1\"", "\"2\""],
|
449
|
+
"3": ["3"],
|
450
|
+
"4": ["nil"],
|
451
|
+
"5": ["nil"],
|
452
|
+
"6": []
|
598
453
|
},
|
599
454
|
"exception": {
|
600
455
|
"line_number_in_this_file": 6,
|