awesome_print 1.2.0 → 1.6.1
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 +7 -0
- data/.gitignore +10 -2
- data/Appraisals +39 -0
- data/CHANGELOG +22 -3
- data/CONTRIBUTING.md +41 -0
- data/Gemfile +3 -2
- data/Gemfile.lock +29 -12
- data/LICENSE +1 -1
- data/README.md +20 -0
- data/Rakefile +14 -1
- data/lib/ap.rb +0 -0
- data/lib/awesome_print/ext/active_record.rb +2 -1
- data/lib/awesome_print/ext/mongoid.rb +1 -1
- data/lib/awesome_print/ext/ostruct.rb +27 -0
- data/lib/awesome_print/ext/ripple.rb +1 -1
- data/lib/awesome_print/formatter.rb +1 -1
- data/lib/awesome_print/inspector.rb +0 -0
- data/lib/awesome_print/version.rb +1 -1
- data/lib/awesome_print.rb +6 -1
- data/spec/active_record_helper.rb +34 -0
- data/spec/colors_spec.rb +8 -8
- data/spec/formats_spec.rb +70 -70
- data/spec/methods_spec.rb +61 -61
- data/spec/misc_spec.rb +53 -34
- data/spec/objects_spec.rb +6 -6
- data/spec/spec_helper.rb +5 -1
- metadata +66 -24
data/spec/formats_spec.rb
CHANGED
|
@@ -14,11 +14,11 @@ describe "AwesomePrint" do
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it "empty array" do
|
|
17
|
-
[].ai.
|
|
17
|
+
expect([].ai).to eq("[]")
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "plain multiline" do
|
|
21
|
-
@arr.ai(:plain => true).
|
|
21
|
+
expect(@arr.ai(:plain => true)).to eq <<-EOS.strip
|
|
22
22
|
[
|
|
23
23
|
[0] 1,
|
|
24
24
|
[1] :two,
|
|
@@ -35,7 +35,7 @@ EOS
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it "plain multiline without index" do
|
|
38
|
-
@arr.ai(:plain => true, :index => false).
|
|
38
|
+
expect(@arr.ai(:plain => true, :index => false)).to eq <<-EOS.strip
|
|
39
39
|
[
|
|
40
40
|
1,
|
|
41
41
|
:two,
|
|
@@ -52,7 +52,7 @@ EOS
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
it "plain multiline indented" do
|
|
55
|
-
@arr.ai(:plain => true, :indent => 2).
|
|
55
|
+
expect(@arr.ai(:plain => true, :indent => 2)).to eq <<-EOS.strip
|
|
56
56
|
[
|
|
57
57
|
[0] 1,
|
|
58
58
|
[1] :two,
|
|
@@ -69,7 +69,7 @@ EOS
|
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
it "plain multiline indented without index" do
|
|
72
|
-
@arr.ai(:plain => true, :indent => 2, :index => false).
|
|
72
|
+
expect(@arr.ai(:plain => true, :indent => 2, :index => false)).to eq <<-EOS.strip
|
|
73
73
|
[
|
|
74
74
|
1,
|
|
75
75
|
:two,
|
|
@@ -86,11 +86,11 @@ EOS
|
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
it "plain single line" do
|
|
89
|
-
@arr.ai(:plain => true, :multiline => false).
|
|
89
|
+
expect(@arr.ai(:plain => true, :multiline => false)).to eq('[ 1, :two, "three", [ nil, [ true, false ] ] ]')
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
it "colored multiline (default)" do
|
|
93
|
-
@arr.ai.
|
|
93
|
+
expect(@arr.ai).to eq <<-EOS.strip
|
|
94
94
|
[
|
|
95
95
|
\e[1;37m[0] \e[0m\e[1;34m1\e[0m,
|
|
96
96
|
\e[1;37m[1] \e[0m\e[0;36m:two\e[0m,
|
|
@@ -107,7 +107,7 @@ EOS
|
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
it "colored multiline indented" do
|
|
110
|
-
@arr.ai(:indent => 8).
|
|
110
|
+
expect(@arr.ai(:indent => 8)).to eq <<-EOS.strip
|
|
111
111
|
[
|
|
112
112
|
\e[1;37m[0] \e[0m\e[1;34m1\e[0m,
|
|
113
113
|
\e[1;37m[1] \e[0m\e[0;36m:two\e[0m,
|
|
@@ -124,7 +124,7 @@ EOS
|
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
it "colored single line" do
|
|
127
|
-
@arr.ai(:multiline => false).
|
|
127
|
+
expect(@arr.ai(:multiline => false)).to eq("[ \e[1;34m1\e[0m, \e[0;36m:two\e[0m, \e[0;33m\"three\"\e[0m, [ \e[1;31mnil\e[0m, [ \e[1;32mtrue\e[0m, \e[1;31mfalse\e[0m ] ] ]")
|
|
128
128
|
end
|
|
129
129
|
end
|
|
130
130
|
|
|
@@ -136,7 +136,7 @@ EOS
|
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
it "plain multiline" do
|
|
139
|
-
@arr.ai(:plain => true).
|
|
139
|
+
expect(@arr.ai(:plain => true)).to eq <<-EOS.strip
|
|
140
140
|
[
|
|
141
141
|
[0] 1,
|
|
142
142
|
[1] 2,
|
|
@@ -146,7 +146,7 @@ EOS
|
|
|
146
146
|
end
|
|
147
147
|
|
|
148
148
|
it "plain multiline without index" do
|
|
149
|
-
@arr.ai(:plain => true, :index => false).
|
|
149
|
+
expect(@arr.ai(:plain => true, :index => false)).to eq <<-EOS.strip
|
|
150
150
|
[
|
|
151
151
|
1,
|
|
152
152
|
2,
|
|
@@ -156,7 +156,7 @@ EOS
|
|
|
156
156
|
end
|
|
157
157
|
|
|
158
158
|
it "plain single line" do
|
|
159
|
-
@arr.ai(:plain => true, :multiline => false).
|
|
159
|
+
expect(@arr.ai(:plain => true, :multiline => false)).to eq("[ 1, 2, [...] ]")
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
162
|
|
|
@@ -167,7 +167,7 @@ EOS
|
|
|
167
167
|
end
|
|
168
168
|
|
|
169
169
|
it "plain limited output large" do
|
|
170
|
-
@arr.ai(:plain => true, :limit => true).
|
|
170
|
+
expect(@arr.ai(:plain => true, :limit => true)).to eq <<-EOS.strip
|
|
171
171
|
[
|
|
172
172
|
[ 0] 1,
|
|
173
173
|
[ 1] 2,
|
|
@@ -182,7 +182,7 @@ EOS
|
|
|
182
182
|
|
|
183
183
|
it "plain limited output small" do
|
|
184
184
|
@arr = @arr[0..3]
|
|
185
|
-
@arr.ai(:plain => true, :limit => true).
|
|
185
|
+
expect(@arr.ai(:plain => true, :limit => true)).to eq <<-EOS.strip
|
|
186
186
|
[
|
|
187
187
|
[0] 1,
|
|
188
188
|
[1] 2,
|
|
@@ -193,7 +193,7 @@ EOS
|
|
|
193
193
|
end
|
|
194
194
|
|
|
195
195
|
it "plain limited output with 10 lines" do
|
|
196
|
-
@arr.ai(:plain => true, :limit => 10).
|
|
196
|
+
expect(@arr.ai(:plain => true, :limit => 10)).to eq <<-EOS.strip
|
|
197
197
|
[
|
|
198
198
|
[ 0] 1,
|
|
199
199
|
[ 1] 2,
|
|
@@ -210,7 +210,7 @@ EOS
|
|
|
210
210
|
end
|
|
211
211
|
|
|
212
212
|
it "plain limited output with 11 lines" do
|
|
213
|
-
@arr.ai(:plain => true, :limit => 11).
|
|
213
|
+
expect(@arr.ai(:plain => true, :limit => 11)).to eq <<-EOS.strip
|
|
214
214
|
[
|
|
215
215
|
[ 0] 1,
|
|
216
216
|
[ 1] 2,
|
|
@@ -235,7 +235,7 @@ EOS
|
|
|
235
235
|
end
|
|
236
236
|
|
|
237
237
|
it "plain limited output" do
|
|
238
|
-
@hash.ai(:sort_keys => true, :plain => true, :limit => true).
|
|
238
|
+
expect(@hash.ai(:sort_keys => true, :plain => true, :limit => true)).to eq <<-EOS.strip
|
|
239
239
|
{
|
|
240
240
|
"a" => :a,
|
|
241
241
|
"b" => :b,
|
|
@@ -254,13 +254,13 @@ EOS
|
|
|
254
254
|
before do
|
|
255
255
|
@hash = { 1 => { :sym => { "str" => { [1, 2, 3] => { { :k => :v } => Hash } } } } }
|
|
256
256
|
end
|
|
257
|
-
|
|
257
|
+
|
|
258
258
|
it "empty hash" do
|
|
259
|
-
{}.ai.
|
|
259
|
+
expect({}.ai).to eq("{}")
|
|
260
260
|
end
|
|
261
|
-
|
|
261
|
+
|
|
262
262
|
it "plain multiline" do
|
|
263
|
-
@hash.ai(:plain => true).
|
|
263
|
+
expect(@hash.ai(:plain => true)).to eq <<-EOS.strip
|
|
264
264
|
{
|
|
265
265
|
1 => {
|
|
266
266
|
:sym => {
|
|
@@ -276,7 +276,7 @@ EOS
|
|
|
276
276
|
end
|
|
277
277
|
|
|
278
278
|
it "plain multiline indented" do
|
|
279
|
-
@hash.ai(:plain => true, :indent => 1).
|
|
279
|
+
expect(@hash.ai(:plain => true, :indent => 1)).to eq <<-EOS.strip
|
|
280
280
|
{
|
|
281
281
|
1 => {
|
|
282
282
|
:sym => {
|
|
@@ -292,11 +292,11 @@ EOS
|
|
|
292
292
|
end
|
|
293
293
|
|
|
294
294
|
it "plain single line" do
|
|
295
|
-
@hash.ai(:plain => true, :multiline => false).
|
|
295
|
+
expect(@hash.ai(:plain => true, :multiline => false)).to eq('{ 1 => { :sym => { "str" => { [ 1, 2, 3 ] => { { :k => :v } => Hash < Object } } } } }')
|
|
296
296
|
end
|
|
297
297
|
|
|
298
298
|
it "colored multiline (default)" do
|
|
299
|
-
@hash.ai.
|
|
299
|
+
expect(@hash.ai).to eq <<-EOS.strip
|
|
300
300
|
{
|
|
301
301
|
1\e[0;37m => \e[0m{
|
|
302
302
|
:sym\e[0;37m => \e[0m{
|
|
@@ -312,7 +312,7 @@ EOS
|
|
|
312
312
|
end
|
|
313
313
|
|
|
314
314
|
it "colored multiline indented" do
|
|
315
|
-
@hash.ai(:indent => 2).
|
|
315
|
+
expect(@hash.ai(:indent => 2)).to eq <<-EOS.strip
|
|
316
316
|
{
|
|
317
317
|
1\e[0;37m => \e[0m{
|
|
318
318
|
:sym\e[0;37m => \e[0m{
|
|
@@ -328,7 +328,7 @@ EOS
|
|
|
328
328
|
end
|
|
329
329
|
|
|
330
330
|
it "colored single line" do
|
|
331
|
-
@hash.ai(:multiline => false).
|
|
331
|
+
expect(@hash.ai(:multiline => false)).to eq("{ 1\e[0;37m => \e[0m{ :sym\e[0;37m => \e[0m{ \"str\"\e[0;37m => \e[0m{ [ 1, 2, 3 ]\e[0;37m => \e[0m{ { :k => :v }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m } } } } }")
|
|
332
332
|
end
|
|
333
333
|
|
|
334
334
|
end
|
|
@@ -341,7 +341,7 @@ EOS
|
|
|
341
341
|
end
|
|
342
342
|
|
|
343
343
|
it "plain multiline" do
|
|
344
|
-
@hash.ai(:plain => true).
|
|
344
|
+
expect(@hash.ai(:plain => true)).to eq <<-EOS.strip
|
|
345
345
|
{
|
|
346
346
|
:a => {...}
|
|
347
347
|
}
|
|
@@ -349,7 +349,7 @@ EOS
|
|
|
349
349
|
end
|
|
350
350
|
|
|
351
351
|
it "plain single line" do
|
|
352
|
-
@hash.ai(:plain => true, :multiline => false).
|
|
352
|
+
expect(@hash.ai(:plain => true, :multiline => false)).to eq('{ :a => {...} }')
|
|
353
353
|
end
|
|
354
354
|
end
|
|
355
355
|
|
|
@@ -362,13 +362,13 @@ EOS
|
|
|
362
362
|
it "plain multiline" do
|
|
363
363
|
out = @hash.ai(:plain => true)
|
|
364
364
|
if RUBY_VERSION.to_f < 1.9 # Order of @hash keys is not guaranteed.
|
|
365
|
-
out.
|
|
366
|
-
out.
|
|
367
|
-
out.
|
|
368
|
-
out.
|
|
369
|
-
out.
|
|
365
|
+
expect(out).to match(/^\{[^\}]+\}/m)
|
|
366
|
+
expect(out).to match(/ "b" => "b",?/)
|
|
367
|
+
expect(out).to match(/ :a => "a",?/)
|
|
368
|
+
expect(out).to match(/ :z => "z",?/)
|
|
369
|
+
expect(out).to match(/ "alpha" => "alpha",?$/)
|
|
370
370
|
else
|
|
371
|
-
out.
|
|
371
|
+
expect(out).to eq <<-EOS.strip
|
|
372
372
|
{
|
|
373
373
|
"b" => "b",
|
|
374
374
|
:a => "a",
|
|
@@ -378,9 +378,9 @@ EOS
|
|
|
378
378
|
EOS
|
|
379
379
|
end
|
|
380
380
|
end
|
|
381
|
-
|
|
381
|
+
|
|
382
382
|
it "plain multiline with sorted keys" do
|
|
383
|
-
@hash.ai(:plain => true, :sort_keys => true).
|
|
383
|
+
expect(@hash.ai(:plain => true, :sort_keys => true)).to eq <<-EOS.strip
|
|
384
384
|
{
|
|
385
385
|
:a => "a",
|
|
386
386
|
"alpha" => "alpha",
|
|
@@ -401,7 +401,7 @@ EOS
|
|
|
401
401
|
it "hash keys must be left aligned" do
|
|
402
402
|
hash = { [0, 0, 255] => :yellow, :red => "rgb(255, 0, 0)", "magenta" => "rgb(255, 0, 255)" }
|
|
403
403
|
out = hash.ai(:plain => true, :indent => -4, :sort_keys => true)
|
|
404
|
-
out.
|
|
404
|
+
expect(out).to eq <<-EOS.strip
|
|
405
405
|
{
|
|
406
406
|
[ 0, 0, 255 ] => :yellow,
|
|
407
407
|
"magenta" => "rgb(255, 0, 255)",
|
|
@@ -413,7 +413,7 @@ EOS
|
|
|
413
413
|
it "nested hash keys should be indented (array of hashes)" do
|
|
414
414
|
arr = [ { :a => 1, :bb => 22, :ccc => 333}, { 1 => :a, 22 => :bb, 333 => :ccc} ]
|
|
415
415
|
out = arr.ai(:plain => true, :indent => -4, :sort_keys => true)
|
|
416
|
-
out.
|
|
416
|
+
expect(out).to eq <<-EOS.strip
|
|
417
417
|
[
|
|
418
418
|
[0] {
|
|
419
419
|
:a => 1,
|
|
@@ -432,7 +432,7 @@ EOS
|
|
|
432
432
|
it "nested hash keys should be indented (hash of hashes)" do
|
|
433
433
|
arr = { :first => { :a => 1, :bb => 22, :ccc => 333}, :second => { 1 => :a, 22 => :bb, 333 => :ccc} }
|
|
434
434
|
out = arr.ai(:plain => true, :indent => -4, :sort_keys => true)
|
|
435
|
-
out.
|
|
435
|
+
expect(out).to eq <<-EOS.strip
|
|
436
436
|
{
|
|
437
437
|
:first => {
|
|
438
438
|
:a => 1,
|
|
@@ -452,11 +452,11 @@ EOS
|
|
|
452
452
|
#------------------------------------------------------------------------------
|
|
453
453
|
describe "Class" do
|
|
454
454
|
it "shoud show superclass (plain)" do
|
|
455
|
-
self.class.ai(:plain => true).
|
|
455
|
+
expect(self.class.ai(:plain => true)).to eq("#{self.class} < #{self.class.superclass}")
|
|
456
456
|
end
|
|
457
457
|
|
|
458
458
|
it "shoud show superclass (color)" do
|
|
459
|
-
self.class.ai.
|
|
459
|
+
expect(self.class.ai).to eq("#{self.class} < #{self.class.superclass}".yellow)
|
|
460
460
|
end
|
|
461
461
|
end
|
|
462
462
|
|
|
@@ -464,7 +464,7 @@ EOS
|
|
|
464
464
|
describe "File" do
|
|
465
465
|
it "should display a file (plain)" do
|
|
466
466
|
File.open(__FILE__, "r") do |f|
|
|
467
|
-
f.ai(:plain => true).
|
|
467
|
+
expect(f.ai(:plain => true)).to eq("#{f.inspect}\n" << `ls -alF #{f.path}`.chop)
|
|
468
468
|
end
|
|
469
469
|
end
|
|
470
470
|
end
|
|
@@ -473,7 +473,7 @@ EOS
|
|
|
473
473
|
describe "Dir" do
|
|
474
474
|
it "should display a direcory (plain)" do
|
|
475
475
|
Dir.open(File.dirname(__FILE__)) do |d|
|
|
476
|
-
d.ai(:plain => true).
|
|
476
|
+
expect(d.ai(:plain => true)).to eq("#{d.inspect}\n" << `ls -alF #{d.path}`.chop)
|
|
477
477
|
end
|
|
478
478
|
end
|
|
479
479
|
end
|
|
@@ -482,7 +482,7 @@ EOS
|
|
|
482
482
|
describe "BigDecimal and Rational" do
|
|
483
483
|
it "should present BigDecimal object with arbitrary precision" do
|
|
484
484
|
big = BigDecimal("201020102010201020102010201020102010.4")
|
|
485
|
-
big.ai(:plain => true).
|
|
485
|
+
expect(big.ai(:plain => true)).to eq("201020102010201020102010201020102010.4")
|
|
486
486
|
end
|
|
487
487
|
|
|
488
488
|
it "should present Rational object with arbitrary precision" do
|
|
@@ -494,9 +494,9 @@ EOS
|
|
|
494
494
|
# http://www.ruby-forum.com/topic/189397
|
|
495
495
|
#
|
|
496
496
|
if RUBY_VERSION < "1.9"
|
|
497
|
-
out.
|
|
497
|
+
expect(out).to eq("100510051005100510051005100510051005")
|
|
498
498
|
else
|
|
499
|
-
out.
|
|
499
|
+
expect(out).to eq("100510051005100510051005100510051005/1")
|
|
500
500
|
end
|
|
501
501
|
end
|
|
502
502
|
end
|
|
@@ -507,8 +507,8 @@ EOS
|
|
|
507
507
|
ap = AwesomePrint::Inspector.new
|
|
508
508
|
ap.send(:merge_options!, { :color => { :array => :black }, :indent => 0 })
|
|
509
509
|
options = ap.instance_variable_get("@options")
|
|
510
|
-
options[:color][:array].
|
|
511
|
-
options[:indent].
|
|
510
|
+
expect(options[:color][:array]).to eq(:black)
|
|
511
|
+
expect(options[:indent]).to eq(0)
|
|
512
512
|
end
|
|
513
513
|
end
|
|
514
514
|
|
|
@@ -520,40 +520,40 @@ EOS
|
|
|
520
520
|
end
|
|
521
521
|
|
|
522
522
|
it "empty set" do
|
|
523
|
-
Set.new.ai.
|
|
523
|
+
expect(Set.new.ai).to eq([].ai)
|
|
524
524
|
end
|
|
525
525
|
|
|
526
526
|
if RUBY_VERSION > "1.9"
|
|
527
527
|
it "plain multiline" do
|
|
528
|
-
@set.ai(:plain => true).
|
|
528
|
+
expect(@set.ai(:plain => true)).to eq(@arr.ai(:plain => true))
|
|
529
529
|
end
|
|
530
530
|
|
|
531
531
|
it "plain multiline indented" do
|
|
532
|
-
@set.ai(:plain => true, :indent => 1).
|
|
532
|
+
expect(@set.ai(:plain => true, :indent => 1)).to eq(@arr.ai(:plain => true, :indent => 1))
|
|
533
533
|
end
|
|
534
534
|
|
|
535
535
|
it "plain single line" do
|
|
536
|
-
@set.ai(:plain => true, :multiline => false).
|
|
536
|
+
expect(@set.ai(:plain => true, :multiline => false)).to eq(@arr.ai(:plain => true, :multiline => false))
|
|
537
537
|
end
|
|
538
538
|
|
|
539
539
|
it "colored multiline (default)" do
|
|
540
|
-
@set.ai.
|
|
540
|
+
expect(@set.ai).to eq(@arr.ai)
|
|
541
541
|
end
|
|
542
542
|
else # Prior to Ruby 1.9 the order of set values is unpredicatble.
|
|
543
543
|
it "plain multiline" do
|
|
544
|
-
@set.sort_by{ |x| x.to_s }.ai(:plain => true).
|
|
544
|
+
expect(@set.sort_by{ |x| x.to_s }.ai(:plain => true)).to eq(@arr.sort_by{ |x| x.to_s }.ai(:plain => true))
|
|
545
545
|
end
|
|
546
546
|
|
|
547
547
|
it "plain multiline indented" do
|
|
548
|
-
@set.sort_by{ |x| x.to_s }.ai(:plain => true, :indent => 1).
|
|
548
|
+
expect(@set.sort_by{ |x| x.to_s }.ai(:plain => true, :indent => 1)).to eq(@arr.sort_by{ |x| x.to_s }.ai(:plain => true, :indent => 1))
|
|
549
549
|
end
|
|
550
550
|
|
|
551
551
|
it "plain single line" do
|
|
552
|
-
@set.sort_by{ |x| x.to_s }.ai(:plain => true, :multiline => false).
|
|
552
|
+
expect(@set.sort_by{ |x| x.to_s }.ai(:plain => true, :multiline => false)).to eq(@arr.sort_by{ |x| x.to_s }.ai(:plain => true, :multiline => false))
|
|
553
553
|
end
|
|
554
554
|
|
|
555
555
|
it "colored multiline (default)" do
|
|
556
|
-
@set.sort_by{ |x| x.to_s }.ai.
|
|
556
|
+
expect(@set.sort_by{ |x| x.to_s }.ai).to eq(@arr.sort_by{ |x| x.to_s }.ai)
|
|
557
557
|
end
|
|
558
558
|
end
|
|
559
559
|
end
|
|
@@ -569,11 +569,11 @@ EOS
|
|
|
569
569
|
@struct.name = "Herman Munster"
|
|
570
570
|
@struct.address = "1313 Mockingbird Lane"
|
|
571
571
|
end
|
|
572
|
-
|
|
572
|
+
|
|
573
573
|
it "empty struct" do
|
|
574
|
-
Struct.new("EmptyStruct").ai.
|
|
574
|
+
expect(Struct.new("EmptyStruct").ai).to eq("\e[1;33mStruct::EmptyStruct < Struct\e[0m")
|
|
575
575
|
end
|
|
576
|
-
|
|
576
|
+
|
|
577
577
|
it "plain multiline" do
|
|
578
578
|
s1 = <<-EOS.strip
|
|
579
579
|
{
|
|
@@ -587,7 +587,7 @@ EOS
|
|
|
587
587
|
:address => "1313 Mockingbird Lane"
|
|
588
588
|
}
|
|
589
589
|
EOS
|
|
590
|
-
@struct.ai(:plain => true).
|
|
590
|
+
expect(@struct.ai(:plain => true)).to satisfy { |match| match == s1 || match == s2 }
|
|
591
591
|
end
|
|
592
592
|
|
|
593
593
|
it "plain multiline indented" do
|
|
@@ -603,13 +603,13 @@ EOS
|
|
|
603
603
|
:address => "1313 Mockingbird Lane"
|
|
604
604
|
}
|
|
605
605
|
EOS
|
|
606
|
-
@struct.ai(:plain => true, :indent => 1).
|
|
606
|
+
expect(@struct.ai(:plain => true, :indent => 1)).to satisfy { |match| match == s1 || match == s2 }
|
|
607
607
|
end
|
|
608
608
|
|
|
609
609
|
it "plain single line" do
|
|
610
610
|
s1 = "{ :address => \"1313 Mockingbird Lane\", :name => \"Herman Munster\" }"
|
|
611
611
|
s2 = "{ :name => \"Herman Munster\", :address => \"1313 Mockingbird Lane\" }"
|
|
612
|
-
@struct.ai(:plain => true, :multiline => false).
|
|
612
|
+
expect(@struct.ai(:plain => true, :multiline => false)).to satisfy { |match| match == s1 || match == s2 }
|
|
613
613
|
end
|
|
614
614
|
|
|
615
615
|
it "colored multiline (default)" do
|
|
@@ -625,7 +625,7 @@ EOS
|
|
|
625
625
|
:address\e[0;37m => \e[0m\e[0;33m\"1313 Mockingbird Lane\"\e[0m
|
|
626
626
|
}
|
|
627
627
|
EOS
|
|
628
|
-
@struct.ai.
|
|
628
|
+
expect(@struct.ai).to satisfy { |match| match == s1 || match == s2 }
|
|
629
629
|
end
|
|
630
630
|
end
|
|
631
631
|
|
|
@@ -639,7 +639,7 @@ EOS
|
|
|
639
639
|
class My < Array; end
|
|
640
640
|
|
|
641
641
|
my = My.new([ 1, :two, "three", [ nil, [ true, false ] ] ])
|
|
642
|
-
my.ai(:plain => true).
|
|
642
|
+
expect(my.ai(:plain => true)).to eq <<-EOS.strip
|
|
643
643
|
[
|
|
644
644
|
[0] 1,
|
|
645
645
|
[1] :two,
|
|
@@ -659,7 +659,7 @@ EOS
|
|
|
659
659
|
class My < Hash; end
|
|
660
660
|
|
|
661
661
|
my = My[ { 1 => { :sym => { "str" => { [1, 2, 3] => { { :k => :v } => Hash } } } } } ]
|
|
662
|
-
my.ai(:plain => true).
|
|
662
|
+
expect(my.ai(:plain => true)).to eq <<-EOS.strip
|
|
663
663
|
{
|
|
664
664
|
1 => {
|
|
665
665
|
:sym => {
|
|
@@ -678,7 +678,7 @@ EOS
|
|
|
678
678
|
class My < File; end
|
|
679
679
|
|
|
680
680
|
my = File.new('/dev/null') rescue File.new('nul')
|
|
681
|
-
my.ai(:plain => true).
|
|
681
|
+
expect(my.ai(:plain => true)).to eq("#{my.inspect}\n" << `ls -alF #{my.path}`.chop)
|
|
682
682
|
end
|
|
683
683
|
|
|
684
684
|
it "inherited from Dir should be displayed as Dir" do
|
|
@@ -686,7 +686,7 @@ EOS
|
|
|
686
686
|
|
|
687
687
|
require 'tmpdir'
|
|
688
688
|
my = My.new(Dir.tmpdir)
|
|
689
|
-
my.ai(:plain => true).
|
|
689
|
+
expect(my.ai(:plain => true)).to eq("#{my.inspect}\n" << `ls -alF #{my.path}`.chop)
|
|
690
690
|
end
|
|
691
691
|
|
|
692
692
|
it "should handle a class that defines its own #send method" do
|
|
@@ -695,7 +695,7 @@ EOS
|
|
|
695
695
|
end
|
|
696
696
|
|
|
697
697
|
my = My.new
|
|
698
|
-
my.methods.ai(:plain => true).
|
|
698
|
+
expect { my.methods.ai(:plain => true) }.not_to raise_error
|
|
699
699
|
end
|
|
700
700
|
|
|
701
701
|
it "should handle a class defines its own #method method (ex. request.method)" do
|
|
@@ -706,7 +706,7 @@ EOS
|
|
|
706
706
|
end
|
|
707
707
|
|
|
708
708
|
my = My.new
|
|
709
|
-
my.methods.ai(:plain => true).
|
|
709
|
+
expect { my.methods.ai(:plain => true) }.not_to raise_error
|
|
710
710
|
end
|
|
711
711
|
end
|
|
712
712
|
end
|