awesome_print 1.6.1 → 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +4 -0
  3. data/Appraisals +45 -22
  4. data/{CHANGELOG → CHANGELOG.md} +83 -18
  5. data/CONTRIBUTING.md +45 -4
  6. data/Gemfile.lock +28 -22
  7. data/LICENSE +16 -19
  8. data/README.md +97 -92
  9. data/Rakefile +5 -5
  10. data/awesome_print.gemspec +33 -0
  11. data/init.rb +1 -0
  12. data/lib/ap.rb +2 -2
  13. data/lib/awesome_print/colorize.rb +24 -0
  14. data/lib/awesome_print/core_ext/{array.rb → awesome_method_array.rb} +16 -18
  15. data/lib/awesome_print/core_ext/class.rb +3 -2
  16. data/lib/awesome_print/core_ext/kernel.rb +1 -1
  17. data/lib/awesome_print/core_ext/logger.rb +1 -1
  18. data/lib/awesome_print/core_ext/method.rb +2 -2
  19. data/lib/awesome_print/core_ext/object.rb +3 -2
  20. data/lib/awesome_print/core_ext/string.rb +3 -3
  21. data/lib/awesome_print/custom_defaults.rb +57 -0
  22. data/lib/awesome_print/ext/action_view.rb +8 -4
  23. data/lib/awesome_print/ext/active_record.rb +45 -12
  24. data/lib/awesome_print/ext/active_support.rb +1 -1
  25. data/lib/awesome_print/ext/mongo_mapper.rb +16 -13
  26. data/lib/awesome_print/ext/mongoid.rb +8 -6
  27. data/lib/awesome_print/ext/nobrainer.rb +52 -0
  28. data/lib/awesome_print/ext/nokogiri.rb +4 -4
  29. data/lib/awesome_print/ext/ostruct.rb +1 -1
  30. data/lib/awesome_print/ext/ripple.rb +5 -6
  31. data/lib/awesome_print/ext/sequel.rb +7 -6
  32. data/lib/awesome_print/formatter.rb +54 -327
  33. data/lib/awesome_print/formatters/array_formatter.rb +139 -0
  34. data/lib/awesome_print/formatters/base_formatter.rb +140 -0
  35. data/lib/awesome_print/formatters/class_formatter.rb +25 -0
  36. data/lib/awesome_print/formatters/dir_formatter.rb +22 -0
  37. data/lib/awesome_print/formatters/file_formatter.rb +22 -0
  38. data/lib/awesome_print/formatters/hash_formatter.rb +106 -0
  39. data/lib/awesome_print/formatters/method_formatter.rb +22 -0
  40. data/lib/awesome_print/formatters/object_formatter.rb +78 -0
  41. data/lib/awesome_print/formatters/simple_formatter.rb +21 -0
  42. data/lib/awesome_print/formatters/struct_formatter.rb +71 -0
  43. data/lib/awesome_print/formatters.rb +15 -0
  44. data/lib/awesome_print/indentator.rb +18 -0
  45. data/lib/awesome_print/inspector.rb +92 -94
  46. data/lib/awesome_print/version.rb +2 -2
  47. data/lib/awesome_print.rb +19 -18
  48. data/spec/active_record_helper.rb +24 -28
  49. data/spec/colors_spec.rb +31 -31
  50. data/spec/core_ext/logger_spec.rb +43 -0
  51. data/spec/core_ext/string_spec.rb +20 -0
  52. data/spec/ext/action_view_spec.rb +21 -0
  53. data/spec/ext/active_record_spec.rb +260 -0
  54. data/spec/ext/active_support_spec.rb +30 -0
  55. data/spec/ext/mongo_mapper_spec.rb +261 -0
  56. data/spec/ext/mongoid_spec.rb +67 -0
  57. data/spec/ext/nobrainer_spec.rb +59 -0
  58. data/spec/ext/nokogiri_spec.rb +46 -0
  59. data/spec/ext/ostruct_spec.rb +22 -0
  60. data/spec/ext/ripple_spec.rb +48 -0
  61. data/spec/formats_spec.rb +251 -184
  62. data/spec/methods_spec.rb +126 -130
  63. data/spec/misc_spec.rb +98 -93
  64. data/spec/objects_spec.rb +162 -27
  65. data/spec/spec_helper.rb +72 -38
  66. data/spec/support/active_record_data/3_2_diana.txt +24 -0
  67. data/spec/support/active_record_data/3_2_diana_legacy.txt +24 -0
  68. data/spec/support/active_record_data/3_2_multi.txt +50 -0
  69. data/spec/support/active_record_data/3_2_multi_legacy.txt +50 -0
  70. data/spec/support/active_record_data/4_0_diana.txt +98 -0
  71. data/spec/support/active_record_data/4_0_multi.txt +198 -0
  72. data/spec/support/active_record_data/4_1_diana.txt +97 -0
  73. data/spec/support/active_record_data/4_1_multi.txt +196 -0
  74. data/spec/support/active_record_data/4_2_diana.txt +109 -0
  75. data/spec/support/active_record_data/4_2_diana_legacy.txt +109 -0
  76. data/spec/support/active_record_data/4_2_multi.txt +220 -0
  77. data/spec/support/active_record_data/4_2_multi_legacy.txt +220 -0
  78. data/spec/support/active_record_data/5_0_diana.txt +105 -0
  79. data/spec/support/active_record_data/5_0_multi.txt +212 -0
  80. data/spec/support/active_record_data/5_1_diana.txt +104 -0
  81. data/spec/support/active_record_data/5_1_multi.txt +210 -0
  82. data/spec/support/active_record_data/5_2_diana.txt +104 -0
  83. data/spec/support/active_record_data/5_2_multi.txt +210 -0
  84. data/spec/support/active_record_data/6_0_diana.txt +104 -0
  85. data/spec/support/active_record_data/6_0_multi.txt +210 -0
  86. data/spec/support/active_record_data/6_1_diana.txt +109 -0
  87. data/spec/support/active_record_data/6_1_multi.txt +220 -0
  88. data/spec/support/active_record_data.rb +20 -0
  89. data/spec/support/ext_verifier.rb +42 -0
  90. data/spec/support/mongoid_versions.rb +26 -0
  91. data/spec/support/rails_versions.rb +55 -0
  92. metadata +104 -15
  93. data/lib/awesome_print/ext/no_brainer.rb +0 -58
data/spec/methods_spec.rb CHANGED
@@ -1,75 +1,79 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Single method" do
4
- before do
5
- stub_dotfile!
6
- end
1
+ require 'spec_helper'
7
2
 
3
+ RSpec.describe 'Single method' do
8
4
  after do
9
- Object.instance_eval{ remove_const :Hello } if defined?(Hello)
5
+ Object.instance_eval { remove_const :Hello } if defined?(Hello)
10
6
  end
11
7
 
12
- it "plain: should handle a method with no arguments" do
8
+ it 'plain: should handle a method with no arguments' do
13
9
  method = ''.method(:upcase)
14
- expect(method.ai(:plain => true)).to eq('String#upcase()')
10
+ if RUBY_VERSION >= '2.4.0'
11
+ expect(method.ai(plain: true)).to eq('String#upcase(*arg1)')
12
+ else
13
+ expect(method.ai(plain: true)).to eq('String#upcase()')
14
+ end
15
15
  end
16
16
 
17
- it "color: should handle a method with no arguments" do
17
+ it 'color: should handle a method with no arguments' do
18
18
  method = ''.method(:upcase)
19
- expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35mupcase\e[0m\e[0;37m()\e[0m")
19
+ if RUBY_VERSION >= '2.4.0'
20
+ expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35mupcase\e[0m\e[0;37m(*arg1)\e[0m")
21
+ else
22
+ expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35mupcase\e[0m\e[0;37m()\e[0m")
23
+ end
20
24
  end
21
25
 
22
- it "plain: should handle a method with one argument" do
26
+ it 'plain: should handle a method with one argument' do
23
27
  method = ''.method(:include?)
24
- expect(method.ai(:plain => true)).to eq('String#include?(arg1)')
28
+ expect(method.ai(plain: true)).to eq('String#include?(arg1)')
25
29
  end
26
30
 
27
- it "color: should handle a method with one argument" do
31
+ it 'color: should handle a method with one argument' do
28
32
  method = ''.method(:include?)
29
33
  expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35minclude?\e[0m\e[0;37m(arg1)\e[0m")
30
34
  end
31
35
 
32
- it "plain: should handle a method with two arguments" do
36
+ it 'plain: should handle a method with two arguments' do
33
37
  method = ''.method(:tr)
34
- expect(method.ai(:plain => true)).to eq('String#tr(arg1, arg2)')
38
+ expect(method.ai(plain: true)).to eq('String#tr(arg1, arg2)')
35
39
  end
36
40
 
37
- it "color: should handle a method with two arguments" do
41
+ it 'color: should handle a method with two arguments' do
38
42
  method = ''.method(:tr)
39
43
  expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35mtr\e[0m\e[0;37m(arg1, arg2)\e[0m")
40
44
  end
41
45
 
42
- it "plain: should handle a method with multiple arguments" do
46
+ it 'plain: should handle a method with multiple arguments' do
43
47
  method = ''.method(:split)
44
- expect(method.ai(:plain => true)).to eq('String#split(*arg1)')
48
+ expect(method.ai(plain: true)).to eq('String#split(*arg1)')
45
49
  end
46
50
 
47
- it "color: should handle a method with multiple arguments" do
51
+ it 'color: should handle a method with multiple arguments' do
48
52
  method = ''.method(:split)
49
53
  expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35msplit\e[0m\e[0;37m(*arg1)\e[0m")
50
54
  end
51
55
 
52
- it "plain: should handle a method defined in mixin" do
56
+ it 'plain: should handle a method defined in mixin' do
53
57
  method = ''.method(:is_a?)
54
- expect(method.ai(:plain => true)).to eq('String (Kernel)#is_a?(arg1)')
58
+ expect(method.ai(plain: true)).to eq('String (Kernel)#is_a?(arg1)')
55
59
  end
56
60
 
57
- it "color: should handle a method defined in mixin" do
61
+ it 'color: should handle a method defined in mixin' do
58
62
  method = ''.method(:is_a?)
59
63
  expect(method.ai).to eq("\e[1;33mString (Kernel)\e[0m#\e[0;35mis_a?\e[0m\e[0;37m(arg1)\e[0m")
60
64
  end
61
65
 
62
- it "plain: should handle an unbound method" do
66
+ it 'plain: should handle an unbound method' do
63
67
  class Hello
64
68
  def world; end
65
69
  end
66
70
  method = Hello.instance_method(:world)
67
- expect(method.ai(:plain => true)).to eq('Hello (unbound)#world()')
71
+ expect(method.ai(plain: true)).to eq('Hello (unbound)#world()')
68
72
  end
69
73
 
70
- it "color: should handle an unbound method" do
74
+ it 'color: should handle an unbound method' do
71
75
  class Hello
72
- def world(a,b); end
76
+ def world(a, b); end
73
77
  end
74
78
  method = Hello.instance_method(:world)
75
79
  if RUBY_VERSION < '1.9.2'
@@ -80,93 +84,89 @@ describe "Single method" do
80
84
  end
81
85
  end
82
86
 
83
- describe "Object methods" do
84
- before do
85
- stub_dotfile!
86
- end
87
-
87
+ RSpec.describe 'Object methods' do
88
88
  after do
89
- Object.instance_eval{ remove_const :Hello } if defined?(Hello)
89
+ Object.instance_eval { remove_const :Hello } if defined?(Hello)
90
90
  end
91
91
 
92
- describe "object.methods" do
93
- it "index: should handle object.methods" do
94
- out = nil.methods.ai(:plain => true).split("\n").grep(/is_a\?/).first
92
+ describe 'object.methods' do
93
+ it 'index: should handle object.methods' do
94
+ out = nil.methods.ai(plain: true).split("\n").grep(/is_a\?/).first
95
95
  expect(out).to match(/^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/)
96
96
  end
97
97
 
98
- it "no index: should handle object.methods" do
99
- out = nil.methods.ai(:plain => true, :index => false).split("\n").grep(/is_a\?/).first
98
+ it 'no index: should handle object.methods' do
99
+ out = nil.methods.ai(plain: true, index: false).split("\n").grep(/is_a\?/).first
100
100
  expect(out).to match(/^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/)
101
101
  end
102
102
  end
103
103
 
104
- describe "object.public_methods" do
105
- it "index: should handle object.public_methods" do
106
- out = nil.public_methods.ai(:plain => true).split("\n").grep(/is_a\?/).first
104
+ describe 'object.public_methods' do
105
+ it 'index: should handle object.public_methods' do
106
+ out = nil.public_methods.ai(plain: true).split("\n").grep(/is_a\?/).first
107
107
  expect(out).to match(/^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/)
108
108
  end
109
109
 
110
- it "no index: should handle object.public_methods" do
111
- out = nil.public_methods.ai(:plain => true, :index => false).split("\n").grep(/is_a\?/).first
110
+ it 'no index: should handle object.public_methods' do
111
+ out = nil.public_methods.ai(plain: true, index: false).split("\n").grep(/is_a\?/).first
112
112
  expect(out).to match(/^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/)
113
113
  end
114
114
  end
115
115
 
116
- describe "object.private_methods" do
117
- it "index: should handle object.private_methods" do
118
- out = nil.private_methods.ai(:plain => true).split("\n").grep(/sleep/).first
116
+ describe 'object.private_methods' do
117
+ it 'index: should handle object.private_methods' do
118
+ out = nil.private_methods.ai(plain: true).split("\n").grep(/sleep/).first
119
119
  expect(out).to match(/^\s+\[\s*\d+\]\s+sleep\(\*arg1\)\s+NilClass \(Kernel\)$/)
120
120
  end
121
121
 
122
- it "no index: should handle object.private_methods" do
123
- out = nil.private_methods.ai(:plain => true, :index => false).split("\n").grep(/sleep/).first
122
+ it 'no index: should handle object.private_methods' do
123
+ out = nil.private_methods.ai(plain: true, index: false).split("\n").grep(/sleep/).first
124
124
  expect(out).to match(/^\s+sleep\(\*arg1\)\s+NilClass \(Kernel\)$/)
125
125
  end
126
126
  end
127
127
 
128
- describe "object.protected_methods" do
129
- it "index: should handle object.protected_methods" do
128
+ describe 'object.protected_methods' do
129
+ it 'index: should handle object.protected_methods' do
130
130
  class Hello
131
131
  protected
132
132
  def m1; end
133
133
  def m2; end
134
134
  end
135
- expect(Hello.new.protected_methods.ai(:plain => true)).to eq("[\n [0] m1() Hello\n [1] m2() Hello\n]")
135
+ expect(Hello.new.protected_methods.ai(plain: true)).to eq("[\n [0] m1() Hello\n [1] m2() Hello\n]")
136
136
  end
137
137
 
138
- it "no index: should handle object.protected_methods" do
138
+ it 'no index: should handle object.protected_methods' do
139
139
  class Hello
140
140
  protected
141
- def m3(a,b); end
141
+ def m3(a, b); end
142
142
  end
143
143
  if RUBY_VERSION < '1.9.2'
144
- expect(Hello.new.protected_methods.ai(:plain => true, :index => false)).to eq("[\n m3(arg1, arg2) Hello\n]")
144
+ expect(Hello.new.protected_methods.ai(plain: true, index: false)).to eq("[\n m3(arg1, arg2) Hello\n]")
145
145
  else
146
- expect(Hello.new.protected_methods.ai(:plain => true, :index => false)).to eq("[\n m3(a, b) Hello\n]")
146
+ expect(Hello.new.protected_methods.ai(plain: true, index: false)).to eq("[\n m3(a, b) Hello\n]")
147
147
  end
148
148
  end
149
149
  end
150
150
 
151
- describe "object.private_methods" do
152
- it "index: should handle object.private_methods" do
151
+ describe 'object.private_methods' do
152
+ it 'index: should handle object.private_methods' do
153
153
  class Hello
154
154
  private
155
155
  def m1; end
156
156
  def m2; end
157
157
  end
158
158
 
159
- out = Hello.new.private_methods.ai(:plain => true).split("\n").grep(/m\d/)
159
+ out = Hello.new.private_methods.ai(plain: true).split("\n").grep(/m\d/)
160
160
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/)
161
161
  expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello$/)
162
162
  end
163
163
 
164
- it "no index: should handle object.private_methods" do
164
+ it 'no index: should handle object.private_methods' do
165
165
  class Hello
166
166
  private
167
- def m3(a,b); end
167
+ def m3(a, b); end
168
168
  end
169
- out = Hello.new.private_methods.ai(:plain => true).split("\n").grep(/m\d/)
169
+ out = Hello.new.private_methods.ai(plain: true).split("\n").grep(/m\d/)
170
170
  if RUBY_VERSION < '1.9.2'
171
171
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m3\(arg1, arg2\)\s+Hello$/)
172
172
  else
@@ -175,24 +175,24 @@ describe "Object methods" do
175
175
  end
176
176
  end
177
177
 
178
- describe "object.singleton_methods" do
179
- it "index: should handle object.singleton_methods" do
178
+ describe 'object.singleton_methods' do
179
+ it 'index: should handle object.singleton_methods' do
180
180
  class Hello
181
181
  class << self
182
182
  def m1; end
183
183
  def m2; end
184
184
  end
185
185
  end
186
- out = Hello.singleton_methods.ai(:plain => true).split("\n").grep(/m\d/)
186
+ out = Hello.singleton_methods.ai(plain: true).split("\n").grep(/m\d/)
187
187
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/)
188
188
  expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello$/)
189
189
  end
190
190
 
191
- it "no index: should handle object.singleton_methods" do
191
+ it 'no index: should handle object.singleton_methods' do
192
192
  class Hello
193
- def self.m3(a,b); end
193
+ def self.m3(a, b); end
194
194
  end
195
- out = Hello.singleton_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
195
+ out = Hello.singleton_methods.ai(plain: true, index: false).split("\n").grep(/m\d/)
196
196
  if RUBY_VERSION < '1.9.2'
197
197
  expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello$/)
198
198
  else
@@ -202,31 +202,27 @@ describe "Object methods" do
202
202
  end
203
203
  end
204
204
 
205
- describe "Class methods" do
206
- before do
207
- stub_dotfile!
208
- end
209
-
205
+ RSpec.describe 'Class methods' do
210
206
  after do
211
- Object.instance_eval{ remove_const :Hello } if defined?(Hello)
207
+ Object.instance_eval { remove_const :Hello } if defined?(Hello)
212
208
  end
213
209
 
214
- describe "class.instance_methods" do
215
- it "index: should handle unbound class.instance_methods" do
210
+ describe 'class.instance_methods' do
211
+ it 'index: should handle unbound class.instance_methods' do
216
212
  class Hello
217
213
  def m1; end
218
214
  def m2; end
219
215
  end
220
- out = Hello.instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
216
+ out = Hello.instance_methods.ai(plain: true).split("\n").grep(/m\d/)
221
217
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
222
218
  expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
223
219
  end
224
220
 
225
- it "no index: should handle unbound class.instance_methods" do
221
+ it 'no index: should handle unbound class.instance_methods' do
226
222
  class Hello
227
- def m3(a,b); end
223
+ def m3(a, b); end
228
224
  end
229
- out = Hello.instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
225
+ out = Hello.instance_methods.ai(plain: true, index: false).split("\n").grep(/m\d/)
230
226
  if RUBY_VERSION < '1.9.2'
231
227
  expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
232
228
  else
@@ -235,22 +231,22 @@ describe "Class methods" do
235
231
  end
236
232
  end
237
233
 
238
- describe "class.public_instance_methods" do
239
- it "index: should handle class.public_instance_methods" do
234
+ describe 'class.public_instance_methods' do
235
+ it 'index: should handle class.public_instance_methods' do
240
236
  class Hello
241
237
  def m1; end
242
238
  def m2; end
243
239
  end
244
- out = Hello.public_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
240
+ out = Hello.public_instance_methods.ai(plain: true).split("\n").grep(/m\d/)
245
241
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
246
242
  expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
247
243
  end
248
244
 
249
- it "no index: should handle class.public_instance_methods" do
245
+ it 'no index: should handle class.public_instance_methods' do
250
246
  class Hello
251
- def m3(a,b); end
247
+ def m3(a, b); end
252
248
  end
253
- out = Hello.public_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
249
+ out = Hello.public_instance_methods.ai(plain: true, index: false).split("\n").grep(/m\d/)
254
250
  if RUBY_VERSION < '1.9.2'
255
251
  expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
256
252
  else
@@ -259,24 +255,24 @@ describe "Class methods" do
259
255
  end
260
256
  end
261
257
 
262
- describe "class.protected_instance_methods" do
263
- it "index: should handle class.protected_instance_methods" do
258
+ describe 'class.protected_instance_methods' do
259
+ it 'index: should handle class.protected_instance_methods' do
264
260
  class Hello
265
261
  protected
266
262
  def m1; end
267
263
  def m2; end
268
264
  end
269
- out = Hello.protected_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
265
+ out = Hello.protected_instance_methods.ai(plain: true).split("\n").grep(/m\d/)
270
266
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
271
267
  expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
272
268
  end
273
269
 
274
- it "no index: should handle class.protected_instance_methods" do
270
+ it 'no index: should handle class.protected_instance_methods' do
275
271
  class Hello
276
272
  protected
277
- def m3(a,b); end
273
+ def m3(a, b); end
278
274
  end
279
- out = Hello.protected_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
275
+ out = Hello.protected_instance_methods.ai(plain: true, index: false).split("\n").grep(/m\d/)
280
276
  if RUBY_VERSION < '1.9.2'
281
277
  expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
282
278
  else
@@ -285,24 +281,24 @@ describe "Class methods" do
285
281
  end
286
282
  end
287
283
 
288
- describe "class.private_instance_methods" do
289
- it "index: should handle class.private_instance_methods" do
284
+ describe 'class.private_instance_methods' do
285
+ it 'index: should handle class.private_instance_methods' do
290
286
  class Hello
291
287
  private
292
288
  def m1; end
293
289
  def m2; end
294
290
  end
295
- out = Hello.private_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
291
+ out = Hello.private_instance_methods.ai(plain: true).split("\n").grep(/m\d/)
296
292
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
297
293
  expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
298
294
  end
299
295
 
300
- it "no index: should handle class.private_instance_methods" do
296
+ it 'no index: should handle class.private_instance_methods' do
301
297
  class Hello
302
298
  private
303
- def m3(a,b); end
299
+ def m3(a, b); end
304
300
  end
305
- out = Hello.private_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
301
+ out = Hello.private_instance_methods.ai(plain: true, index: false).split("\n").grep(/m\d/)
306
302
  if RUBY_VERSION < '1.9.2'
307
303
  expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
308
304
  else
@@ -313,73 +309,73 @@ describe "Class methods" do
313
309
  end
314
310
 
315
311
  if RUBY_VERSION >= '1.9.2'
316
- describe "Ruby 1.9.2+ Method#parameters" do
312
+ RSpec.describe 'Ruby 1.9.2+ Method#parameters' do
317
313
  before do
318
314
  stub_dotfile!
319
315
  end
320
316
 
321
317
  after do
322
- Object.instance_eval{ remove_const :Hello } if defined?(Hello)
318
+ Object.instance_eval { remove_const :Hello } if defined?(Hello)
323
319
  end
324
320
 
325
- it "()" do
321
+ it '()' do
326
322
  class Hello
327
323
  def m1; end
328
324
  end
329
- out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
325
+ out = Hello.new.methods.ai(plain: true).split("\n").grep(/m1/)
330
326
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/)
331
327
  end
332
328
 
333
- it ":req" do
329
+ it ':req' do
334
330
  class Hello
335
331
  def m1(a, b, c); end
336
332
  end
337
- out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
333
+ out = Hello.new.methods.ai(plain: true).split("\n").grep(/m1/)
338
334
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(a, b, c\)\s+Hello$/)
339
335
  end
340
336
 
341
- it ":opt" do
337
+ it ':opt' do
342
338
  class Hello
343
339
  def m1(a, b = 1, c = 2); end # m1(a, *b, *c)
344
340
  end
345
- out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
341
+ out = Hello.new.methods.ai(plain: true).split("\n").grep(/m1/)
346
342
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(a, \*b, \*c\)\s+Hello$/)
347
343
  end
348
344
 
349
- it ":rest" do
345
+ it ':rest' do
350
346
  class Hello
351
347
  def m1(*a); end # m1(*a)
352
348
  end
353
- out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
349
+ out = Hello.new.methods.ai(plain: true).split("\n").grep(/m1/)
354
350
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\*a\)\s+Hello$/)
355
351
  end
356
352
 
357
- it ":block" do
353
+ it ':block' do
358
354
  class Hello
359
355
  def m1(a, b = nil, &blk); end # m1(a, *b, &blk)
360
356
  end
361
- out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
357
+ out = Hello.new.methods.ai(plain: true).split("\n").grep(/m1/)
362
358
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(a, \*b, &blk\)\s+Hello$/)
363
359
  end
364
360
  end
365
361
  end
366
362
 
367
- describe "Methods arrays" do
363
+ RSpec.describe 'Methods arrays' do
368
364
  after do
369
- Object.instance_eval{ remove_const :Hello } if defined?(Hello)
370
- Object.instance_eval{ remove_const :World } if defined?(World)
365
+ Object.instance_eval { remove_const :Hello } if defined?(Hello)
366
+ Object.instance_eval { remove_const :World } if defined?(World)
371
367
  end
372
368
 
373
- it "obj1.methods - obj2.methods should be awesome printed" do
369
+ it 'obj1.methods - obj2.methods should be awesome printed' do
374
370
  stub_dotfile!
375
371
  class Hello
376
372
  def self.m1; end
377
373
  end
378
- out = (Hello.methods - Class.methods).ai(:plain => true)
374
+ out = (Hello.methods - Class.methods).ai(plain: true)
379
375
  expect(out).to eq("[\n [0] m1() Hello\n]")
380
376
  end
381
377
 
382
- it "obj1.methods & obj2.methods should be awesome printed" do
378
+ it 'obj1.methods & obj2.methods should be awesome printed' do
383
379
  stub_dotfile!
384
380
  class Hello
385
381
  def self.m1; end
@@ -388,24 +384,24 @@ describe "Methods arrays" do
388
384
  class World
389
385
  def self.m1; end
390
386
  end
391
- out = (Hello.methods & World.methods - Class.methods).ai(:plain => true)
387
+ out = (Hello.methods & World.methods - Class.methods).ai(plain: true)
392
388
  expect(out).to eq("[\n [0] m1() Hello\n]")
393
389
  end
394
390
 
395
- it "obj1.methods.grep(pattern) should be awesome printed" do
391
+ it 'obj1.methods.grep(pattern) should be awesome printed' do
396
392
  stub_dotfile!
397
393
  class Hello
398
394
  def self.m1; end
399
395
  def self.m2; end
400
396
  def self.m3; end
401
397
  end
402
- out = Hello.methods.grep(/^m1$/).ai(:plain => true)
398
+ out = Hello.methods.grep(/^m1$/).ai(plain: true)
403
399
  expect(out).to eq("[\n [0] m1() Hello\n]")
404
- out = Hello.methods.grep(/^m\d$/).ai(:plain => true)
400
+ out = Hello.methods.grep(/^m\d$/).ai(plain: true)
405
401
  expect(out).to eq("[\n [0] m1() Hello\n [1] m2() Hello\n [2] m3() Hello\n]")
406
402
  end
407
403
 
408
- it "obj1.methods.grep(pattern, &block) should pass the matching string within the block" do
404
+ it 'obj1.methods.grep(pattern, &block) should pass the matching string within the block' do
409
405
  class Hello
410
406
  def self.m_one; end
411
407
  def self.m_two; end
@@ -415,7 +411,7 @@ describe "Methods arrays" do
415
411
  expect(out).to eq([:one, :two])
416
412
  end
417
413
 
418
- it "obj1.methods.grep(pattern, &block) should be awesome printed" do
414
+ it 'obj1.methods.grep(pattern, &block) should be awesome printed' do
419
415
  stub_dotfile!
420
416
  class Hello
421
417
  def self.m0; end
@@ -424,12 +420,12 @@ describe "Methods arrays" do
424
420
  def self.one; end
425
421
  end
426
422
 
427
- out = Hello.methods.grep(/^m(\d)$/) { %w(none one)[$1.to_i] }.ai(:plain => true)
423
+ out = Hello.methods.grep(/^m(\d)$/) { %w(none one)[$1.to_i] }.ai(plain: true)
428
424
  expect(out).to eq("[\n [0] none() Hello\n [1] one() Hello\n]")
429
425
  end
430
426
 
431
- # See https://github.com/michaeldv/awesome_print/issues/30 for details.
432
- it "grepping methods and converting them to_sym should work as expected" do
427
+ # See https://github.com/awesome-print/awesome_print/issues/30 for details.
428
+ it 'grepping methods and converting them to_sym should work as expected' do
433
429
  class Hello
434
430
  private
435
431
  def him; end
@@ -444,16 +440,16 @@ describe "Methods arrays" do
444
440
  end
445
441
 
446
442
  hello = Hello.new
447
- expect((hello.send(:his) - hello.send(:her)).sort_by { |x| x.to_s }).to eq([ :him, :his ])
443
+ expect((hello.send(:his) - hello.send(:her)).sort_by { |x| x.to_s }).to eq([:him, :his])
448
444
  end
449
445
 
450
- it "appending garbage to methods array should not raise error" do
451
- arr = 42.methods << [ :wtf ]
452
- expect { arr.ai(:plain => true) }.not_to raise_error
446
+ it 'appending garbage to methods array should not raise error' do
447
+ arr = 42.methods << [:wtf]
448
+ expect { arr.ai(plain: true) }.not_to raise_error
453
449
  if RUBY_VERSION < '1.9.2'
454
- expect(arr.ai(:plain => true)).to match(/\s+wtf\(\?\)\s+\?/) # [ :wtf ].to_s => "wtf"
450
+ expect(arr.ai(plain: true)).to match(/\s+wtf\(\?\)\s+\?/) # [ :wtf ].to_s => "wtf"
455
451
  else
456
- expect(arr.ai(:plain => true)).to match(/\s+\[:wtf\]\(\?\)\s+\?/) # [ :wtf ].to_s => [:wtf]
452
+ expect(arr.ai(plain: true)).to match(/\s+\[:wtf\]\(\?\)\s+\?/) # [ :wtf ].to_s => [:wtf]
457
453
  end
458
454
  end
459
455
  end