amazing_print 1.0.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/Appraisals +47 -51
  4. data/CHANGELOG.md +32 -0
  5. data/Gemfile +2 -0
  6. data/LICENSE +1 -0
  7. data/README.md +20 -13
  8. data/Rakefile +2 -0
  9. data/lib/amazing_print.rb +19 -17
  10. data/lib/amazing_print/colorize.rb +2 -0
  11. data/lib/amazing_print/core_ext/awesome_method_array.rb +3 -1
  12. data/lib/amazing_print/core_ext/class.rb +2 -0
  13. data/lib/amazing_print/core_ext/kernel.rb +2 -0
  14. data/lib/amazing_print/core_ext/logger.rb +11 -2
  15. data/lib/amazing_print/core_ext/object.rb +2 -0
  16. data/lib/amazing_print/core_ext/string.rb +5 -2
  17. data/lib/amazing_print/custom_defaults.rb +3 -1
  18. data/lib/amazing_print/ext/action_view.rb +3 -1
  19. data/lib/amazing_print/ext/active_record.rb +9 -18
  20. data/lib/amazing_print/ext/active_support.rb +2 -0
  21. data/lib/amazing_print/ext/mongo_mapper.rb +4 -2
  22. data/lib/amazing_print/ext/mongoid.rb +2 -0
  23. data/lib/amazing_print/ext/nobrainer.rb +6 -0
  24. data/lib/amazing_print/ext/nokogiri.rb +2 -0
  25. data/lib/amazing_print/ext/ostruct.rb +2 -0
  26. data/lib/amazing_print/ext/ripple.rb +2 -0
  27. data/lib/amazing_print/ext/sequel.rb +4 -2
  28. data/lib/amazing_print/formatter.rb +9 -2
  29. data/lib/amazing_print/formatters.rb +12 -10
  30. data/lib/amazing_print/formatters/array_formatter.rb +3 -1
  31. data/lib/amazing_print/formatters/base_formatter.rb +5 -2
  32. data/lib/amazing_print/formatters/class_formatter.rb +2 -0
  33. data/lib/amazing_print/formatters/dir_formatter.rb +4 -1
  34. data/lib/amazing_print/formatters/file_formatter.rb +4 -1
  35. data/lib/amazing_print/formatters/hash_formatter.rb +4 -2
  36. data/lib/amazing_print/formatters/method_formatter.rb +2 -0
  37. data/lib/amazing_print/formatters/object_formatter.rb +14 -13
  38. data/lib/amazing_print/formatters/simple_formatter.rb +2 -0
  39. data/lib/amazing_print/formatters/struct_formatter.rb +9 -7
  40. data/lib/amazing_print/indentator.rb +2 -0
  41. data/lib/amazing_print/inspector.rb +9 -9
  42. data/lib/amazing_print/version.rb +3 -1
  43. data/lib/ap.rb +3 -1
  44. data/spec/active_record_helper.rb +10 -0
  45. data/spec/colors_spec.rb +43 -46
  46. data/spec/core_ext/logger_spec.rb +40 -14
  47. data/spec/core_ext/string_spec.rb +2 -7
  48. data/spec/ext/action_controller_spec.rb +40 -0
  49. data/spec/ext/action_view_spec.rb +8 -1
  50. data/spec/ext/active_model_spec.rb +37 -0
  51. data/spec/ext/active_record_spec.rb +42 -7
  52. data/spec/ext/active_support_spec.rb +12 -1
  53. data/spec/ext/mongo_mapper_spec.rb +8 -6
  54. data/spec/ext/mongoid_spec.rb +2 -0
  55. data/spec/ext/nobrainer_spec.rb +2 -0
  56. data/spec/ext/nokogiri_spec.rb +2 -0
  57. data/spec/ext/ostruct_spec.rb +2 -0
  58. data/spec/ext/ripple_spec.rb +2 -0
  59. data/spec/ext/sequel_spec.rb +45 -0
  60. data/spec/formats_spec.rb +10 -8
  61. data/spec/methods_spec.rb +37 -3
  62. data/spec/misc_spec.rb +3 -1
  63. data/spec/objects_spec.rb +2 -0
  64. data/spec/sequel_helper.rb +18 -0
  65. data/spec/spec_helper.rb +5 -1
  66. data/spec/support/active_record_data.rb +2 -0
  67. data/spec/support/active_record_data/6_1_diana.txt +109 -0
  68. data/spec/support/active_record_data/6_1_multi.txt +220 -0
  69. data/spec/support/ext_verifier.rb +9 -4
  70. data/spec/support/mongoid_versions.rb +2 -0
  71. data/spec/support/rails_versions.rb +7 -0
  72. metadata +79 -54
  73. data/lib/amazing_print/core_ext/method.rb +0 -21
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (c) 2010-2016 Michael Dvorkin and contributors
2
4
  #
3
5
  # AmazingPrint is freely distributable under the terms of MIT license.
@@ -5,6 +7,6 @@
5
7
  #------------------------------------------------------------------------------
6
8
  module AmazingPrint
7
9
  def self.version
8
- '1.0.0'
10
+ '1.3.0'
9
11
  end
10
12
  end
data/lib/ap.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (c) 2010-2016 Michael Dvorkin and contributors
2
4
  #
3
5
  # AmazingPrint is freely distributable under the terms of MIT license.
@@ -7,4 +9,4 @@
7
9
  # Keeping this for backwards compatibility to allow
8
10
  # require "ap"
9
11
  #
10
- require File.dirname(__FILE__) + '/amazing_print'
12
+ require_relative 'amazing_print'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if ExtVerifier.has_rails?
2
4
  # Required to use the column support
3
5
  module Rails
@@ -27,4 +29,12 @@ if ExtVerifier.has_rails?
27
29
  class User < ActiveRecord::Base; has_many :emails; end
28
30
  class SubUser < User; end
29
31
  class Email < ActiveRecord::Base; belongs_to :user; end
32
+ class TableFreeModel
33
+ include ::ActiveModel::Validations
34
+ attr_reader(:name)
35
+
36
+ def attributes
37
+ { 'name' => name }
38
+ end
39
+ end
30
40
  end
data/spec/colors_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe 'AmazingPrint' do
@@ -18,8 +20,8 @@ RSpec.describe 'AmazingPrint' do
18
20
  end
19
21
 
20
22
  describe 'colorization' do
21
- PLAIN = '[ 1, :two, "three", [ nil, [ true, false ] ] ]'.freeze
22
- COLORIZED = "[ \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 ] ] ]".freeze
23
+ PLAIN = '[ 1, :two, "three", [ nil, [ true, false ] ] ]'
24
+ COLORIZED = "[ \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 ] ] ]"
23
25
 
24
26
  before do
25
27
  ENV['TERM'] = 'xterm-colors'
@@ -38,34 +40,28 @@ RSpec.describe 'AmazingPrint' do
38
40
  end
39
41
 
40
42
  it "colorizes processes with ENV['ANSICON'] by default" do
41
- begin
42
- stub_tty!
43
- term = ENV['ANSICON']
44
- ENV['ANSICON'] = '1'
45
- expect(@arr.ai(multiline: false)).to eq(COLORIZED)
46
- ensure
47
- ENV['ANSICON'] = term
48
- end
43
+ stub_tty!
44
+ term = ENV['ANSICON']
45
+ ENV['ANSICON'] = '1'
46
+ expect(@arr.ai(multiline: false)).to eq(COLORIZED)
47
+ ensure
48
+ ENV['ANSICON'] = term
49
49
  end
50
50
 
51
51
  it 'does not colorize tty processes running in dumb terminals by default' do
52
- begin
53
- stub_tty!
54
- term = ENV['TERM']
55
- ENV['TERM'] = 'dumb'
56
- expect(@arr.ai(multiline: false)).to eq(PLAIN)
57
- ensure
58
- ENV['TERM'] = term
59
- end
52
+ stub_tty!
53
+ term = ENV['TERM']
54
+ ENV['TERM'] = 'dumb'
55
+ expect(@arr.ai(multiline: false)).to eq(PLAIN)
56
+ ensure
57
+ ENV['TERM'] = term
60
58
  end
61
59
 
62
60
  it 'does not colorize subprocesses by default' do
63
- begin
64
- stub_tty! false
65
- expect(@arr.ai(multiline: false)).to eq(PLAIN)
66
- ensure
67
- stub_tty!
68
- end
61
+ stub_tty! false
62
+ expect(@arr.ai(multiline: false)).to eq(PLAIN)
63
+ ensure
64
+ stub_tty!
69
65
  end
70
66
  end
71
67
 
@@ -80,34 +76,35 @@ RSpec.describe 'AmazingPrint' do
80
76
  end
81
77
 
82
78
  it "colorizes processes with ENV['ANSICON'] set to 0" do
83
- begin
84
- stub_tty!
85
- term = ENV['ANSICON']
86
- ENV['ANSICON'] = '1'
87
- expect(@arr.ai(multiline: false)).to eq(COLORIZED)
88
- ensure
89
- ENV['ANSICON'] = term
90
- end
79
+ stub_tty!
80
+ term = ENV['ANSICON']
81
+ ENV['ANSICON'] = '1'
82
+ expect(@arr.ai(multiline: false)).to eq(COLORIZED)
83
+ ensure
84
+ ENV['ANSICON'] = term
91
85
  end
92
86
 
93
87
  it 'colorizes dumb terminals' do
94
- begin
95
- stub_tty!
96
- term = ENV['TERM']
97
- ENV['TERM'] = 'dumb'
98
- expect(@arr.ai(multiline: false)).to eq(COLORIZED)
99
- ensure
100
- ENV['TERM'] = term
101
- end
88
+ stub_tty!
89
+ term = ENV['TERM']
90
+ ENV['TERM'] = 'dumb'
91
+ expect(@arr.ai(multiline: false)).to eq(COLORIZED)
92
+ ensure
93
+ ENV['TERM'] = term
102
94
  end
103
95
 
104
96
  it 'colorizes subprocess' do
105
- begin
106
- stub_tty! false
107
- expect(@arr.ai(multiline: false)).to eq(COLORIZED)
108
- ensure
109
- stub_tty!
110
- end
97
+ stub_tty! false
98
+ expect(@arr.ai(multiline: false)).to eq(COLORIZED)
99
+ ensure
100
+ stub_tty!
101
+ end
102
+ end
103
+
104
+ describe 'uncolor' do
105
+ it 'removes any ANSI color codes' do
106
+ expect('red'.red + 'blue'.blue).to eq "\e[1;31mred\e[0m\e[1;34mblue\e[0m"
107
+ expect(('red'.red + 'blue'.blue).uncolor).to eq 'redblue'
111
108
  end
112
109
  end
113
110
  end
@@ -1,22 +1,29 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  require 'logger'
4
6
  require 'amazing_print/core_ext/logger'
5
7
 
6
8
  RSpec.describe 'AmazingPrint logging extensions' do
7
- before(:all) do
8
- @logger = begin
9
- Logger.new('/dev/null')
10
- rescue Errno::ENOENT
11
- Logger.new('nul')
12
- end
9
+ let(:object) { double }
10
+ let(:options) { { sort_keys: true } }
11
+
12
+ subject(:logger) do
13
+ Logger.new('/dev/null')
14
+ rescue Errno::ENOENT
15
+ Logger.new('nul')
13
16
  end
14
17
 
15
18
  describe 'ap method' do
16
19
  it 'should awesome_inspect the given object' do
17
- object = double
18
20
  expect(object).to receive(:ai)
19
- @logger.ap object
21
+ logger.ap object
22
+ end
23
+
24
+ it 'passes options to `ai`' do
25
+ expect(object).to receive(:ai).with(options)
26
+ logger.ap object, options
20
27
  end
21
28
 
22
29
  describe 'the log level' do
@@ -25,19 +32,38 @@ RSpec.describe 'AmazingPrint logging extensions' do
25
32
  end
26
33
 
27
34
  it 'should fallback to the default :debug log level' do
28
- expect(@logger).to receive(:debug)
29
- @logger.ap(nil)
35
+ expect(logger).to receive(:debug)
36
+ logger.ap nil
30
37
  end
31
38
 
32
39
  it 'should use the global user default if no level passed' do
33
40
  AmazingPrint.defaults = { log_level: :info }
34
- expect(@logger).to receive(:info)
35
- @logger.ap(nil)
41
+ expect(logger).to receive(:info)
42
+ logger.ap nil
36
43
  end
37
44
 
38
45
  it 'should use the passed in level' do
39
- expect(@logger).to receive(:warn)
40
- @logger.ap(nil, :warn)
46
+ expect(logger).to receive(:warn)
47
+ logger.ap nil, :warn
48
+ end
49
+
50
+ it 'makes no difference if passed as a hash or a part of options' do
51
+ expect(logger).to receive(:warn)
52
+ logger.ap nil, { level: :warn }
53
+ end
54
+
55
+ context 'when given options' do
56
+ it 'uses the default log level with the options' do
57
+ expect(logger).to receive(:debug)
58
+ expect(object).to receive(:ai).with(options)
59
+ logger.ap object, options
60
+ end
61
+
62
+ it 'still uses the passed in level with options' do
63
+ expect(logger).to receive(:warn)
64
+ expect(object).to receive(:ai).with(options)
65
+ logger.ap object, options.merge({ level: :warn })
66
+ end
41
67
  end
42
68
  end
43
69
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe 'String extensions' do
@@ -10,11 +12,4 @@ RSpec.describe 'String extensions' do
10
12
  expect(color.to_s.send(:"#{color}ish")).to eq("\e[0;#{30 + i}m#{color}\e[0m")
11
13
  end
12
14
  end
13
-
14
- it 'should have black and pale colors' do
15
- expect('black'.send(:black)).to eq('black'.send(:grayish))
16
- expect('pale'.send(:pale)).to eq('pale'.send(:whiteish))
17
- expect('pale'.send(:pale)).to eq("\e[0;37mpale\e[0m")
18
- expect('whiteish'.send(:whiteish)).to eq("\e[0;37mwhiteish\e[0m")
19
- end
20
15
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe 'AmazingPrint::ActionController', skip: -> { !ExtVerifier.has_rails? }.call do
6
+ let(:inspector) { AmazingPrint::Inspector.new }
7
+
8
+ context 'with unpermitted ActionController::Parameters' do
9
+ let(:parameters) do
10
+ ActionController::Parameters.new post: { id: 1, content: 'Some' }
11
+ end
12
+
13
+ it 'should format as an object' do
14
+ expect(inspector.send(:awesome, parameters)).to match(
15
+ /\A#?<ActionController::Parameters {"post"=>{"id"=>1, "content"=>"Some"}} permitted: false>\z/
16
+ )
17
+ end
18
+ end
19
+
20
+ context 'with permitted ActionController::Parameters' do
21
+ let(:expected_output) do
22
+ <<~OUTPUT
23
+ {
24
+ \"post\"\e[0;37m => \e[0m{
25
+ \"id\"\e[0;37m => \e[0m\e[1;34m1\e[0m,
26
+ \"content\"\e[0;37m => \e[0m\e[0;33m\"Some\"\e[0m
27
+ }
28
+ }
29
+ OUTPUT
30
+ .chomp
31
+ end
32
+ let(:parameters) do
33
+ ActionController::Parameters.new post: { id: 1, content: 'Some' }
34
+ end
35
+
36
+ it 'should format as a hash' do
37
+ expect(inspector.send(:awesome, parameters.permit!)).to eq expected_output
38
+ end
39
+ end
40
+ end
@@ -1,6 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
- RSpec.describe 'AmazingPrint ActionView extensions', skip: -> { !ExtVerifier.has_rails? }.call do
5
+ RSpec.describe 'AmazingPrint ActionView extensions',
6
+ skip: -> { !ExtVerifier.has_rails? || ActiveRecord::VERSION::STRING >= '6.1' }.call do
4
7
  before do
5
8
  @view = ActionView::Base.new
6
9
  end
@@ -14,4 +17,8 @@ RSpec.describe 'AmazingPrint ActionView extensions', skip: -> { !ExtVerifier.has
14
17
  markup = ' &<hello>'
15
18
  expect(@view.ap(markup)).to eq('<pre class="debug_dump"><kbd style="color:brown">&quot; &amp;&lt;hello&gt;&quot;</kbd></pre>')
16
19
  end
20
+
21
+ it 'uses HTML and does set output to HTML safe' do
22
+ expect(@view.ap('<p>Hello World</p>')).to be_html_safe
23
+ end
17
24
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'active_record_helper'
5
+
6
+ RSpec.describe 'ActiveModel::Errors formatting', skip: -> { !ExtVerifier.has_rails? }.call do
7
+ before do
8
+ @ap = AmazingPrint::Inspector.new(plain: true)
9
+ end
10
+
11
+ it 'should format active_model_errors properly' do
12
+ model = TableFreeModel.new
13
+ model.errors.add(:name, "can't be blank")
14
+
15
+ out = @ap.awesome(model.errors)
16
+
17
+ str = <<~ERRORS.strip
18
+ #<ActiveModel::Errors:placeholder_id> {
19
+ "name" => nil,
20
+ :details => {
21
+ :name => [
22
+ [0] {
23
+ :error => "can't be blank"
24
+ }
25
+ ]
26
+ },
27
+ :messages => {
28
+ :name => [
29
+ [0] "can't be blank"
30
+ ]
31
+ }
32
+ }
33
+ ERRORS
34
+
35
+ expect(out).to be_similar_to(str)
36
+ end
37
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'active_record_helper'
3
5
 
@@ -126,7 +128,9 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
126
128
  out = @ap.awesome(@diana)
127
129
 
128
130
  raw_object_string =
129
- if activerecord_6_0?
131
+ if activerecord_6_1?
132
+ ActiveRecordData.raw_6_1_diana
133
+ elsif activerecord_6_0?
130
134
  ActiveRecordData.raw_6_0_diana
131
135
  elsif activerecord_5_2?
132
136
  ActiveRecordData.raw_5_2_diana
@@ -152,7 +156,7 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
152
156
  end
153
157
  end
154
158
 
155
- if RUBY_PLATFORM == 'java'
159
+ if RUBY_PLATFORM == 'java' && !activerecord_6_1?
156
160
  raw_object_string.gsub!(
157
161
  'ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer',
158
162
  'ArJdbc::SQLite3::SQLite3Integer'
@@ -166,7 +170,9 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
166
170
  out = @ap.awesome([@diana, @laura])
167
171
 
168
172
  raw_object_string =
169
- if activerecord_6_0?
173
+ if activerecord_6_1?
174
+ ActiveRecordData.raw_6_1_multi
175
+ elsif activerecord_6_0?
170
176
  ActiveRecordData.raw_6_0_multi
171
177
  elsif activerecord_5_2?
172
178
  ActiveRecordData.raw_5_2_multi
@@ -192,7 +198,7 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
192
198
  end
193
199
  end
194
200
 
195
- if RUBY_PLATFORM == 'java'
201
+ if RUBY_PLATFORM == 'java' && !activerecord_6_1?
196
202
  raw_object_string.gsub!(
197
203
  'ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer',
198
204
  'ArJdbc::SQLite3::SQLite3Integer'
@@ -238,6 +244,11 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
238
244
  it 'should print ActiveRecord::Base objects (ex. ancestors)' do
239
245
  expect { @ap.awesome(User.ancestors) }.not_to raise_error
240
246
  end
247
+
248
+ it 'should print valid HTML for subclasses' do
249
+ @ap = AmazingPrint::Inspector.new(html: true)
250
+ expect(@ap.awesome(SubUser)).to match('SubUser &lt; User')
251
+ end
241
252
  end
242
253
 
243
254
  #------------------------------------------------------------------------------
@@ -255,7 +266,19 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
255
266
  expect(out).to match(
256
267
  /\s+first\(\*args,\s&block\)\s+#<Class:\w+>\s+\(ActiveRecord::Querying\)/
257
268
  )
258
- elsif RUBY_VERSION >= '2.4.4'
269
+ elsif RUBY_VERSION >= '3.0.0'
270
+ expect(out).to match(
271
+ /\s*first\(\*(\*|args),\s+&(&|block)\)\s+#<Class:User> \(ActiveRecord::Querying\)/
272
+ )
273
+ elsif RUBY_VERSION >= '2.7.2'
274
+ expect(out).to match(
275
+ /\s*first\(\*(\*|args),\s+&(&|block)\)\s+User/
276
+ )
277
+ elsif RUBY_VERSION >= '2.7.0'
278
+ expect(out).to match(
279
+ /\s*first\(\*(\*|args),\s+&(&|block)\)\s+#<Class:ActiveRecord::Base> \(ActiveRecord::Querying\)/
280
+ )
281
+ elsif RUBY_VERSION =~ /^2\.4\.([4-9]|[1-9][0-9])|^2\.[56]\./
259
282
  expect(out).to match(/\sfirst\(\*arg.*?\)\s+User/)
260
283
  elsif RUBY_VERSION >= '1.9'
261
284
  expect(out).to match(/\sfirst\(\*args,\s&block\)\s+Class \(ActiveRecord::Querying\)/)
@@ -272,7 +295,13 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
272
295
  expect(out).to match(
273
296
  /\sprimary_key\(.*?\)\s+#<Class:\w+>\s\(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/
274
297
  )
275
- elsif RUBY_VERSION >= '2.4.4'
298
+ elsif RUBY_VERSION >= '3.0.0'
299
+ expect(out).to match(/\sprimary_key\(.*?\)\s+#<Class:User> \(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/)
300
+ elsif RUBY_VERSION =~ /^2\.7\.(0|1)/
301
+ expect(out).to match(
302
+ /\sprimary_key\(.*?\)\s+.+Class.+\(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/
303
+ )
304
+ elsif RUBY_VERSION =~ /^2\.4\.([4-9]|[1-9][0-9])|^2\.[56]\./ || RUBY_VERSION >= '2.7.2'
276
305
  expect(out).to match(/\sprimary_key\(.*?\)\s+User/)
277
306
  else
278
307
  expect(out).to match(/\sprimary_key\(.*?\)\s+Class \(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/)
@@ -286,7 +315,13 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
286
315
  else
287
316
  if RUBY_PLATFORM == 'java'
288
317
  expect(out).to match(/\svalidate\(\*arg.*?\)\s+#<Class:\w+> \(ActiveModel::Validations::ClassMethods\)/)
289
- elsif RUBY_VERSION >= '2.4.4'
318
+ elsif RUBY_VERSION >= '3.0.0'
319
+ expect(out).to match(/\svalidate\(\*arg.*?\)\s+#<Class:User> \(ActiveModel::Validations::ClassMethods\)/)
320
+ elsif RUBY_VERSION =~ /2\.7\.(0|1)/
321
+ expect(out).to match(
322
+ /\svalidate\(\*args.*?\)\s+#<Class:ActiveRecord::Base> \(ActiveModel::Validations::ClassMethods\)/
323
+ )
324
+ elsif RUBY_VERSION =~ /^2\.4\.([4-9]|[1-9][0-9])|^2\.[56]\./ || RUBY_VERSION >= '2.7.2'
290
325
  expect(out).to match(/\svalidate\(\*arg.*?\)\s+User/)
291
326
  else
292
327
  expect(out).to match(/\svalidate\(\*arg.*?\)\s+Class \(ActiveModel::Validations::ClassMethods\)/)