amazing_print 1.4.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +16 -0
  3. data/CHANGELOG.md +56 -33
  4. data/Gemfile +12 -0
  5. data/Gemfile.lock +61 -44
  6. data/README.md +3 -4
  7. data/lib/amazing_print/colorize.rb +5 -12
  8. data/lib/amazing_print/colors.rb +37 -0
  9. data/lib/amazing_print/core_ext/awesome_method_array.rb +1 -1
  10. data/lib/amazing_print/custom_defaults.rb +7 -1
  11. data/lib/amazing_print/ext/mongoid.rb +14 -2
  12. data/lib/amazing_print/ext_loader.rb +27 -0
  13. data/lib/amazing_print/formatters/array_formatter.rb +1 -1
  14. data/lib/amazing_print/formatters/base_formatter.rb +8 -3
  15. data/lib/amazing_print/formatters/dir_formatter.rb +10 -1
  16. data/lib/amazing_print/formatters/file_formatter.rb +10 -1
  17. data/lib/amazing_print/formatters/hash_formatter.rb +3 -5
  18. data/lib/amazing_print/formatters/mswin_helper.rb +63 -0
  19. data/lib/amazing_print/inspector.rb +6 -3
  20. data/lib/amazing_print/version.rb +1 -1
  21. data/lib/amazing_print.rb +3 -9
  22. data/spec/colors_spec.rb +9 -4
  23. data/spec/ext/action_controller_spec.rb +3 -3
  24. data/spec/ext/active_record_spec.rb +30 -60
  25. data/spec/ext/active_support_spec.rb +2 -2
  26. data/spec/ext/mongoid_spec.rb +110 -47
  27. data/spec/ext/nokogiri_spec.rb +6 -6
  28. data/spec/ext/sequel_spec.rb +1 -1
  29. data/spec/formats_spec.rb +97 -89
  30. data/spec/misc_spec.rb +15 -61
  31. data/spec/spec_helper.rb +7 -1
  32. data/spec/support/active_record_data/7_0_diana.txt +110 -0
  33. data/spec/support/active_record_data/7_0_multi.txt +222 -0
  34. data/spec/support/rails_versions.rb +5 -0
  35. metadata +13 -156
  36. data/lib/amazing_print/core_ext/string.rb +0 -45
  37. data/spec/core_ext/string_spec.rb +0 -15
data/spec/formats_spec.rb CHANGED
@@ -93,7 +93,7 @@ RSpec.describe 'AmazingPrint' do
93
93
  [
94
94
  \e[1;37m[0] \e[0m\e[1;34m1\e[0m,
95
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,
96
+ \e[1;37m[2] \e[0m\e[0;33m"three"\e[0m,
97
97
  \e[1;37m[3] \e[0m[
98
98
  \e[1;37m[0] \e[0m\e[1;31mnil\e[0m,
99
99
  \e[1;37m[1] \e[0m[
@@ -110,7 +110,7 @@ RSpec.describe 'AmazingPrint' do
110
110
  [
111
111
  \e[1;37m[0] \e[0m\e[1;34m1\e[0m,
112
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,
113
+ \e[1;37m[2] \e[0m\e[0;33m"three"\e[0m,
114
114
  \e[1;37m[3] \e[0m[
115
115
  \e[1;37m[0] \e[0m\e[1;31mnil\e[0m,
116
116
  \e[1;37m[1] \e[0m[
@@ -314,11 +314,11 @@ RSpec.describe 'AmazingPrint' do
314
314
  it 'colored multiline (default)' do
315
315
  expect(@hash.ai).to eq <<~EOS.strip
316
316
  {
317
- 1\e[0;37m => \e[0m{
318
- :sym\e[0;37m => \e[0m{
319
- \"str\"\e[0;37m => \e[0m{
320
- [ 1, 2, 3 ]\e[0;37m => \e[0m{
321
- { :k => :v }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m
317
+ \e[1;34m1\e[0m\e[0;37m => \e[0m{
318
+ \e[0;36m:sym\e[0m\e[0;37m => \e[0m{
319
+ \e[0;33m"str"\e[0m\e[0;37m => \e[0m{
320
+ [ \e[1;34m1\e[0m, \e[1;34m2\e[0m, \e[1;34m3\e[0m ]\e[0;37m => \e[0m{
321
+ { \e[0;36m:k\e[0m\e[0;37m => \e[0m\e[0;36m:v\e[0m }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m
322
322
  }
323
323
  }
324
324
  }
@@ -330,11 +330,11 @@ RSpec.describe 'AmazingPrint' do
330
330
  it 'colored with new hash syntax' do
331
331
  expect(@hash.ai(ruby19_syntax: true)).to eq <<~EOS.strip
332
332
  {
333
- 1\e[0;37m => \e[0m{
334
- sym\e[0;37m: \e[0m{
335
- \"str\"\e[0;37m => \e[0m{
336
- [ 1, 2, 3 ]\e[0;37m => \e[0m{
337
- { k: :v }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m
333
+ \e[1;34m1\e[0m\e[0;37m => \e[0m{
334
+ \e[0;36m:sym\e[0m\e[0;37m => \e[0m{
335
+ \e[0;33m"str"\e[0m\e[0;37m => \e[0m{
336
+ [ \e[1;34m1\e[0m, \e[1;34m2\e[0m, \e[1;34m3\e[0m ]\e[0;37m => \e[0m{
337
+ { \e[0;36m:k\e[0m\e[0;37m => \e[0m\e[0;36m:v\e[0m }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m
338
338
  }
339
339
  }
340
340
  }
@@ -346,11 +346,11 @@ RSpec.describe 'AmazingPrint' do
346
346
  it 'colored multiline indented' do
347
347
  expect(@hash.ai(indent: 2)).to eq <<~EOS.strip
348
348
  {
349
- 1\e[0;37m => \e[0m{
350
- :sym\e[0;37m => \e[0m{
351
- \"str\"\e[0;37m => \e[0m{
352
- [ 1, 2, 3 ]\e[0;37m => \e[0m{
353
- { :k => :v }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m
349
+ \e[1;34m1\e[0m\e[0;37m => \e[0m{
350
+ \e[0;36m:sym\e[0m\e[0;37m => \e[0m{
351
+ \e[0;33m"str"\e[0m\e[0;37m => \e[0m{
352
+ [ \e[1;34m1\e[0m, \e[1;34m2\e[0m, \e[1;34m3\e[0m ]\e[0;37m => \e[0m{
353
+ { \e[0;36m:k\e[0m\e[0;37m => \e[0m\e[0;36m:v\e[0m }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m
354
354
  }
355
355
  }
356
356
  }
@@ -360,7 +360,10 @@ RSpec.describe 'AmazingPrint' do
360
360
  end
361
361
 
362
362
  it 'colored single line' do
363
- 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 } } } } }")
363
+ puts @hash.ai(multiline: false)
364
+ expect(@hash.ai(multiline: false)).to eq(
365
+ "{ \e[1;34m1\e[0m\e[0;37m => \e[0m{ \e[0;36m:sym\e[0m\e[0;37m => \e[0m{ \e[0;33m\"str\"\e[0m\e[0;37m => \e[0m{ [ \e[1;34m1\e[0m, \e[1;34m2\e[0m, \e[1;34m3\e[0m ]\e[0;37m => \e[0m{ { \e[0;36m:k\e[0m\e[0;37m => \e[0m\e[0;36m:v\e[0m }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m } } } } }" # rubocop:disable Layout/LineLength
366
+ )
364
367
  end
365
368
  end
366
369
 
@@ -392,22 +395,14 @@ RSpec.describe 'AmazingPrint' do
392
395
 
393
396
  it 'plain multiline' do
394
397
  out = @hash.ai(plain: true)
395
- if RUBY_VERSION.to_f < 1.9 # Order of @hash keys is not guaranteed.
396
- expect(out).to match(/^\{[^}]+\}/m)
397
- expect(out).to match(/ "b" => "b",?/)
398
- expect(out).to match(/ :a => "a",?/)
399
- expect(out).to match(/ :z => "z",?/)
400
- expect(out).to match(/ "alpha" => "alpha",?$/)
401
- else
402
- expect(out).to eq <<~EOS.strip
403
- {
404
- "b" => "b",
405
- :a => "a",
406
- :z => "z",
407
- "alpha" => "alpha"
408
- }
409
- EOS
410
- end
398
+ expect(out).to eq <<~EOS.strip
399
+ {
400
+ "b" => "b",
401
+ :a => "a",
402
+ :z => "z",
403
+ "alpha" => "alpha"
404
+ }
405
+ EOS
411
406
  end
412
407
 
413
408
  it 'plain multiline with sorted keys' do
@@ -479,6 +474,21 @@ RSpec.describe 'AmazingPrint' do
479
474
  end
480
475
  end
481
476
 
477
+ #
478
+ # With Ruby 1.9 syntax
479
+ #
480
+ it 'hash keys must be left aligned' do
481
+ hash = { [0, 0, 255] => :yellow, :bloodiest_red => 'rgb(255, 0, 0)', 'magenta' => 'rgb(255, 0, 255)' }
482
+ out = hash.ai(plain: true, indent: -2, ruby19_syntax: true, sort_keys: true)
483
+ expect(out).to eq <<~EOS.strip
484
+ {
485
+ [ 0, 0, 255 ] => :yellow,
486
+ bloodiest_red: "rgb(255, 0, 0)",
487
+ "magenta" => "rgb(255, 0, 255)"
488
+ }
489
+ EOS
490
+ end
491
+
482
492
  #------------------------------------------------------------------------------
483
493
  describe 'Class' do
484
494
  it 'shows superclass (plain)' do
@@ -486,26 +496,38 @@ RSpec.describe 'AmazingPrint' do
486
496
  end
487
497
 
488
498
  it 'shows superclass (color)' do
489
- expect(self.class.ai).to eq("#{self.class} < #{self.class.superclass}".yellow)
499
+ expect(self.class.ai).to eq(AmazingPrint::Colors.yellow("#{self.class} < #{self.class.superclass}"))
490
500
  end
491
501
  end
492
502
 
493
503
  #------------------------------------------------------------------------------
494
504
  describe 'File' do
495
- it 'displays a file (plain)' do
505
+ it 'displays a file (plain)', :unix do
496
506
  File.open(__FILE__, 'r') do |f|
497
507
  expect(f.ai(plain: true)).to eq("#{f.inspect}\n" + `ls -alF #{f.path}`.chop)
498
508
  end
499
509
  end
510
+
511
+ it 'displays a file (plain) akin to powershell Get-ChildItem', :mswin do
512
+ File.open(__FILE__, 'r') do |f|
513
+ expect(f.ai(plain: true)).to eq("#{f.inspect}\n" + AmazingPrint::Formatters::GetChildItem.new(f.path).to_s)
514
+ end
515
+ end
500
516
  end
501
517
 
502
518
  #------------------------------------------------------------------------------
503
519
  describe 'Dir' do
504
- it 'displays a direcory (plain)' do
520
+ it 'displays a direcory (plain)', :unix do
505
521
  Dir.open(File.dirname(__FILE__)) do |d|
506
522
  expect(d.ai(plain: true)).to eq("#{d.inspect}\n" + `ls -alF #{d.path}`.chop)
507
523
  end
508
524
  end
525
+
526
+ it 'displays a directory (plain) akin to powershell Get-ChildItem', :mswin do
527
+ Dir.open(File.dirname(__FILE__)) do |d|
528
+ expect(d.ai(plain: true)).to eq("#{d.inspect}\n" + AmazingPrint::Formatters::GetChildItem.new(d.path).to_s)
529
+ end
530
+ end
509
531
  end
510
532
 
511
533
  #------------------------------------------------------------------------------
@@ -518,16 +540,7 @@ RSpec.describe 'AmazingPrint' do
518
540
  it 'presents Rational object with arbitrary precision' do
519
541
  rat = Rational(201_020_102_010_201_020_102_010_201_020_102_010, 2)
520
542
  out = rat.ai(plain: true)
521
- #
522
- # Ruby 1.9 slightly changed the format of Rational#to_s, see
523
- # http://techtime.getharvest.com/blog/harvest-is-now-on-ruby-1-dot-9-3 and
524
- # http://www.ruby-forum.com/topic/189397
525
- #
526
- if RUBY_VERSION < '1.9'
527
- expect(out).to eq('100510051005100510051005100510051005')
528
- else
529
- expect(out).to eq('100510051005100510051005100510051005/1')
530
- end
543
+ expect(out).to eq('100510051005100510051005100510051005/1')
531
544
  end
532
545
  end
533
546
 
@@ -553,39 +566,20 @@ RSpec.describe 'AmazingPrint' do
553
566
  expect(Set.new.ai).to eq([].ai)
554
567
  end
555
568
 
556
- if RUBY_VERSION > '1.9'
557
- it 'plain multiline' do
558
- expect(@set.ai(plain: true)).to eq(@arr.ai(plain: true))
559
- end
560
-
561
- it 'plain multiline indented' do
562
- expect(@set.ai(plain: true, indent: 1)).to eq(@arr.ai(plain: true, indent: 1))
563
- end
564
-
565
- it 'plain single line' do
566
- expect(@set.ai(plain: true, multiline: false)).to eq(@arr.ai(plain: true, multiline: false))
567
- end
568
-
569
- it 'colored multiline (default)' do
570
- expect(@set.ai).to eq(@arr.ai)
571
- end
572
- else # Prior to Ruby 1.9 the order of set values is unpredicatble.
573
- it 'plain multiline' do
574
- expect(@set.sort_by(&:to_s).ai(plain: true)).to eq(@arr.sort_by(&:to_s).ai(plain: true))
575
- end
569
+ it 'plain multiline' do
570
+ expect(@set.ai(plain: true)).to eq(@arr.ai(plain: true))
571
+ end
576
572
 
577
- it 'plain multiline indented' do
578
- expect(@set.sort_by(&:to_s).ai(plain: true, indent: 1)).to eq(@arr.sort_by(&:to_s).ai(plain: true, indent: 1))
579
- end
573
+ it 'plain multiline indented' do
574
+ expect(@set.ai(plain: true, indent: 1)).to eq(@arr.ai(plain: true, indent: 1))
575
+ end
580
576
 
581
- it 'plain single line' do
582
- expect(@set.sort_by(&:to_s).ai(plain: true,
583
- multiline: false)).to eq(@arr.sort_by(&:to_s).ai(plain: true, multiline: false))
584
- end
577
+ it 'plain single line' do
578
+ expect(@set.ai(plain: true, multiline: false)).to eq(@arr.ai(plain: true, multiline: false))
579
+ end
585
580
 
586
- it 'colored multiline (default)' do
587
- expect(@set.sort_by(&:to_s).ai).to eq(@arr.sort_by(&:to_s).ai)
588
- end
581
+ it 'colored multiline (default)' do
582
+ expect(@set.ai).to eq(@arr.ai)
589
583
  end
590
584
  end
591
585
 
@@ -607,12 +601,12 @@ RSpec.describe 'AmazingPrint' do
607
601
 
608
602
  it 'plain multiline' do
609
603
  s1 = <<-EOS.strip
610
- address = \"1313 Mockingbird Lane\",
611
- name = \"Herman Munster\"
604
+ address = "1313 Mockingbird Lane",
605
+ name = "Herman Munster"
612
606
  EOS
613
607
  s2 = <<-EOS.strip
614
- name = \"Herman Munster\",
615
- address = \"1313 Mockingbird Lane\"
608
+ name = "Herman Munster",
609
+ address = "1313 Mockingbird Lane"
616
610
  EOS
617
611
  expect(@struct.ai(plain: true)).to satisfy { |out| out.match(s1) || out.match(s2) }
618
612
  end
@@ -637,12 +631,12 @@ RSpec.describe 'AmazingPrint' do
637
631
 
638
632
  it 'colored multiline (default)' do
639
633
  s1 = <<-EOS.strip
640
- address\e[0;37m = \e[0m\e[0;33m\"1313 Mockingbird Lane\"\e[0m,
641
- name\e[0;37m = \e[0m\e[0;33m\"Herman Munster\"\e[0m
634
+ address\e[0;37m = \e[0m\e[0;33m"1313 Mockingbird Lane"\e[0m,
635
+ name\e[0;37m = \e[0m\e[0;33m"Herman Munster"\e[0m
642
636
  EOS
643
637
  s2 = <<-EOS.strip
644
- name\e[0;37m = \e[0m\e[0;33m\"Herman Munster\"\e[0m,
645
- address\e[0;37m = \e[0m\e[0;33m\"1313 Mockingbird Lane\"\e[0m
638
+ name\e[0;37m = \e[0m\e[0;33m"Herman Munster"\e[0m,
639
+ address\e[0;37m = \e[0m\e[0;33m"1313 Mockingbird Lane"\e[0m
646
640
  EOS
647
641
  expect(@struct.ai).to satisfy { |out| out.include?(s1) || out.include?(s2) }
648
642
  end
@@ -693,7 +687,7 @@ RSpec.describe 'AmazingPrint' do
693
687
  EOS
694
688
  end
695
689
 
696
- it 'inherited from File should be displayed as File' do
690
+ it 'inherited from File should be displayed as File', :unix do
697
691
  class My < File; end
698
692
 
699
693
  my = begin
@@ -704,7 +698,13 @@ RSpec.describe 'AmazingPrint' do
704
698
  expect(my.ai(plain: true)).to eq("#{my.inspect}\n" + `ls -alF #{my.path}`.chop)
705
699
  end
706
700
 
707
- it 'inherited from Dir should be displayed as Dir' do
701
+ it 'inherited from File should be displayed as File', :mswin do
702
+ class My < File; end
703
+ my = My.new('nul') # it's /dev/null in Windows
704
+ expect(my.ai(plain: true)).to eq("#{my.inspect}\n" + AmazingPrint::Formatters::GetChildItem.new(my.path).to_s)
705
+ end
706
+
707
+ it 'inherited from Dir should be displayed as Dir', :unix do
708
708
  class My < Dir; end
709
709
 
710
710
  require 'tmpdir'
@@ -712,6 +712,14 @@ RSpec.describe 'AmazingPrint' do
712
712
  expect(my.ai(plain: true)).to eq("#{my.inspect}\n" + `ls -alF #{my.path}`.chop)
713
713
  end
714
714
 
715
+ it 'inherited from Dir are displayed as Dir', :mswin do
716
+ class My < Dir; end
717
+
718
+ require 'tmpdir'
719
+ my = My.new(Dir.tmpdir)
720
+ expect(my.ai(plain: true)).to eq("#{my.inspect}\n" + AmazingPrint::Formatters::GetChildItem.new(my.path).to_s)
721
+ end
722
+
715
723
  it 'handles a class that defines its own #send method' do
716
724
  class My
717
725
  def send(arg1, arg2, arg3); end
@@ -757,7 +765,7 @@ RSpec.describe 'AmazingPrint' do
757
765
  class My
758
766
  def to_hash
759
767
  object = Object.new
760
- object.define_singleton_method('[]') { return nil }
768
+ object.define_singleton_method('[]') { nil }
761
769
 
762
770
  object
763
771
  end
@@ -771,7 +779,7 @@ RSpec.describe 'AmazingPrint' do
771
779
  class My
772
780
  def to_hash
773
781
  object = Object.new
774
- object.define_singleton_method(:keys) { return [:foo] }
782
+ object.define_singleton_method(:keys) { [:foo] }
775
783
 
776
784
  object
777
785
  end
data/spec/misc_spec.rb CHANGED
@@ -32,12 +32,10 @@ RSpec.describe 'AmazingPrint' do
32
32
  end
33
33
 
34
34
  # See https://github.com/awesome-print/awesome_print/issues/85
35
- if RUBY_VERSION >= '1.8.7'
36
- it "handle array grep when a method is defined in C and thus doesn't have a binding" do
37
- arr = (0..6).to_a
38
- grepped = arr.grep(1..4, &:succ)
39
- expect(grepped.ai(plain: true, multiline: false)).to eq('[ 2, 3, 4, 5 ]')
40
- end
35
+ it "handle array grep when a method is defined in C and thus doesn't have a binding" do
36
+ arr = (0..6).to_a
37
+ grepped = arr.grep(1..4, &:succ)
38
+ expect(grepped.ai(plain: true, multiline: false)).to eq('[ 2, 3, 4, 5 ]')
41
39
  end
42
40
 
43
41
  it 'returns value passed as a parameter' do
@@ -105,7 +103,7 @@ RSpec.describe 'AmazingPrint' do
105
103
  expect(markup.ai(html: true)).to eq <<~EOS.strip
106
104
  <pre>[
107
105
  <kbd style="color:white">[0] </kbd>{
108
- &quot;hello&quot;<kbd style="color:slategray"> =&gt; </kbd><kbd style="color:brown">&quot;world&quot;</kbd>
106
+ <kbd style="color:brown">&quot;hello&quot;</kbd><kbd style="color:slategray"> =&gt; </kbd><kbd style="color:brown">&quot;world&quot;</kbd>
109
107
  }
110
108
  ]</pre>
111
109
  EOS
@@ -143,65 +141,21 @@ RSpec.describe 'AmazingPrint' do
143
141
  end
144
142
  end
145
143
 
146
- #------------------------------------------------------------------------------
147
- describe 'Coexistence with the colorize gem' do
148
- before do # Redefine String#red just like colorize gem does it.
149
- @awesome_method = ''.method(:red)
150
-
151
- String.instance_eval do
152
- define_method :red do # Method arity is now 0 in Ruby 1.9+.
153
- "[red]#{self}[/red]"
154
- end
155
- end
156
- end
157
-
158
- after do # Restore String#red method.
159
- awesome_method = @awesome_method
160
- String.instance_eval do
161
- define_method :red, awesome_method
162
- end
163
- end
164
-
165
- it 'shoud not raise ArgumentError when formatting HTML' do
166
- out = 'hello'.ai(color: { string: :red }, html: true)
167
- if RUBY_VERSION >= '1.9'
168
- expect(out).to eq(%(<pre>[red]<kbd style="color:red">&quot;hello&quot;</kbd>[/red]</pre>))
169
- else
170
- expect(out).to eq(%(<pre>[red]&quot;hello&quot;[/red]</pre>))
171
- end
172
- end
173
-
174
- it 'shoud not raise ArgumentError when formatting HTML (shade color)' do
175
- out = 'hello'.ai(color: { string: :redish }, html: true)
176
- expect(out).to eq(%(<pre><kbd style="color:darkred">&quot;hello&quot;</kbd></pre>))
177
- end
178
-
179
- it 'shoud not raise ArgumentError when formatting non-HTML' do
180
- out = 'hello'.ai(color: { string: :red }, html: false)
181
- expect(out).to eq(%([red]"hello"[/red]))
182
- end
183
-
184
- it 'shoud not raise ArgumentError when formatting non-HTML (shade color)' do
185
- out = 'hello'.ai(color: { string: :redish }, html: false)
186
- expect(out).to eq(%(\e[0;31m"hello"\e[0m))
187
- end
188
- end
189
-
190
144
  #------------------------------------------------------------------------------
191
145
  describe 'Console' do
192
146
  it 'detects IRB' do
193
147
  class IRB; end
194
148
  ENV.delete('RAILS_ENV')
195
- expect(AmazingPrint.console?).to eq(true)
196
- expect(AmazingPrint.rails_console?).to eq(false)
149
+ expect(AmazingPrint.console?).to be(true)
150
+ expect(AmazingPrint.rails_console?).to be(false)
197
151
  Object.instance_eval { remove_const :IRB }
198
152
  end
199
153
 
200
154
  it 'detects Pry' do
201
155
  class Pry; end
202
156
  ENV.delete('RAILS_ENV')
203
- expect(AmazingPrint.console?).to eq(true)
204
- expect(AmazingPrint.rails_console?).to eq(false)
157
+ expect(AmazingPrint.console?).to be(true)
158
+ expect(AmazingPrint.rails_console?).to be(false)
205
159
  Object.instance_eval { remove_const :Pry }
206
160
  end
207
161
 
@@ -209,8 +163,8 @@ RSpec.describe 'AmazingPrint' do
209
163
  class IRB; end
210
164
 
211
165
  module Rails; class Console; end; end
212
- expect(AmazingPrint.console?).to eq(true)
213
- expect(AmazingPrint.rails_console?).to eq(true)
166
+ expect(AmazingPrint.console?).to be(true)
167
+ expect(AmazingPrint.rails_console?).to be(true)
214
168
  Object.instance_eval { remove_const :IRB }
215
169
  Object.instance_eval { remove_const :Rails }
216
170
  end
@@ -218,8 +172,8 @@ RSpec.describe 'AmazingPrint' do
218
172
  it "detects ENV['RAILS_ENV']" do
219
173
  class Pry; end
220
174
  ENV['RAILS_ENV'] = 'development'
221
- expect(AmazingPrint.console?).to eq(true)
222
- expect(AmazingPrint.rails_console?).to eq(true)
175
+ expect(AmazingPrint.console?).to be(true)
176
+ expect(AmazingPrint.rails_console?).to be(true)
223
177
  Object.instance_eval { remove_const :Pry }
224
178
  end
225
179
 
@@ -230,8 +184,8 @@ RSpec.describe 'AmazingPrint' do
230
184
 
231
185
  it 'returns nil when running under console' do
232
186
  class IRB; end
233
- expect(capture! { ap([1, 2, 3]) }).to eq(nil)
234
- expect(capture! { ap({ a: 1 }) }).to eq(nil)
187
+ expect(capture! { ap([1, 2, 3]) }).to be_nil
188
+ expect(capture! { ap({ a: 1 }) }).to be_nil
235
189
  Object.instance_eval { remove_const :IRB }
236
190
  end
237
191
 
data/spec/spec_helper.rb CHANGED
@@ -41,7 +41,7 @@ ExtVerifier.require_dependencies!(
41
41
  sequel
42
42
  ]
43
43
  )
44
- require 'nokogiri'
44
+ require 'nokogiri' unless RUBY_PLATFORM.include?('mswin')
45
45
  require 'amazing_print'
46
46
 
47
47
  RSpec.configure do |config|
@@ -66,6 +66,12 @@ RSpec.configure do |config|
66
66
  config.before do |_example|
67
67
  stub_dotfile!
68
68
  end
69
+
70
+ if RUBY_PLATFORM.include?('mswin')
71
+ config.filter_run_excluding unix: true
72
+ else
73
+ config.filter_run_excluding mswin: true
74
+ end
69
75
  end
70
76
 
71
77
  # This matcher handles the normalization of objects to replace non deterministic
@@ -0,0 +1,110 @@
1
+ #<User:placeholder_id
2
+ @_start_transaction_state = nil,
3
+ @association_cache = {},
4
+ @destroyed = false,
5
+ @marked_for_destruction = false,
6
+ @new_record = true,
7
+ @previously_new_record = false,
8
+ @primary_key = "id",
9
+ @readonly = false,
10
+ @strict_loading = false,
11
+ attr_accessor :attributes = #<ActiveModel::AttributeSet:placeholder_id
12
+ @attributes = {
13
+ "admin" => #<ActiveModel::Attribute::FromUser:placeholder_id
14
+ @original_attribute = #<ActiveModel::Attribute::FromDatabase:placeholder_id
15
+ @original_attribute = nil,
16
+ attr_reader :name = "admin",
17
+ attr_reader :type = #<ActiveModel::Type::Boolean:placeholder_id
18
+ attr_reader :limit = nil,
19
+ attr_reader :precision = nil,
20
+ attr_reader :scale = nil
21
+ >,
22
+ attr_reader :value_before_type_cast = nil
23
+ >,
24
+ attr_reader :name = "admin",
25
+ attr_reader :type = #<ActiveModel::Type::Boolean:placeholder_id
26
+ attr_reader :limit = nil,
27
+ attr_reader :precision = nil,
28
+ attr_reader :scale = nil
29
+ >,
30
+ attr_reader :value_before_type_cast = false
31
+ >,
32
+ "created_at" => #<ActiveModel::Attribute::FromUser:placeholder_id
33
+ @original_attribute = #<ActiveModel::Attribute::FromDatabase:placeholder_id
34
+ @original_attribute = nil,
35
+ attr_reader :name = "created_at",
36
+ attr_reader :type = #<ActiveRecord::Type::DateTime:placeholder_id
37
+ attr_reader :limit = nil,
38
+ attr_reader :precision = 6,
39
+ attr_reader :scale = nil
40
+ >,
41
+ attr_reader :value_before_type_cast = nil
42
+ >,
43
+ attr_reader :name = "created_at",
44
+ attr_reader :type = #<ActiveRecord::Type::DateTime:placeholder_id
45
+ attr_reader :limit = nil,
46
+ attr_reader :precision = 6,
47
+ attr_reader :scale = nil
48
+ >,
49
+ attr_reader :value_before_type_cast = "1992-10-10 12:30:00"
50
+ >,
51
+ "id" => #<ActiveModel::Attribute::FromDatabase:placeholder_id
52
+ @original_attribute = nil,
53
+ attr_reader :name = "id",
54
+ attr_reader :type = #<ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer:placeholder_id
55
+ @range = -9223372036854775808...9223372036854775808,
56
+ attr_reader :limit = nil,
57
+ attr_reader :precision = nil,
58
+ attr_reader :scale = nil
59
+ >,
60
+ attr_reader :value_before_type_cast = nil
61
+ >,
62
+ "name" => #<ActiveModel::Attribute::FromUser:placeholder_id
63
+ @original_attribute = #<ActiveModel::Attribute::FromDatabase:placeholder_id
64
+ @original_attribute = nil,
65
+ attr_reader :name = "name",
66
+ attr_reader :type = #<ActiveModel::Type::String:placeholder_id
67
+ @false = "f",
68
+ @true = "t",
69
+ attr_reader :limit = nil,
70
+ attr_reader :precision = nil,
71
+ attr_reader :scale = nil
72
+ >,
73
+ attr_reader :value_before_type_cast = nil
74
+ >,
75
+ attr_reader :name = "name",
76
+ attr_reader :type = #<ActiveModel::Type::String:placeholder_id
77
+ @false = "f",
78
+ @true = "t",
79
+ attr_reader :limit = nil,
80
+ attr_reader :precision = nil,
81
+ attr_reader :scale = nil
82
+ >,
83
+ attr_reader :value_before_type_cast = "Diana"
84
+ >,
85
+ "rank" => #<ActiveModel::Attribute::FromUser:placeholder_id
86
+ @original_attribute = #<ActiveModel::Attribute::FromDatabase:placeholder_id
87
+ @original_attribute = nil,
88
+ attr_reader :name = "rank",
89
+ attr_reader :type = #<ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer:placeholder_id
90
+ @range = -9223372036854775808...9223372036854775808,
91
+ attr_reader :limit = nil,
92
+ attr_reader :precision = nil,
93
+ attr_reader :scale = nil
94
+ >,
95
+ attr_reader :value_before_type_cast = nil
96
+ >,
97
+ attr_reader :name = "rank",
98
+ attr_reader :type = #<ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer:placeholder_id
99
+ @range = -9223372036854775808...9223372036854775808,
100
+ attr_reader :limit = nil,
101
+ attr_reader :precision = nil,
102
+ attr_reader :scale = nil
103
+ >,
104
+ attr_reader :value_before_type_cast = 1
105
+ >
106
+ }
107
+ >,
108
+ attr_accessor :destroyed_by_association = nil,
109
+ attr_reader :strict_loading_mode = :all
110
+ >