amazing_print 1.5.0 → 1.8.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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +79 -37
  3. data/README.md +11 -11
  4. data/lib/amazing_print/core_ext/awesome_method_array.rb +3 -3
  5. data/lib/amazing_print/custom_defaults.rb +7 -1
  6. data/lib/amazing_print/ext/active_record.rb +32 -2
  7. data/lib/amazing_print/ext/mongo_mapper.rb +2 -2
  8. data/lib/amazing_print/ext/mongoid.rb +14 -2
  9. data/lib/amazing_print/ext/nobrainer.rb +2 -2
  10. data/lib/amazing_print/ext_loader.rb +27 -0
  11. data/lib/amazing_print/formatter.rb +1 -1
  12. data/lib/amazing_print/formatters/array_formatter.rb +1 -1
  13. data/lib/amazing_print/formatters/base_formatter.rb +14 -5
  14. data/lib/amazing_print/formatters/hash_formatter.rb +28 -11
  15. data/lib/amazing_print/formatters/mswin_helper.rb +4 -4
  16. data/lib/amazing_print/formatters/object_formatter.rb +2 -2
  17. data/lib/amazing_print/formatters/struct_formatter.rb +2 -2
  18. data/lib/amazing_print/inspector.rb +8 -5
  19. data/lib/amazing_print/version.rb +1 -1
  20. data/lib/amazing_print.rb +2 -8
  21. metadata +9 -62
  22. data/.gitignore +0 -35
  23. data/Appraisals +0 -50
  24. data/Gemfile +0 -15
  25. data/Gemfile.lock +0 -83
  26. data/LICENSE +0 -22
  27. data/Rakefile +0 -25
  28. data/spec/active_record_helper.rb +0 -43
  29. data/spec/colors_spec.rb +0 -120
  30. data/spec/core_ext/logger_spec.rb +0 -70
  31. data/spec/ext/action_controller_spec.rb +0 -40
  32. data/spec/ext/action_view_spec.rb +0 -24
  33. data/spec/ext/active_model_spec.rb +0 -37
  34. data/spec/ext/active_record_spec.rb +0 -298
  35. data/spec/ext/active_support_spec.rb +0 -37
  36. data/spec/ext/mongo_mapper_spec.rb +0 -265
  37. data/spec/ext/mongoid_spec.rb +0 -72
  38. data/spec/ext/nobrainer_spec.rb +0 -64
  39. data/spec/ext/nokogiri_spec.rb +0 -52
  40. data/spec/ext/ostruct_spec.rb +0 -24
  41. data/spec/ext/ripple_spec.rb +0 -53
  42. data/spec/ext/sequel_spec.rb +0 -45
  43. data/spec/formats_spec.rb +0 -792
  44. data/spec/methods_spec.rb +0 -520
  45. data/spec/misc_spec.rb +0 -206
  46. data/spec/objects_spec.rb +0 -225
  47. data/spec/sequel_helper.rb +0 -18
  48. data/spec/spec_helper.rb +0 -112
  49. data/spec/support/active_record_data/3_2_diana.txt +0 -24
  50. data/spec/support/active_record_data/3_2_diana_legacy.txt +0 -24
  51. data/spec/support/active_record_data/3_2_multi.txt +0 -50
  52. data/spec/support/active_record_data/3_2_multi_legacy.txt +0 -50
  53. data/spec/support/active_record_data/4_0_diana.txt +0 -98
  54. data/spec/support/active_record_data/4_0_multi.txt +0 -198
  55. data/spec/support/active_record_data/4_1_diana.txt +0 -97
  56. data/spec/support/active_record_data/4_1_multi.txt +0 -196
  57. data/spec/support/active_record_data/4_2_diana.txt +0 -109
  58. data/spec/support/active_record_data/4_2_diana_legacy.txt +0 -109
  59. data/spec/support/active_record_data/4_2_multi.txt +0 -220
  60. data/spec/support/active_record_data/4_2_multi_legacy.txt +0 -220
  61. data/spec/support/active_record_data/5_0_diana.txt +0 -105
  62. data/spec/support/active_record_data/5_0_multi.txt +0 -212
  63. data/spec/support/active_record_data/5_1_diana.txt +0 -104
  64. data/spec/support/active_record_data/5_1_multi.txt +0 -210
  65. data/spec/support/active_record_data/5_2_diana.txt +0 -104
  66. data/spec/support/active_record_data/5_2_multi.txt +0 -210
  67. data/spec/support/active_record_data/6_0_diana.txt +0 -104
  68. data/spec/support/active_record_data/6_0_multi.txt +0 -210
  69. data/spec/support/active_record_data/6_1_diana.txt +0 -109
  70. data/spec/support/active_record_data/6_1_multi.txt +0 -220
  71. data/spec/support/active_record_data.rb +0 -22
  72. data/spec/support/ext_verifier.rb +0 -46
  73. data/spec/support/mongoid_versions.rb +0 -24
  74. data/spec/support/rails_versions.rb +0 -57
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazing_print
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Dvorkin
8
- - Kevin McCormackPatrik Wenger
9
- autorequire:
8
+ - Kevin McCormack
9
+ - Patrik Wenger
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-05-24 00:00:00.000000000 Z
12
+ date: 1980-01-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: 'Great Ruby debugging companion: pretty print Ruby objects to visualize
15
15
  their structure. Supports custom object formatting via plugins'
@@ -18,15 +18,9 @@ executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
- - ".gitignore"
22
- - Appraisals
23
21
  - CHANGELOG.md
24
22
  - CONTRIBUTING.md
25
- - Gemfile
26
- - Gemfile.lock
27
- - LICENSE
28
23
  - README.md
29
- - Rakefile
30
24
  - lib/amazing_print.rb
31
25
  - lib/amazing_print/colorize.rb
32
26
  - lib/amazing_print/colors.rb
@@ -46,6 +40,7 @@ files:
46
40
  - lib/amazing_print/ext/ostruct.rb
47
41
  - lib/amazing_print/ext/ripple.rb
48
42
  - lib/amazing_print/ext/sequel.rb
43
+ - lib/amazing_print/ext_loader.rb
49
44
  - lib/amazing_print/formatter.rb
50
45
  - lib/amazing_print/formatters.rb
51
46
  - lib/amazing_print/formatters/array_formatter.rb
@@ -63,58 +58,11 @@ files:
63
58
  - lib/amazing_print/inspector.rb
64
59
  - lib/amazing_print/version.rb
65
60
  - lib/ap.rb
66
- - spec/active_record_helper.rb
67
- - spec/colors_spec.rb
68
- - spec/core_ext/logger_spec.rb
69
- - spec/ext/action_controller_spec.rb
70
- - spec/ext/action_view_spec.rb
71
- - spec/ext/active_model_spec.rb
72
- - spec/ext/active_record_spec.rb
73
- - spec/ext/active_support_spec.rb
74
- - spec/ext/mongo_mapper_spec.rb
75
- - spec/ext/mongoid_spec.rb
76
- - spec/ext/nobrainer_spec.rb
77
- - spec/ext/nokogiri_spec.rb
78
- - spec/ext/ostruct_spec.rb
79
- - spec/ext/ripple_spec.rb
80
- - spec/ext/sequel_spec.rb
81
- - spec/formats_spec.rb
82
- - spec/methods_spec.rb
83
- - spec/misc_spec.rb
84
- - spec/objects_spec.rb
85
- - spec/sequel_helper.rb
86
- - spec/spec_helper.rb
87
- - spec/support/active_record_data.rb
88
- - spec/support/active_record_data/3_2_diana.txt
89
- - spec/support/active_record_data/3_2_diana_legacy.txt
90
- - spec/support/active_record_data/3_2_multi.txt
91
- - spec/support/active_record_data/3_2_multi_legacy.txt
92
- - spec/support/active_record_data/4_0_diana.txt
93
- - spec/support/active_record_data/4_0_multi.txt
94
- - spec/support/active_record_data/4_1_diana.txt
95
- - spec/support/active_record_data/4_1_multi.txt
96
- - spec/support/active_record_data/4_2_diana.txt
97
- - spec/support/active_record_data/4_2_diana_legacy.txt
98
- - spec/support/active_record_data/4_2_multi.txt
99
- - spec/support/active_record_data/4_2_multi_legacy.txt
100
- - spec/support/active_record_data/5_0_diana.txt
101
- - spec/support/active_record_data/5_0_multi.txt
102
- - spec/support/active_record_data/5_1_diana.txt
103
- - spec/support/active_record_data/5_1_multi.txt
104
- - spec/support/active_record_data/5_2_diana.txt
105
- - spec/support/active_record_data/5_2_multi.txt
106
- - spec/support/active_record_data/6_0_diana.txt
107
- - spec/support/active_record_data/6_0_multi.txt
108
- - spec/support/active_record_data/6_1_diana.txt
109
- - spec/support/active_record_data/6_1_multi.txt
110
- - spec/support/ext_verifier.rb
111
- - spec/support/mongoid_versions.rb
112
- - spec/support/rails_versions.rb
113
61
  homepage: https://github.com/amazing-print/amazing_print
114
62
  licenses:
115
63
  - MIT
116
- metadata: {}
117
- post_install_message:
64
+ metadata:
65
+ changelog_uri: https://github.com/amazing-print/amazing_print/blob/master/CHANGELOG.md
118
66
  rdoc_options: []
119
67
  require_paths:
120
68
  - lib
@@ -122,15 +70,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
70
  requirements:
123
71
  - - ">="
124
72
  - !ruby/object:Gem::Version
125
- version: 2.5.0
73
+ version: 3.1.0
126
74
  required_rubygems_version: !ruby/object:Gem::Requirement
127
75
  requirements:
128
76
  - - ">="
129
77
  - !ruby/object:Gem::Version
130
78
  version: '0'
131
79
  requirements: []
132
- rubygems_version: 3.4.10
133
- signing_key:
80
+ rubygems_version: 3.6.7
134
81
  specification_version: 4
135
82
  summary: Pretty print Ruby objects with proper indentation and colors
136
83
  test_files: []
data/.gitignore DELETED
@@ -1,35 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## RUBYMINE
17
- .idea
18
-
19
- ## PROJECT::GENERAL
20
- coverage
21
- rdoc
22
- pkg
23
- .ruby-version
24
- gemfiles/*.gemfile.lock
25
- Gemfile.lock
26
- /tmp
27
- /.bundle
28
- /gemfiles/.bundle
29
-
30
- ## PROJECT::RVM
31
- .rvmrc
32
-
33
- # PROJECT::RBENV
34
- .ruby-gemset
35
- *.gem
data/Appraisals DELETED
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if RUBY_VERSION < '3'
4
- appraise 'rails-5.2' do
5
- gem 'activerecord-jdbcsqlite3-adapter', '~> 52.0', platform: :jruby
6
- gem 'rails', '~> 5.2.0'
7
- gem 'sqlite3', platform: :mri
8
- end
9
-
10
- appraise 'rails-6.0' do
11
- gem 'activerecord-jdbcsqlite3-adapter', '~> 60.0', platform: :jruby
12
- gem 'rails', '~> 6.0.0'
13
- gem 'sqlite3', platform: :mri
14
- end
15
-
16
- appraise 'mongoid-4.0' do
17
- # https://github.com/rails/rails/issues/34822#issuecomment-570670516
18
- gem 'bigdecimal', '~> 1.4', platforms: :mri
19
- gem 'mongoid', '~> 4.0.0'
20
- end
21
-
22
- appraise 'mongoid-5.0' do
23
- # https://github.com/rails/rails/issues/34822#issuecomment-570670516
24
- gem 'bigdecimal', '~> 1.4', platforms: :mri
25
- gem 'mongoid', '~> 5.0.0'
26
- end
27
-
28
- appraise 'mongoid-6.0' do
29
- gem 'mongoid', '~> 6.0.0'
30
- end
31
-
32
- appraise 'mongo_mapper' do
33
- gem 'activemodel', '~> 4.2.0'
34
- gem 'activesupport', '~> 4.2.0'
35
- gem 'bigdecimal', '~> 1.4', platforms: :mri
36
- gem 'mongo_mapper', '~> 0.14'
37
- end
38
- end
39
-
40
- appraise 'rails-6.1' do
41
- gem 'activerecord-jdbcsqlite3-adapter', '~> 61.0', platform: :jruby
42
- gem 'rails', '~> 6.1.0'
43
- gem 'sqlite3', platform: :mri
44
- end
45
-
46
- appraise 'sequel-5.0' do
47
- gem 'jdbc-sqlite3', platform: :jruby
48
- gem 'sequel', '~> 5.0'
49
- gem 'sqlite3', platform: :mri
50
- end
data/Gemfile DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in amazing_print.gemspec
6
- gemspec
7
-
8
- # Development dependencies
9
- gem 'appraisal', '~> 2.3'
10
- gem 'fakefs', '~> 1.2'
11
- gem 'nokogiri', '~> 1.10'
12
- gem 'pry'
13
- gem 'rspec', '~> 3.9'
14
- gem 'rubocop', '~> 1.20'
15
- gem 'rubocop-rspec', '~> 2.4'
data/Gemfile.lock DELETED
@@ -1,83 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- amazing_print (1.5.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- appraisal (2.4.1)
10
- bundler
11
- rake
12
- thor (>= 0.14.0)
13
- ast (2.4.2)
14
- coderay (1.1.3)
15
- diff-lcs (1.5.0)
16
- fakefs (1.9.0)
17
- json (2.6.3)
18
- method_source (1.0.0)
19
- nokogiri (1.15.2-x86_64-linux)
20
- racc (~> 1.4)
21
- parallel (1.23.0)
22
- parser (3.2.2.1)
23
- ast (~> 2.4.1)
24
- pry (0.14.2)
25
- coderay (~> 1.1)
26
- method_source (~> 1.0)
27
- racc (1.6.2)
28
- rainbow (3.1.1)
29
- rake (13.0.6)
30
- regexp_parser (2.8.0)
31
- rexml (3.2.5)
32
- rspec (3.12.0)
33
- rspec-core (~> 3.12.0)
34
- rspec-expectations (~> 3.12.0)
35
- rspec-mocks (~> 3.12.0)
36
- rspec-core (3.12.2)
37
- rspec-support (~> 3.12.0)
38
- rspec-expectations (3.12.3)
39
- diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.12.0)
41
- rspec-mocks (3.12.5)
42
- diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.12.0)
44
- rspec-support (3.12.0)
45
- rubocop (1.51.0)
46
- json (~> 2.3)
47
- parallel (~> 1.10)
48
- parser (>= 3.2.0.0)
49
- rainbow (>= 2.2.2, < 4.0)
50
- regexp_parser (>= 1.8, < 3.0)
51
- rexml (>= 3.2.5, < 4.0)
52
- rubocop-ast (>= 1.28.0, < 2.0)
53
- ruby-progressbar (~> 1.7)
54
- unicode-display_width (>= 2.4.0, < 3.0)
55
- rubocop-ast (1.28.1)
56
- parser (>= 3.2.1.0)
57
- rubocop-capybara (2.18.0)
58
- rubocop (~> 1.41)
59
- rubocop-factory_bot (2.23.1)
60
- rubocop (~> 1.33)
61
- rubocop-rspec (2.22.0)
62
- rubocop (~> 1.33)
63
- rubocop-capybara (~> 2.17)
64
- rubocop-factory_bot (~> 2.22)
65
- ruby-progressbar (1.13.0)
66
- thor (1.2.2)
67
- unicode-display_width (2.4.2)
68
-
69
- PLATFORMS
70
- x86_64-linux
71
-
72
- DEPENDENCIES
73
- amazing_print!
74
- appraisal (~> 2.3)
75
- fakefs (~> 1.2)
76
- nokogiri (~> 1.10)
77
- pry
78
- rspec (~> 3.9)
79
- rubocop (~> 1.20)
80
- rubocop-rspec (~> 2.4)
81
-
82
- BUNDLED WITH
83
- 2.3.12
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2010-2019 Michael Dvorkin
4
- Copyright (c) 2020 AmazingPrint
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
data/Rakefile DELETED
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rubygems'
4
- require 'bundler/setup'
5
-
6
- require 'bundler'
7
- Bundler::GemHelper.install_tasks
8
-
9
- task :default do
10
- if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
11
- Rake::Task['spec'].invoke
12
- else
13
- Rake::Task['appraise'].invoke
14
- end
15
- end
16
-
17
- task :appraise do
18
- exec 'appraisal install && appraisal rake'
19
- end
20
-
21
- desc 'Run all amazing_print gem specs'
22
- task :spec do
23
- # Run plain rspec command without RSpec::Core::RakeTask overrides.
24
- exec 'rspec -c spec'
25
- end
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if ExtVerifier.has_rails?
4
- # Required to use the column support
5
- module Rails
6
- def self.env
7
- {}
8
- end
9
- end
10
-
11
- # Establish connection to in-memory SQLite DB
12
- ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
13
-
14
- # Create the users table
15
- ActiveRecord::Migration.verbose = false
16
- ActiveRecord::Migration.create_table :users do |t|
17
- t.string :name
18
- t.integer :rank
19
- t.boolean :admin
20
- t.datetime :created_at
21
- end
22
-
23
- ActiveRecord::Migration.create_table :emails do |t|
24
- t.references :user
25
- t.string :email_address
26
- end
27
-
28
- # Create models
29
- class User < ActiveRecord::Base; has_many :emails; end
30
-
31
- class SubUser < User; end
32
-
33
- class Email < ActiveRecord::Base; belongs_to :user; end
34
-
35
- class TableFreeModel
36
- include ::ActiveModel::Validations
37
- attr_reader(:name)
38
-
39
- def attributes
40
- { 'name' => name }
41
- end
42
- end
43
- end
data/spec/colors_spec.rb DELETED
@@ -1,120 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # rubocop:disable Lint/ConstantDefinitionInBlock, Style/OptionalBooleanParameter
4
-
5
- require 'spec_helper'
6
-
7
- RSpec.describe 'AmazingPrint' do
8
- def stub_tty!(output = true, stream = $stdout)
9
- if output
10
- stream.instance_eval do
11
- def tty?
12
- true
13
- end
14
- end
15
- else
16
- stream.instance_eval do
17
- def tty?
18
- false
19
- end
20
- end
21
- end
22
- end
23
-
24
- describe 'colorization' do
25
- PLAIN = '[ 1, :two, "three", [ nil, [ true, false ] ] ]'
26
- 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 ] ] ]"
27
-
28
- before do
29
- ENV['TERM'] = 'xterm-colors'
30
- ENV.delete('ANSICON')
31
- @arr = [1, :two, 'three', [nil, [true, false]]]
32
- end
33
-
34
- describe 'default settings (no forced colors)' do
35
- before do
36
- AmazingPrint.force_colors! colors: false
37
- end
38
-
39
- it 'colorizes tty processes by default' do
40
- stub_tty!
41
- expect(@arr.ai(multiline: false)).to eq(COLORIZED)
42
- end
43
-
44
- it "colorizes processes with ENV['ANSICON'] by default" do
45
- stub_tty!
46
- term = ENV['ANSICON']
47
- ENV['ANSICON'] = '1'
48
- expect(@arr.ai(multiline: false)).to eq(COLORIZED)
49
- ensure
50
- ENV['ANSICON'] = term
51
- end
52
-
53
- it 'does not colorize tty processes running in dumb terminals by default' do
54
- stub_tty!
55
- term = ENV['TERM']
56
- ENV['TERM'] = 'dumb'
57
- expect(@arr.ai(multiline: false)).to eq(PLAIN)
58
- ensure
59
- ENV['TERM'] = term
60
- end
61
-
62
- it 'does not colorize subprocesses by default' do
63
- stub_tty! false
64
- expect(@arr.ai(multiline: false)).to eq(PLAIN)
65
- ensure
66
- stub_tty!
67
- end
68
- end
69
-
70
- describe 'forced colors override' do
71
- before do
72
- AmazingPrint.force_colors!
73
- end
74
-
75
- it 'still colorizes tty processes' do
76
- stub_tty!
77
- expect(@arr.ai(multiline: false)).to eq(COLORIZED)
78
- end
79
-
80
- it "colorizes processes with ENV['ANSICON'] set to 0" do
81
- stub_tty!
82
- term = ENV['ANSICON']
83
- ENV['ANSICON'] = '1'
84
- expect(@arr.ai(multiline: false)).to eq(COLORIZED)
85
- ensure
86
- ENV['ANSICON'] = term
87
- end
88
-
89
- it 'colorizes dumb terminals' do
90
- stub_tty!
91
- term = ENV['TERM']
92
- ENV['TERM'] = 'dumb'
93
- expect(@arr.ai(multiline: false)).to eq(COLORIZED)
94
- ensure
95
- ENV['TERM'] = term
96
- end
97
-
98
- it 'colorizes subprocess' do
99
- stub_tty! false
100
- expect(@arr.ai(multiline: false)).to eq(COLORIZED)
101
- ensure
102
- stub_tty!
103
- end
104
- end
105
- end
106
-
107
- describe 'AmazingPrint::Colors' do
108
- %i[gray red green yellow blue purple cyan white].each_with_index do |color, i|
109
- it "has #{color} color" do
110
- expect(AmazingPrint::Colors.public_send(color, color.to_s)).to eq("\e[1;#{i + 30}m#{color}\e[0m")
111
- end
112
-
113
- it "has #{color}ish color" do
114
- expect(AmazingPrint::Colors.public_send(:"#{color}ish", color.to_s)).to eq("\e[0;#{i + 30}m#{color}\e[0m")
115
- end
116
- end
117
- end
118
- end
119
-
120
- # rubocop:enable Lint/ConstantDefinitionInBlock, Style/OptionalBooleanParameter
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- require 'logger'
6
- require 'amazing_print/core_ext/logger'
7
-
8
- RSpec.describe 'AmazingPrint logging extensions' do
9
- subject(:logger) do
10
- Logger.new('/dev/null')
11
- rescue Errno::ENOENT
12
- Logger.new('nul')
13
- end
14
-
15
- let(:object) { double }
16
- let(:options) { { sort_keys: true } }
17
-
18
- describe 'ap method' do
19
- it 'awesome_inspects the given object' do
20
- expect(object).to receive(:ai)
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
27
- end
28
-
29
- describe 'the log level' do
30
- before do
31
- AmazingPrint.defaults = {}
32
- end
33
-
34
- it 'fallbacks to the default :debug log level' do
35
- expect(logger).to receive(:debug)
36
- logger.ap nil
37
- end
38
-
39
- it 'uses the global user default if no level passed' do
40
- AmazingPrint.defaults = { log_level: :info }
41
- expect(logger).to receive(:info)
42
- logger.ap nil
43
- end
44
-
45
- it 'uses the passed in level' do
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
67
- end
68
- end
69
- end
70
- end
@@ -1,40 +0,0 @@
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 'formats 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 'formats as a hash' do
37
- expect(inspector.send(:awesome, parameters.permit!)).to eq expected_output
38
- end
39
- end
40
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe 'AmazingPrint ActionView extensions',
6
- skip: -> { !ExtVerifier.has_rails? || ActiveRecord::VERSION::STRING >= '6.1' }.call do
7
- before do
8
- @view = ActionView::Base.new
9
- end
10
-
11
- it "uses HTML and adds 'debug_dump' class to plain <pre> tag" do
12
- markup = rand
13
- expect(@view.ap(markup, plain: true)).to eq(%(<pre class="debug_dump">#{markup}</pre>))
14
- end
15
-
16
- it "uses HTML and adds 'debug_dump' class to colorized <pre> tag" do
17
- markup = ' &<hello>'
18
- expect(@view.ap(markup)).to eq('<pre class="debug_dump"><kbd style="color:brown">&quot; &amp;&lt;hello&gt;&quot;</kbd></pre>')
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
24
- end
@@ -1,37 +0,0 @@
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 'formats 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