ryansch-awesome_print 1.0.2.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.
@@ -0,0 +1,730 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require "bigdecimal"
3
+ require "rational"
4
+
5
+ describe "AwesomePrint" do
6
+ before do
7
+ stub_dotfile!
8
+ end
9
+
10
+ describe "Array" do
11
+ before do
12
+ @arr = [ 1, :two, "three", [ nil, [ true, false] ] ]
13
+ end
14
+
15
+ it "empty array" do
16
+ [].ai.should == "[]"
17
+ end
18
+
19
+ it "plain multiline" do
20
+ @arr.ai(:plain => true).should == <<-EOS.strip
21
+ [
22
+ [0] 1,
23
+ [1] :two,
24
+ [2] "three",
25
+ [3] [
26
+ [0] nil,
27
+ [1] [
28
+ [0] true,
29
+ [1] false
30
+ ]
31
+ ]
32
+ ]
33
+ EOS
34
+ end
35
+
36
+ it "plain multiline without index" do
37
+ @arr.ai(:plain => true, :index => false).should == <<-EOS.strip
38
+ [
39
+ 1,
40
+ :two,
41
+ "three",
42
+ [
43
+ nil,
44
+ [
45
+ true,
46
+ false
47
+ ]
48
+ ]
49
+ ]
50
+ EOS
51
+ end
52
+
53
+ it "plain multiline indented" do
54
+ @arr.ai(:plain => true, :indent => 2).should == <<-EOS.strip
55
+ [
56
+ [0] 1,
57
+ [1] :two,
58
+ [2] "three",
59
+ [3] [
60
+ [0] nil,
61
+ [1] [
62
+ [0] true,
63
+ [1] false
64
+ ]
65
+ ]
66
+ ]
67
+ EOS
68
+ end
69
+
70
+ it "plain multiline indented without index" do
71
+ @arr.ai(:plain => true, :indent => 2, :index => false).should == <<-EOS.strip
72
+ [
73
+ 1,
74
+ :two,
75
+ "three",
76
+ [
77
+ nil,
78
+ [
79
+ true,
80
+ false
81
+ ]
82
+ ]
83
+ ]
84
+ EOS
85
+ end
86
+
87
+ it "plain single line" do
88
+ @arr.ai(:plain => true, :multiline => false).should == '[ 1, :two, "three", [ nil, [ true, false ] ] ]'
89
+ end
90
+
91
+ it "colored multiline (default)" do
92
+ @arr.ai.should == <<-EOS.strip
93
+ [
94
+ \e[1;37m[0] \e[0m\e[1;34m1\e[0m,
95
+ \e[1;37m[1] \e[0m\e[0;36m:two\e[0m,
96
+ \e[1;37m[2] \e[0m\e[0;33m\"three\"\e[0m,
97
+ \e[1;37m[3] \e[0m[
98
+ \e[1;37m[0] \e[0m\e[1;31mnil\e[0m,
99
+ \e[1;37m[1] \e[0m[
100
+ \e[1;37m[0] \e[0m\e[1;32mtrue\e[0m,
101
+ \e[1;37m[1] \e[0m\e[1;31mfalse\e[0m
102
+ ]
103
+ ]
104
+ ]
105
+ EOS
106
+ end
107
+
108
+ it "colored multiline indented" do
109
+ @arr.ai(:indent => 8).should == <<-EOS.strip
110
+ [
111
+ \e[1;37m[0] \e[0m\e[1;34m1\e[0m,
112
+ \e[1;37m[1] \e[0m\e[0;36m:two\e[0m,
113
+ \e[1;37m[2] \e[0m\e[0;33m\"three\"\e[0m,
114
+ \e[1;37m[3] \e[0m[
115
+ \e[1;37m[0] \e[0m\e[1;31mnil\e[0m,
116
+ \e[1;37m[1] \e[0m[
117
+ \e[1;37m[0] \e[0m\e[1;32mtrue\e[0m,
118
+ \e[1;37m[1] \e[0m\e[1;31mfalse\e[0m
119
+ ]
120
+ ]
121
+ ]
122
+ EOS
123
+ end
124
+
125
+ it "colored single line" do
126
+ @arr.ai(:multiline => false).should == "[ \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 ] ] ]"
127
+ end
128
+ end
129
+
130
+ #------------------------------------------------------------------------------
131
+ describe "Nested Array" do
132
+ before do
133
+ @arr = [ 1, 2 ]
134
+ @arr << @arr
135
+ end
136
+
137
+ it "plain multiline" do
138
+ @arr.ai(:plain => true).should == <<-EOS.strip
139
+ [
140
+ [0] 1,
141
+ [1] 2,
142
+ [2] [...]
143
+ ]
144
+ EOS
145
+ end
146
+
147
+ it "plain multiline without index" do
148
+ @arr.ai(:plain => true, :index => false).should == <<-EOS.strip
149
+ [
150
+ 1,
151
+ 2,
152
+ [...]
153
+ ]
154
+ EOS
155
+ end
156
+
157
+ it "plain single line" do
158
+ @arr.ai(:plain => true, :multiline => false).should == "[ 1, 2, [...] ]"
159
+ end
160
+ end
161
+
162
+ #------------------------------------------------------------------------------
163
+ describe "Limited Output Array" do
164
+ before(:each) do
165
+ @arr = (1..1000).to_a
166
+ end
167
+
168
+ it "plain limited output large" do
169
+ @arr.ai(:plain => true, :limit => true).should == <<-EOS.strip
170
+ [
171
+ [ 0] 1,
172
+ [ 1] 2,
173
+ [ 2] 3,
174
+ [ 3] .. [996],
175
+ [997] 998,
176
+ [998] 999,
177
+ [999] 1000
178
+ ]
179
+ EOS
180
+ end
181
+
182
+ it "plain limited output small" do
183
+ @arr = @arr[0..3]
184
+ @arr.ai(:plain => true, :limit => true).should == <<-EOS.strip
185
+ [
186
+ [0] 1,
187
+ [1] 2,
188
+ [2] 3,
189
+ [3] 4
190
+ ]
191
+ EOS
192
+ end
193
+
194
+ it "plain limited output with 10 lines" do
195
+ @arr.ai(:plain => true, :limit => 10).should == <<-EOS.strip
196
+ [
197
+ [ 0] 1,
198
+ [ 1] 2,
199
+ [ 2] 3,
200
+ [ 3] 4,
201
+ [ 4] 5,
202
+ [ 5] .. [995],
203
+ [996] 997,
204
+ [997] 998,
205
+ [998] 999,
206
+ [999] 1000
207
+ ]
208
+ EOS
209
+ end
210
+
211
+ it "plain limited output with 11 lines" do
212
+ @arr.ai(:plain => true, :limit => 11).should == <<-EOS.strip
213
+ [
214
+ [ 0] 1,
215
+ [ 1] 2,
216
+ [ 2] 3,
217
+ [ 3] 4,
218
+ [ 4] 5,
219
+ [ 5] .. [994],
220
+ [995] 996,
221
+ [996] 997,
222
+ [997] 998,
223
+ [998] 999,
224
+ [999] 1000
225
+ ]
226
+ EOS
227
+ end
228
+ end
229
+
230
+ #------------------------------------------------------------------------------
231
+ describe "Limited Output Hash" do
232
+ before(:each) do
233
+ @hash = ("a".."z").inject({}) { |h, v| h.merge({ v => v.to_sym }) }
234
+ end
235
+
236
+ it "plain limited output" do
237
+ @hash.ai(:sort_keys => true, :plain => true, :limit => true).should == <<-EOS.strip
238
+ {
239
+ "a" => :a,
240
+ "b" => :b,
241
+ "c" => :c,
242
+ "d" => :d .. "w" => :w,
243
+ "x" => :x,
244
+ "y" => :y,
245
+ "z" => :z
246
+ }
247
+ EOS
248
+ end
249
+ end
250
+
251
+ #------------------------------------------------------------------------------
252
+ describe "Hash" do
253
+ before do
254
+ @hash = { 1 => { :sym => { "str" => { [1, 2, 3] => { { :k => :v } => Hash } } } } }
255
+ end
256
+
257
+ it "empty hash" do
258
+ {}.ai.should == "{}"
259
+ end
260
+
261
+ it "plain multiline" do
262
+ @hash.ai(:plain => true).should == <<-EOS.strip
263
+ {
264
+ 1 => {
265
+ :sym => {
266
+ "str" => {
267
+ [ 1, 2, 3 ] => {
268
+ { :k => :v } => Hash < Object
269
+ }
270
+ }
271
+ }
272
+ }
273
+ }
274
+ EOS
275
+ end
276
+
277
+ it "plain multiline indented" do
278
+ @hash.ai(:plain => true, :indent => 1).should == <<-EOS.strip
279
+ {
280
+ 1 => {
281
+ :sym => {
282
+ "str" => {
283
+ [ 1, 2, 3 ] => {
284
+ { :k => :v } => Hash < Object
285
+ }
286
+ }
287
+ }
288
+ }
289
+ }
290
+ EOS
291
+ end
292
+
293
+ it "plain single line" do
294
+ @hash.ai(:plain => true, :multiline => false).should == '{ 1 => { :sym => { "str" => { [ 1, 2, 3 ] => { { :k => :v } => Hash < Object } } } } }'
295
+ end
296
+
297
+ it "colored multiline (default)" do
298
+ @hash.ai.should == <<-EOS.strip
299
+ {
300
+ 1\e[0;37m => \e[0m{
301
+ :sym\e[0;37m => \e[0m{
302
+ \"str\"\e[0;37m => \e[0m{
303
+ [ 1, 2, 3 ]\e[0;37m => \e[0m{
304
+ { :k => :v }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m
305
+ }
306
+ }
307
+ }
308
+ }
309
+ }
310
+ EOS
311
+ end
312
+
313
+ it "colored multiline indented" do
314
+ @hash.ai(:indent => 2).should == <<-EOS.strip
315
+ {
316
+ 1\e[0;37m => \e[0m{
317
+ :sym\e[0;37m => \e[0m{
318
+ \"str\"\e[0;37m => \e[0m{
319
+ [ 1, 2, 3 ]\e[0;37m => \e[0m{
320
+ { :k => :v }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m
321
+ }
322
+ }
323
+ }
324
+ }
325
+ }
326
+ EOS
327
+ end
328
+
329
+ it "colored single line" do
330
+ @hash.ai(:multiline => false).should == "{ 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 } } } } }"
331
+ end
332
+
333
+ end
334
+
335
+ #------------------------------------------------------------------------------
336
+ describe "Nested Hash" do
337
+ before do
338
+ @hash = {}
339
+ @hash[:a] = @hash
340
+ end
341
+
342
+ it "plain multiline" do
343
+ @hash.ai(:plain => true).should == <<-EOS.strip
344
+ {
345
+ :a => {...}
346
+ }
347
+ EOS
348
+ end
349
+
350
+ it "plain single line" do
351
+ @hash.ai(:plain => true, :multiline => false).should == '{ :a => {...} }'
352
+ end
353
+ end
354
+
355
+ #------------------------------------------------------------------------------
356
+ describe "Hash with several keys" do
357
+ before do
358
+ @hash = {"b" => "b", :a => "a", :z => "z", "alpha" => "alpha"}
359
+ end
360
+
361
+ it "plain multiline" do
362
+ out = @hash.ai(:plain => true)
363
+ if RUBY_VERSION.to_f < 1.9 # Order of @hash keys is not guaranteed.
364
+ out.should =~ /^\{[^\}]+\}/m
365
+ out.should =~ / "b" => "b",?/
366
+ out.should =~ / :a => "a",?/
367
+ out.should =~ / :z => "z",?/
368
+ out.should =~ / "alpha" => "alpha",?$/
369
+ else
370
+ out.should == <<-EOS.strip
371
+ {
372
+ "b" => "b",
373
+ :a => "a",
374
+ :z => "z",
375
+ "alpha" => "alpha"
376
+ }
377
+ EOS
378
+ end
379
+ end
380
+
381
+ it "plain multiline with sorted keys" do
382
+ @hash.ai(:plain => true, :sort_keys => true).should == <<-EOS.strip
383
+ {
384
+ :a => "a",
385
+ "alpha" => "alpha",
386
+ "b" => "b",
387
+ :z => "z"
388
+ }
389
+ EOS
390
+ end
391
+
392
+ end
393
+
394
+ #------------------------------------------------------------------------------
395
+ describe "Negative options[:indent]" do
396
+ #
397
+ # With Ruby < 1.9 the order of hash keys is not defined so we can't
398
+ # reliably compare the output string.
399
+ #
400
+ it "hash keys must be left aligned" do
401
+ hash = { [0, 0, 255] => :yellow, :red => "rgb(255, 0, 0)", "magenta" => "rgb(255, 0, 255)" }
402
+ out = hash.ai(:plain => true, :indent => -4, :sort_keys => true)
403
+ out.should == <<-EOS.strip
404
+ {
405
+ [ 0, 0, 255 ] => :yellow,
406
+ "magenta" => "rgb(255, 0, 255)",
407
+ :red => "rgb(255, 0, 0)"
408
+ }
409
+ EOS
410
+ end
411
+
412
+ it "nested hash keys should be indented (array of hashes)" do
413
+ arr = [ { :a => 1, :bb => 22, :ccc => 333}, { 1 => :a, 22 => :bb, 333 => :ccc} ]
414
+ out = arr.ai(:plain => true, :indent => -4, :sort_keys => true)
415
+ out.should == <<-EOS.strip
416
+ [
417
+ [0] {
418
+ :a => 1,
419
+ :bb => 22,
420
+ :ccc => 333
421
+ },
422
+ [1] {
423
+ 1 => :a,
424
+ 22 => :bb,
425
+ 333 => :ccc
426
+ }
427
+ ]
428
+ EOS
429
+ end
430
+
431
+ it "nested hash keys should be indented (hash of hashes)" do
432
+ arr = { :first => { :a => 1, :bb => 22, :ccc => 333}, :second => { 1 => :a, 22 => :bb, 333 => :ccc} }
433
+ out = arr.ai(:plain => true, :indent => -4, :sort_keys => true)
434
+ out.should == <<-EOS.strip
435
+ {
436
+ :first => {
437
+ :a => 1,
438
+ :bb => 22,
439
+ :ccc => 333
440
+ },
441
+ :second => {
442
+ 1 => :a,
443
+ 22 => :bb,
444
+ 333 => :ccc
445
+ }
446
+ }
447
+ EOS
448
+ end
449
+ end
450
+
451
+ #------------------------------------------------------------------------------
452
+ describe "Class" do
453
+ it "shoud show superclass (plain)" do
454
+ self.class.ai(:plain => true).should == "#{self.class} < #{self.class.superclass}"
455
+ end
456
+
457
+ it "shoud show superclass (color)" do
458
+ self.class.ai.should == "#{self.class} < #{self.class.superclass}".yellow
459
+ end
460
+ end
461
+
462
+ #------------------------------------------------------------------------------
463
+ describe "File" do
464
+ it "should display a file (plain)" do
465
+ File.open(__FILE__, "r") do |f|
466
+ f.ai(:plain => true).should == "#{f.inspect}\n" << `ls -alF #{f.path}`.chop
467
+ end
468
+ end
469
+ end
470
+
471
+ #------------------------------------------------------------------------------
472
+ describe "Dir" do
473
+ it "should display a direcory (plain)" do
474
+ Dir.open(File.dirname(__FILE__)) do |d|
475
+ d.ai(:plain => true).should == "#{d.inspect}\n" << `ls -alF #{d.path}`.chop
476
+ end
477
+ end
478
+ end
479
+
480
+ #------------------------------------------------------------------------------
481
+ describe "BigDecimal and Rational" do
482
+ it "should present BigDecimal object as Float scalar" do
483
+ big = BigDecimal("2010.4")
484
+ big.ai(:plain => true).should == "2010.4"
485
+ end
486
+
487
+ it "should present Rational object as Float scalar" do
488
+ rat = Rational(2010, 2)
489
+ rat.ai(:plain => true).should == "1005.0"
490
+ end
491
+ end
492
+
493
+ #------------------------------------------------------------------------------
494
+ describe "Utility methods" do
495
+ it "should merge options" do
496
+ ap = AwesomePrint::Inspector.new
497
+ ap.send(:merge_options!, { :color => { :array => :black }, :indent => 0 })
498
+ options = ap.instance_variable_get("@options")
499
+ options[:color][:array].should == :black
500
+ options[:indent].should == 0
501
+ end
502
+ end
503
+
504
+
505
+ #------------------------------------------------------------------------------
506
+ describe "Struct" do
507
+ before do
508
+ @struct = unless defined?(Struct::SimpleStruct)
509
+ Struct.new("SimpleStruct", :name, :address).new
510
+ else
511
+ Struct::SimpleStruct.new
512
+ end
513
+ @struct.name = "Herman Munster"
514
+ @struct.address = "1313 Mockingbird Lane"
515
+ end
516
+
517
+ it "empty struct" do
518
+ Struct.new("EmptyStruct").ai.should == "\e[1;33mStruct::EmptyStruct < Struct\e[0m"
519
+ end
520
+
521
+ it "plain multiline" do
522
+ s1 = <<-EOS.strip
523
+ {
524
+ :address => "1313 Mockingbird Lane",
525
+ :name => "Herman Munster"
526
+ }
527
+ EOS
528
+ s2 = <<-EOS.strip
529
+ {
530
+ :name => "Herman Munster",
531
+ :address => "1313 Mockingbird Lane"
532
+ }
533
+ EOS
534
+ @struct.ai(:plain => true).should satisfy { |match| match == s1 || match == s2 }
535
+ end
536
+
537
+ it "plain multiline indented" do
538
+ s1 = <<-EOS.strip
539
+ {
540
+ :address => "1313 Mockingbird Lane",
541
+ :name => "Herman Munster"
542
+ }
543
+ EOS
544
+ s2 = <<-EOS.strip
545
+ {
546
+ :name => "Herman Munster",
547
+ :address => "1313 Mockingbird Lane"
548
+ }
549
+ EOS
550
+ @struct.ai(:plain => true, :indent => 1).should satisfy { |match| match == s1 || match == s2 }
551
+ end
552
+
553
+ it "plain single line" do
554
+ s1 = "{ :address => \"1313 Mockingbird Lane\", :name => \"Herman Munster\" }"
555
+ s2 = "{ :name => \"Herman Munster\", :address => \"1313 Mockingbird Lane\" }"
556
+ @struct.ai(:plain => true, :multiline => false).should satisfy { |match| match == s1 || match == s2 }
557
+ end
558
+
559
+ it "colored multiline (default)" do
560
+ s1 = <<-EOS.strip
561
+ {
562
+ :address\e[0;37m => \e[0m\e[0;33m\"1313 Mockingbird Lane\"\e[0m,
563
+ :name\e[0;37m => \e[0m\e[0;33m\"Herman Munster\"\e[0m
564
+ }
565
+ EOS
566
+ s2 = <<-EOS.strip
567
+ {
568
+ :name\e[0;37m => \e[0m\e[0;33m\"Herman Munster\"\e[0m,
569
+ :address\e[0;37m => \e[0m\e[0;33m\"1313 Mockingbird Lane\"\e[0m
570
+ }
571
+ EOS
572
+ @struct.ai.should satisfy { |match| match == s1 || match == s2 }
573
+ end
574
+ end
575
+
576
+
577
+ #------------------------------------------------------------------------------
578
+ describe "Misc" do
579
+ it "handle weird objects that return nil on inspect" do
580
+ weird = Class.new do
581
+ def inspect
582
+ nil
583
+ end
584
+ end
585
+ weird.new.ai(:plain => true).should == ''
586
+ end
587
+
588
+ it "handle frozen object.inspect" do
589
+ weird = Class.new do
590
+ def inspect
591
+ "ice".freeze
592
+ end
593
+ end
594
+ weird.new.ai(:plain => false).should == "ice"
595
+ end
596
+
597
+ # See https://github.com/michaeldv/awesome_print/issues/35
598
+ it "handle array grep when pattern contains / chapacter" do
599
+ hash = { "1/x" => 1, "2//x" => :"2" }
600
+ grepped = hash.keys.grep(/^(\d+)\//) { $1 }
601
+ grepped.ai(:plain => true, :multiline => false).should == '[ "1", "2" ]'
602
+ end
603
+
604
+ it "returns value passed as a parameter" do
605
+ object = rand
606
+ self.stub!(:puts)
607
+ (ap object).should == object
608
+ end
609
+
610
+ # Require different file name this time (lib/ap.rb vs. lib/awesome_print).
611
+ it "several require 'awesome_print' should do no harm" do
612
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/ap')
613
+ lambda { rand.ai }.should_not raise_error
614
+ end
615
+ end
616
+
617
+ describe "HTML output" do
618
+ it "wraps ap output with plain <pre> tag" do
619
+ markup = rand
620
+ markup.ai(:html => true, :plain => true).should == "<pre>#{markup}</pre>"
621
+ end
622
+
623
+ it "wraps ap output with <pre> tag with colorized <kbd>" do
624
+ markup = rand
625
+ markup.ai(:html => true).should == %Q|<pre><kbd style="color:blue">#{markup}</kbd></pre>|
626
+ end
627
+
628
+ it "wraps multiline ap output with <pre> tag with colorized <kbd>" do
629
+ markup = [ 1, :two, "three" ]
630
+ markup.ai(:html => true).should == <<-EOS.strip
631
+ <pre>[
632
+ <kbd style="color:white">[0] </kbd><pre><kbd style="color:blue">1</kbd></pre>,
633
+ <kbd style="color:white">[1] </kbd><pre><kbd style="color:darkcyan">:two</kbd></pre>,
634
+ <kbd style="color:white">[2] </kbd><pre><kbd style="color:brown">&quot;three&quot;</kbd></pre>
635
+ ]</pre>
636
+ EOS
637
+ end
638
+
639
+ it "encodes HTML entities (plain)" do
640
+ markup = ' &<hello>'
641
+ markup.ai(:html => true, :plain => true).should == '<pre>&quot; &amp;&lt;hello&gt;&quot;</pre>'
642
+ end
643
+
644
+ it "encodes HTML entities (color)" do
645
+ markup = ' &<hello>'
646
+ markup.ai(:html => true).should == '<pre><kbd style="color:brown">&quot; &amp;&lt;hello&gt;&quot;</kbd></pre>'
647
+ end
648
+ end
649
+
650
+ #------------------------------------------------------------------------------
651
+ describe "Inherited from standard Ruby classes" do
652
+ after do
653
+ Object.instance_eval{ remove_const :My } if defined?(My)
654
+ end
655
+
656
+ it "inherited from Array should be displayed as Array" do
657
+ class My < Array; end
658
+
659
+ my = My.new([ 1, :two, "three", [ nil, [ true, false ] ] ])
660
+ my.ai(:plain => true).should == <<-EOS.strip
661
+ [
662
+ [0] 1,
663
+ [1] :two,
664
+ [2] "three",
665
+ [3] [
666
+ [0] nil,
667
+ [1] [
668
+ [0] true,
669
+ [1] false
670
+ ]
671
+ ]
672
+ ]
673
+ EOS
674
+ end
675
+
676
+ it "inherited from Hash should be displayed as Hash" do
677
+ class My < Hash; end
678
+
679
+ my = My[ { 1 => { :sym => { "str" => { [1, 2, 3] => { { :k => :v } => Hash } } } } } ]
680
+ my.ai(:plain => true).should == <<-EOS.strip
681
+ {
682
+ 1 => {
683
+ :sym => {
684
+ "str" => {
685
+ [ 1, 2, 3 ] => {
686
+ { :k => :v } => Hash < Object
687
+ }
688
+ }
689
+ }
690
+ }
691
+ }
692
+ EOS
693
+ end
694
+
695
+ it "inherited from File should be displayed as File" do
696
+ class My < File; end
697
+
698
+ my = File.new('/dev/null') rescue File.new('nul')
699
+ my.ai(:plain => true).should == "#{my.inspect}\n" << `ls -alF #{my.path}`.chop
700
+ end
701
+
702
+ it "inherited from Dir should be displayed as Dir" do
703
+ class My < Dir; end
704
+
705
+ require 'tmpdir'
706
+ my = My.new(Dir.tmpdir)
707
+ my.ai(:plain => true).should == "#{my.inspect}\n" << `ls -alF #{my.path}`.chop
708
+ end
709
+
710
+ it "should handle a class that defines its own #send method" do
711
+ class My
712
+ def send(arg1, arg2, arg3); end
713
+ end
714
+
715
+ my = My.new
716
+ my.methods.ai(:plain => true).should_not raise_error(ArgumentError)
717
+ end
718
+
719
+ it "should handle a class defines its own #method method (ex. request.method)" do
720
+ class My
721
+ def method
722
+ 'POST'
723
+ end
724
+ end
725
+
726
+ my = My.new
727
+ my.methods.ai(:plain => true).should_not raise_error(ArgumentError)
728
+ end
729
+ end
730
+ end