amazing_print 1.3.0 → 1.5.0

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +0 -6
  3. data/CHANGELOG.md +24 -0
  4. data/Gemfile +9 -0
  5. data/Gemfile.lock +51 -47
  6. data/README.md +9 -7
  7. data/lib/amazing_print/colorize.rb +5 -14
  8. data/lib/amazing_print/colors.rb +37 -0
  9. data/lib/amazing_print/core_ext/awesome_method_array.rb +4 -4
  10. data/lib/amazing_print/core_ext/class.rb +1 -1
  11. data/lib/amazing_print/core_ext/logger.rb +1 -3
  12. data/lib/amazing_print/core_ext/object.rb +1 -1
  13. data/lib/amazing_print/custom_defaults.rb +10 -3
  14. data/lib/amazing_print/ext/active_record.rb +5 -9
  15. data/lib/amazing_print/ext/active_support.rb +1 -3
  16. data/lib/amazing_print/ext/mongo_mapper.rb +4 -7
  17. data/lib/amazing_print/ext/mongoid.rb +2 -6
  18. data/lib/amazing_print/ext/nobrainer.rb +3 -5
  19. data/lib/amazing_print/ext/nokogiri.rb +1 -3
  20. data/lib/amazing_print/ext/ostruct.rb +1 -3
  21. data/lib/amazing_print/ext/ripple.rb +4 -5
  22. data/lib/amazing_print/formatter.rb +5 -6
  23. data/lib/amazing_print/formatters/array_formatter.rb +7 -6
  24. data/lib/amazing_print/formatters/base_formatter.rb +20 -25
  25. data/lib/amazing_print/formatters/class_formatter.rb +1 -0
  26. data/lib/amazing_print/formatters/dir_formatter.rb +11 -1
  27. data/lib/amazing_print/formatters/file_formatter.rb +11 -1
  28. data/lib/amazing_print/formatters/hash_formatter.rb +5 -3
  29. data/lib/amazing_print/formatters/method_formatter.rb +1 -0
  30. data/lib/amazing_print/formatters/mswin_helper.rb +63 -0
  31. data/lib/amazing_print/formatters/object_formatter.rb +2 -1
  32. data/lib/amazing_print/formatters/simple_formatter.rb +1 -0
  33. data/lib/amazing_print/formatters/struct_formatter.rb +2 -1
  34. data/lib/amazing_print/inspector.rb +29 -5
  35. data/lib/amazing_print/version.rb +1 -1
  36. data/lib/amazing_print.rb +3 -7
  37. data/spec/active_record_helper.rb +3 -0
  38. data/spec/colors_spec.rb +15 -6
  39. data/spec/core_ext/logger_spec.rb +7 -7
  40. data/spec/ext/action_controller_spec.rb +5 -5
  41. data/spec/ext/active_model_spec.rb +1 -1
  42. data/spec/ext/active_record_spec.rb +39 -73
  43. data/spec/ext/active_support_spec.rb +3 -3
  44. data/spec/ext/mongo_mapper_spec.rb +15 -11
  45. data/spec/ext/mongoid_spec.rb +7 -3
  46. data/spec/ext/nobrainer_spec.rb +6 -2
  47. data/spec/ext/nokogiri_spec.rb +7 -7
  48. data/spec/ext/ripple_spec.rb +6 -2
  49. data/spec/ext/sequel_spec.rb +1 -1
  50. data/spec/formats_spec.rb +101 -90
  51. data/spec/methods_spec.rb +12 -4
  52. data/spec/misc_spec.rb +29 -70
  53. data/spec/objects_spec.rb +4 -0
  54. data/spec/spec_helper.rb +11 -9
  55. metadata +10 -142
  56. data/lib/amazing_print/core_ext/string.rb +0 -45
  57. data/spec/core_ext/string_spec.rb +0 -15
@@ -30,7 +30,7 @@ module AmazingPrint
30
30
  # ]
31
31
  #------------------------------------------------------------------------------
32
32
  def should_be_limited?
33
- options[:limit] || (options[:limit].is_a?(Integer) && (options[:limit] > 0))
33
+ options[:limit] || (options[:limit].is_a?(Integer) && options[:limit].positive?)
34
34
  end
35
35
 
36
36
  def get_limit_size
@@ -42,14 +42,14 @@ module AmazingPrint
42
42
  end
43
43
  end
44
44
 
45
- def limited(data, width, is_hash = false)
45
+ def limited(data, width, is_hash: false)
46
46
  limit = get_limit_size
47
47
  if data.length <= limit
48
48
  data
49
49
  else
50
50
  # Calculate how many elements to be displayed above and below the separator.
51
51
  head = limit / 2
52
- tail = head - (limit - 1) % 2
52
+ tail = head - ((limit - 1) % 2)
53
53
 
54
54
  # Add the proper elements to the temp array and format the separator.
55
55
  temp = data[0, head] + [nil] + data[-tail, tail]
@@ -65,23 +65,18 @@ module AmazingPrint
65
65
  end
66
66
 
67
67
  def method_tuple(method)
68
- if method.respond_to?(:parameters) # Ruby 1.9.2+
69
- # See http://readruby.chengguangnan.com/methods#method-objects-parameters
70
- # (mirror: http://archive.is/XguCA#selection-3381.1-3381.11)
71
- args = method.parameters.inject([]) do |arr, (type, name)|
72
- name ||= (type == :block ? 'block' : "arg#{arr.size + 1}")
73
- arr << case type
74
- when :req then name.to_s
75
- when :keyreq then "#{name}:"
76
- when :key then "*#{name}:"
77
- when :opt, :rest then "*#{name}"
78
- when :block then "&#{name}"
79
- else '?'
80
- end
81
- end
82
- else # See http://ruby-doc.org/core/classes/Method.html#M001902
83
- args = (1..method.arity.abs).map { |i| "arg#{i}" }
84
- args[-1] = "*#{args[-1]}" if method.arity < 0
68
+ # See http://readruby.chengguangnan.com/methods#method-objects-parameters
69
+ # (mirror: http://archive.is/XguCA#selection-3381.1-3381.11)
70
+ args = method.parameters.inject([]) do |arr, (type, name)|
71
+ name ||= (type == :block ? 'block' : "arg#{arr.size + 1}")
72
+ arr << case type
73
+ when :req then name.to_s
74
+ when :keyreq then "#{name}:"
75
+ when :key then "*#{name}:"
76
+ when :opt, :rest then "*#{name}"
77
+ when :block then "&#{name}"
78
+ else '?'
79
+ end
85
80
  end
86
81
 
87
82
  # method.to_s formats to handle:
@@ -95,7 +90,7 @@ module AmazingPrint
95
90
  # #<UnboundMethod: Hello#world>
96
91
  # #<UnboundMethod: Hello#world() /home/hs/code/amazing_print/spec/methods_spec.rb:68>
97
92
  #
98
- if method.to_s =~ %r{(Unbound)*Method: ((#<)?[^/#]*)[#\.]}
93
+ if method.to_s =~ %r{(Unbound)*Method: ((#<)?[^/#]*)[#.]}
99
94
  unbound = Regexp.last_match(1) && '(unbound)'
100
95
  klass = Regexp.last_match(2)
101
96
  if klass && klass =~ /(\(\w+:\s.*?\))/ # Is this ActiveRecord-style class?
@@ -123,21 +118,21 @@ module AmazingPrint
123
118
  INDENT_CACHE = (0..100).map { |i| ' ' * i }.map(&:freeze).freeze
124
119
 
125
120
  def indent(n = indentation)
126
- INDENT_CACHE[n] || ' ' * n
121
+ INDENT_CACHE[n] || (' ' * n)
127
122
  end
128
123
 
129
124
  def outdent
130
125
  i = indentation - options[:indent].abs
131
126
 
132
- INDENT_CACHE[i] || ' ' * i
127
+ INDENT_CACHE[i] || (' ' * i)
133
128
  end
134
129
 
135
130
  def align(value, width)
136
131
  if options[:multiline]
137
132
  indent_option = options[:indent]
138
- if indent_option > 0
133
+ if indent_option.positive?
139
134
  value.rjust(width)
140
- elsif indent_option == 0
135
+ elsif indent_option.zero?
141
136
  "#{indent}#{value.ljust(width)}"
142
137
  else
143
138
  "#{indent(indentation + indent_option)}#{value.ljust(width)}"
@@ -8,6 +8,7 @@ module AmazingPrint
8
8
  attr_reader :klass, :inspector, :options
9
9
 
10
10
  def initialize(klass, inspector)
11
+ super()
11
12
  @klass = klass
12
13
  @inspector = inspector
13
14
  @options = inspector.options
@@ -3,6 +3,7 @@
3
3
  require 'shellwords'
4
4
 
5
5
  require_relative 'base_formatter'
6
+ require_relative 'mswin_helper' if RUBY_PLATFORM.include?('mswin')
6
7
 
7
8
  module AmazingPrint
8
9
  module Formatters
@@ -10,15 +11,24 @@ module AmazingPrint
10
11
  attr_reader :dir, :inspector, :options
11
12
 
12
13
  def initialize(dir, inspector)
14
+ super()
13
15
  @dir = dir
14
16
  @inspector = inspector
15
17
  @options = inspector.options
16
18
  end
17
19
 
18
20
  def format
19
- ls = `ls -alF #{dir.path.shellescape}`
21
+ ls = info
20
22
  colorize(ls.empty? ? dir.inspect : "#{dir.inspect}\n#{ls.chop}", :dir)
21
23
  end
24
+
25
+ def info
26
+ if RUBY_PLATFORM.include?('mswin')
27
+ "#{GetChildItem.new(@dir.path)}\n"
28
+ else
29
+ `ls -alF #{dir.path.shellescape}`
30
+ end
31
+ end
22
32
  end
23
33
  end
24
34
  end
@@ -3,6 +3,7 @@
3
3
  require 'shellwords'
4
4
 
5
5
  require_relative 'base_formatter'
6
+ require_relative 'mswin_helper' if RUBY_PLATFORM.include?('mswin')
6
7
 
7
8
  module AmazingPrint
8
9
  module Formatters
@@ -10,15 +11,24 @@ module AmazingPrint
10
11
  attr_reader :file, :inspector, :options
11
12
 
12
13
  def initialize(file, inspector)
14
+ super()
13
15
  @file = file
14
16
  @inspector = inspector
15
17
  @options = inspector.options
16
18
  end
17
19
 
18
20
  def format
19
- ls = File.directory?(file) ? `ls -adlF #{file.path.shellescape}` : `ls -alF #{file.path.shellescape}`
21
+ ls = info
20
22
  colorize(ls.empty? ? file.inspect : "#{file.inspect}\n#{ls.chop}", :file)
21
23
  end
24
+
25
+ def info
26
+ if RUBY_PLATFORM.include?('mswin')
27
+ "#{GetChildItem.new(@file.path)}\n"
28
+ else
29
+ File.directory?(file) ? `ls -adlF #{file.path.shellescape}` : `ls -alF #{file.path.shellescape}`
30
+ end
31
+ end
22
32
  end
23
33
  end
24
34
  end
@@ -8,6 +8,7 @@ module AmazingPrint
8
8
  attr_reader :hash, :inspector, :options
9
9
 
10
10
  def initialize(hash, inspector)
11
+ super()
11
12
  @hash = hash
12
13
  @inspector = inspector
13
14
  @options = inspector.options
@@ -55,12 +56,12 @@ module AmazingPrint
55
56
  end
56
57
  end
57
58
 
58
- should_be_limited? ? limited(data, width, hash: true) : data
59
+ should_be_limited? ? limited(data, width, is_hash: true) : data
59
60
  end
60
61
 
61
62
  def left_width(keys)
62
63
  result = max_key_width(keys)
63
- result += indentation if options[:indent] > 0
64
+ result += indentation if options[:indent].positive?
64
65
  result
65
66
  end
66
67
 
@@ -86,7 +87,8 @@ module AmazingPrint
86
87
 
87
88
  def ruby19_syntax(key, value, width)
88
89
  key[0] = ''
89
- "#{align(key, width - 1)}#{colorize(': ', :hash)}#{inspector.awesome(value)}"
90
+ key << ':'
91
+ "#{align(key, width)} #{inspector.awesome(value)}"
90
92
  end
91
93
 
92
94
  def pre_ruby19_syntax(key, value, width)
@@ -8,6 +8,7 @@ module AmazingPrint
8
8
  attr_reader :method, :inspector, :options
9
9
 
10
10
  def initialize(method, inspector)
11
+ super()
11
12
  @method = method
12
13
  @inspector = inspector
13
14
  @options = inspector.options
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fiddle'
4
+ require 'fiddle/import'
5
+
6
+ module AmazingPrint
7
+ module Formatters
8
+ module Kernel32
9
+ extend Fiddle::Importer
10
+ dlload 'kernel32'
11
+ extern 'unsigned long GetFileAttributesA(const char*)'
12
+ end
13
+
14
+ class GetChildItem
15
+ def initialize(fname)
16
+ @fname = fname
17
+ @stat = File.send(File.symlink?(@fname) ? :lstat : :stat, @fname)
18
+ @attrs = Kernel32::GetFileAttributesA @fname
19
+ end
20
+
21
+ # docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants
22
+ FILE_ATTRIBUTE_ARCHIVE = 0x20
23
+ FILE_ATTRIBUTE_READONLY = 0x1
24
+ FILE_ATTRIBUTE_HIDDEN = 0x2
25
+ FILE_ATTRIBUTE_SYSTEM = 0x4
26
+
27
+ def mode
28
+ r = ['-'] * 6
29
+ r[0] = 'd' if @stat.directory?
30
+ r[1] = 'a' unless (@attrs & FILE_ATTRIBUTE_ARCHIVE).zero?
31
+ r[2] = 'r' unless (@attrs & FILE_ATTRIBUTE_READONLY).zero?
32
+ r[3] = 'h' unless (@attrs & FILE_ATTRIBUTE_HIDDEN).zero?
33
+ r[4] = 's' unless (@attrs & FILE_ATTRIBUTE_SYSTEM).zero?
34
+ r[5] = 'l' if File.symlink? @fname
35
+ r.join
36
+ end
37
+
38
+ def last_write_time
39
+ @stat.mtime.strftime '%Y-%m-%d %H:%M'
40
+ end
41
+
42
+ def length
43
+ @stat.file? ? @stat.size.to_s : ''
44
+ end
45
+
46
+ def name
47
+ @fname
48
+ end
49
+
50
+ def to_s
51
+ format '%-12<Mode>s %<LastWriteTime>s %14<Length>s %<Name>s',
52
+ {
53
+ Mode: mode,
54
+ LastWriteTime: last_write_time,
55
+ Length: length,
56
+ Name: name
57
+ }
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ puts AmazingPrint::Formatters::GetChildItem.new ARGV[0] if __FILE__ == $PROGRAM_NAME
@@ -8,6 +8,7 @@ module AmazingPrint
8
8
  attr_reader :object, :variables, :inspector, :options
9
9
 
10
10
  def initialize(object, inspector)
11
+ super()
11
12
  @object = object
12
13
  @variables = object.instance_variables
13
14
  @inspector = inspector
@@ -38,7 +39,7 @@ module AmazingPrint
38
39
  key = if key =~ /(@\w+)/
39
40
  key.sub(Regexp.last_match(1), colorize(Regexp.last_match(1), :variable))
40
41
  else
41
- key.sub(/(attr_\w+)\s(\:\w+)/, "#{colorize('\\1', :keyword)} #{colorize('\\2', :method)}")
42
+ key.sub(/(attr_\w+)\s(:\w+)/, "#{colorize('\\1', :keyword)} #{colorize('\\2', :method)}")
42
43
  end
43
44
  end
44
45
 
@@ -8,6 +8,7 @@ module AmazingPrint
8
8
  attr_reader :string, :type, :inspector, :options
9
9
 
10
10
  def initialize(string, type, inspector)
11
+ super()
11
12
  @string = string
12
13
  @type = type
13
14
  @inspector = inspector
@@ -8,6 +8,7 @@ module AmazingPrint
8
8
  attr_reader :struct, :variables, :inspector, :options
9
9
 
10
10
  def initialize(struct, inspector)
11
+ super()
11
12
  @struct = struct
12
13
  @variables = struct.members
13
14
  @inspector = inspector
@@ -38,7 +39,7 @@ module AmazingPrint
38
39
  key = if key =~ /(@\w+)/
39
40
  key.sub(Regexp.last_match(1), colorize(Regexp.last_match(1), :variable))
40
41
  else
41
- key.sub(/(attr_\w+)\s(\:\w+)/, "#{colorize('\\1', :keyword)} #{colorize('\\2', :method)}")
42
+ key.sub(/(attr_\w+)\s(:\w+)/, "#{colorize('\\1', :keyword)} #{colorize('\\2', :method)}")
42
43
  end
43
44
  end
44
45
 
@@ -5,6 +5,9 @@
5
5
  # AmazingPrint is freely distributable under the terms of MIT license.
6
6
  # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
7
  #------------------------------------------------------------------------------
8
+
9
+ # rubocop:disable Metrics/ClassLength
10
+
8
11
  require_relative 'indentator'
9
12
 
10
13
  module AmazingPrint
@@ -13,6 +16,15 @@ module AmazingPrint
13
16
 
14
17
  AP = :__amazing_print__
15
18
 
19
+ ##
20
+ # Unload the cached dotfile and load it again.
21
+ #
22
+ def self.reload_dotfile
23
+ @@dotfile = nil
24
+ new.send :load_dotfile
25
+ true
26
+ end
27
+
16
28
  def initialize(options = {})
17
29
  @options = {
18
30
  indent: 4, # Number of spaces for indenting.
@@ -91,7 +103,7 @@ module AmazingPrint
91
103
  if defined? @colorize_stdout
92
104
  @colorize_stdout
93
105
  else
94
- @colorize_stdout = STDOUT.tty? && (
106
+ @colorize_stdout = $stdout.tty? && (
95
107
  (
96
108
  ENV['TERM'] &&
97
109
  ENV['TERM'] != 'dumb'
@@ -147,18 +159,28 @@ module AmazingPrint
147
159
  @options.merge!(options)
148
160
  end
149
161
 
162
+ def find_dotfile
163
+ xdg_config_home = File.expand_path(ENV.fetch('XDG_CONFIG_HOME', '~/.config'))
164
+ xdg_config_path = File.join(xdg_config_home, 'aprc') # ${XDG_CONFIG_HOME}/aprc
165
+
166
+ return xdg_config_path if File.exist?(xdg_config_path)
167
+
168
+ # default to ~/.aprc
169
+ File.join(Dir.home, '.aprc')
170
+ end
171
+
150
172
  # This method needs to be mocked during testing so that it always loads
151
173
  # predictable values
152
174
  #---------------------------------------------------------------------------
153
175
  def load_dotfile
154
- dotfile = File.join(ENV['HOME'], '.aprc')
176
+ return if @@dotfile # Load the dotfile only once.
177
+
178
+ dotfile = find_dotfile
155
179
  load dotfile if dotfile_readable?(dotfile)
156
180
  end
157
181
 
158
182
  def dotfile_readable?(dotfile)
159
- if @@dotfile_readable.nil? || @@dotfile != dotfile
160
- @@dotfile_readable = File.readable?(@@dotfile = dotfile)
161
- end
183
+ @@dotfile_readable = File.readable?(@@dotfile = dotfile) if @@dotfile_readable.nil? || @@dotfile != dotfile
162
184
  @@dotfile_readable
163
185
  end
164
186
  @@dotfile_readable = @@dotfile = nil
@@ -173,3 +195,5 @@ module AmazingPrint
173
195
  end
174
196
  end
175
197
  end
198
+
199
+ # rubocop:enable Metrics/ClassLength
@@ -7,6 +7,6 @@
7
7
  #------------------------------------------------------------------------------
8
8
  module AmazingPrint
9
9
  def self.version
10
- '1.3.0'
10
+ '1.5.0'
11
11
  end
12
12
  end
data/lib/amazing_print.rb CHANGED
@@ -10,7 +10,7 @@
10
10
  # so do nothing for subsequent requires.
11
11
  #
12
12
  unless defined?(AmazingPrint::Inspector)
13
- %w[awesome_method_array string object class kernel].each do |file|
13
+ %w[awesome_method_array object class kernel].each do |file|
14
14
  require_relative "amazing_print/core_ext/#{file}"
15
15
  end
16
16
 
@@ -23,12 +23,8 @@ unless defined?(AmazingPrint::Inspector)
23
23
  # Load the following under normal circumstances as well as in Rails
24
24
  # console when required from ~/.irbrc or ~/.pryrc.
25
25
  #
26
- if defined?(ActiveRecord) || AmazingPrint.rails_console?
27
- require_relative 'amazing_print/ext/active_record'
28
- end
29
- if defined?(ActiveSupport) || AmazingPrint.rails_console?
30
- require_relative 'amazing_print/ext/active_support'
31
- end
26
+ require_relative 'amazing_print/ext/active_record' if defined?(ActiveRecord) || AmazingPrint.rails_console?
27
+ require_relative 'amazing_print/ext/active_support' if defined?(ActiveSupport) || AmazingPrint.rails_console?
32
28
  #
33
29
  # Load remaining extensions.
34
30
  #
@@ -27,8 +27,11 @@ if ExtVerifier.has_rails?
27
27
 
28
28
  # Create models
29
29
  class User < ActiveRecord::Base; has_many :emails; end
30
+
30
31
  class SubUser < User; end
32
+
31
33
  class Email < ActiveRecord::Base; belongs_to :user; end
34
+
32
35
  class TableFreeModel
33
36
  include ::ActiveModel::Validations
34
37
  attr_reader(:name)
data/spec/colors_spec.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Lint/ConstantDefinitionInBlock, Style/OptionalBooleanParameter
4
+
3
5
  require 'spec_helper'
4
6
 
5
7
  RSpec.describe 'AmazingPrint' do
6
- def stub_tty!(output = true, stream = STDOUT)
8
+ def stub_tty!(output = true, stream = $stdout)
7
9
  if output
8
10
  stream.instance_eval do
9
11
  def tty?
@@ -31,7 +33,7 @@ RSpec.describe 'AmazingPrint' do
31
33
 
32
34
  describe 'default settings (no forced colors)' do
33
35
  before do
34
- AmazingPrint.force_colors! false
36
+ AmazingPrint.force_colors! colors: false
35
37
  end
36
38
 
37
39
  it 'colorizes tty processes by default' do
@@ -100,12 +102,19 @@ RSpec.describe 'AmazingPrint' do
100
102
  stub_tty!
101
103
  end
102
104
  end
105
+ end
103
106
 
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'
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")
108
115
  end
109
116
  end
110
117
  end
111
118
  end
119
+
120
+ # rubocop:enable Lint/ConstantDefinitionInBlock, Style/OptionalBooleanParameter
@@ -6,17 +6,17 @@ require 'logger'
6
6
  require 'amazing_print/core_ext/logger'
7
7
 
8
8
  RSpec.describe 'AmazingPrint logging extensions' do
9
- let(:object) { double }
10
- let(:options) { { sort_keys: true } }
11
-
12
9
  subject(:logger) do
13
10
  Logger.new('/dev/null')
14
11
  rescue Errno::ENOENT
15
12
  Logger.new('nul')
16
13
  end
17
14
 
15
+ let(:object) { double }
16
+ let(:options) { { sort_keys: true } }
17
+
18
18
  describe 'ap method' do
19
- it 'should awesome_inspect the given object' do
19
+ it 'awesome_inspects the given object' do
20
20
  expect(object).to receive(:ai)
21
21
  logger.ap object
22
22
  end
@@ -31,18 +31,18 @@ RSpec.describe 'AmazingPrint logging extensions' do
31
31
  AmazingPrint.defaults = {}
32
32
  end
33
33
 
34
- it 'should fallback to the default :debug log level' do
34
+ it 'fallbacks to the default :debug log level' do
35
35
  expect(logger).to receive(:debug)
36
36
  logger.ap nil
37
37
  end
38
38
 
39
- it 'should use the global user default if no level passed' do
39
+ it 'uses the global user default if no level passed' do
40
40
  AmazingPrint.defaults = { log_level: :info }
41
41
  expect(logger).to receive(:info)
42
42
  logger.ap nil
43
43
  end
44
44
 
45
- it 'should use the passed in level' do
45
+ it 'uses the passed in level' do
46
46
  expect(logger).to receive(:warn)
47
47
  logger.ap nil, :warn
48
48
  end
@@ -10,7 +10,7 @@ RSpec.describe 'AmazingPrint::ActionController', skip: -> { !ExtVerifier.has_rai
10
10
  ActionController::Parameters.new post: { id: 1, content: 'Some' }
11
11
  end
12
12
 
13
- it 'should format as an object' do
13
+ it 'formats as an object' do
14
14
  expect(inspector.send(:awesome, parameters)).to match(
15
15
  /\A#?<ActionController::Parameters {"post"=>{"id"=>1, "content"=>"Some"}} permitted: false>\z/
16
16
  )
@@ -21,9 +21,9 @@ RSpec.describe 'AmazingPrint::ActionController', skip: -> { !ExtVerifier.has_rai
21
21
  let(:expected_output) do
22
22
  <<~OUTPUT
23
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
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
27
  }
28
28
  }
29
29
  OUTPUT
@@ -33,7 +33,7 @@ RSpec.describe 'AmazingPrint::ActionController', skip: -> { !ExtVerifier.has_rai
33
33
  ActionController::Parameters.new post: { id: 1, content: 'Some' }
34
34
  end
35
35
 
36
- it 'should format as a hash' do
36
+ it 'formats as a hash' do
37
37
  expect(inspector.send(:awesome, parameters.permit!)).to eq expected_output
38
38
  end
39
39
  end
@@ -8,7 +8,7 @@ RSpec.describe 'ActiveModel::Errors formatting', skip: -> { !ExtVerifier.has_rai
8
8
  @ap = AmazingPrint::Inspector.new(plain: true)
9
9
  end
10
10
 
11
- it 'should format active_model_errors properly' do
11
+ it 'formats active_model_errors properly' do
12
12
  model = TableFreeModel.new
13
13
  model.errors.add(:name, "can't be blank")
14
14