awesome_print 1.0.2 → 1.7.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 (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -1
  3. data/Appraisals +52 -0
  4. data/CHANGELOG.md +152 -0
  5. data/CONTRIBUTING.md +81 -0
  6. data/Gemfile +3 -2
  7. data/Gemfile.lock +44 -13
  8. data/LICENSE +3 -3
  9. data/README.md +272 -264
  10. data/Rakefile +23 -1
  11. data/lib/ap.rb +1 -1
  12. data/lib/awesome_print/colorize.rb +24 -0
  13. data/lib/awesome_print/core_ext/array.rb +12 -2
  14. data/lib/awesome_print/core_ext/class.rb +1 -1
  15. data/lib/awesome_print/core_ext/kernel.rb +8 -3
  16. data/lib/awesome_print/core_ext/logger.rb +1 -1
  17. data/lib/awesome_print/core_ext/method.rb +1 -1
  18. data/lib/awesome_print/core_ext/object.rb +1 -1
  19. data/lib/awesome_print/core_ext/string.rb +1 -1
  20. data/lib/awesome_print/ext/action_view.rb +1 -1
  21. data/lib/awesome_print/ext/active_record.rb +8 -2
  22. data/lib/awesome_print/ext/active_support.rb +2 -2
  23. data/lib/awesome_print/ext/mongo_mapper.rb +86 -3
  24. data/lib/awesome_print/ext/mongoid.rb +3 -3
  25. data/lib/awesome_print/ext/nobrainer.rb +49 -0
  26. data/lib/awesome_print/ext/nokogiri.rb +1 -1
  27. data/lib/awesome_print/ext/ostruct.rb +27 -0
  28. data/lib/awesome_print/ext/ripple.rb +72 -0
  29. data/lib/awesome_print/ext/sequel.rb +57 -0
  30. data/lib/awesome_print/formatter.rb +59 -309
  31. data/lib/awesome_print/formatters/array_formatter.rb +73 -0
  32. data/lib/awesome_print/formatters/base_formatter.rb +138 -0
  33. data/lib/awesome_print/formatters/class_formatter.rb +24 -0
  34. data/lib/awesome_print/formatters/dir_formatter.rb +22 -0
  35. data/lib/awesome_print/formatters/file_formatter.rb +22 -0
  36. data/lib/awesome_print/formatters/hash_formatter.rb +54 -0
  37. data/lib/awesome_print/formatters/method_formatter.rb +22 -0
  38. data/lib/awesome_print/formatters/object_formatter.rb +80 -0
  39. data/lib/awesome_print/formatters/simple_formatter.rb +21 -0
  40. data/lib/awesome_print/indentator.rb +18 -0
  41. data/lib/awesome_print/inspector.rb +48 -6
  42. data/lib/awesome_print/version.rb +2 -2
  43. data/lib/awesome_print.rb +20 -10
  44. data/spec/active_record_helper.rb +24 -0
  45. data/spec/colors_spec.rb +10 -10
  46. data/spec/formats_spec.rb +191 -170
  47. data/spec/methods_spec.rb +69 -68
  48. data/spec/misc_spec.rb +250 -0
  49. data/spec/objects_spec.rb +62 -12
  50. data/spec/spec_helper.rb +66 -34
  51. metadata +125 -49
  52. data/CHANGELOG +0 -77
data/spec/methods_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
- describe "Single method" do
3
+ RSpec.describe "Single method" do
4
4
  before do
5
5
  stub_dotfile!
6
6
  end
@@ -11,52 +11,52 @@ describe "Single method" do
11
11
 
12
12
  it "plain: should handle a method with no arguments" do
13
13
  method = ''.method(:upcase)
14
- method.ai(:plain => true).should == 'String#upcase()'
14
+ expect(method.ai(:plain => true)).to eq('String#upcase()')
15
15
  end
16
16
 
17
17
  it "color: should handle a method with no arguments" do
18
18
  method = ''.method(:upcase)
19
- method.ai.should == "\e[1;33mString\e[0m#\e[0;35mupcase\e[0m\e[0;37m()\e[0m"
19
+ expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35mupcase\e[0m\e[0;37m()\e[0m")
20
20
  end
21
21
 
22
22
  it "plain: should handle a method with one argument" do
23
23
  method = ''.method(:include?)
24
- method.ai(:plain => true).should == 'String#include?(arg1)'
24
+ expect(method.ai(:plain => true)).to eq('String#include?(arg1)')
25
25
  end
26
26
 
27
27
  it "color: should handle a method with one argument" do
28
28
  method = ''.method(:include?)
29
- method.ai.should == "\e[1;33mString\e[0m#\e[0;35minclude?\e[0m\e[0;37m(arg1)\e[0m"
29
+ expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35minclude?\e[0m\e[0;37m(arg1)\e[0m")
30
30
  end
31
31
 
32
32
  it "plain: should handle a method with two arguments" do
33
33
  method = ''.method(:tr)
34
- method.ai(:plain => true).should == 'String#tr(arg1, arg2)'
34
+ expect(method.ai(:plain => true)).to eq('String#tr(arg1, arg2)')
35
35
  end
36
36
 
37
37
  it "color: should handle a method with two arguments" do
38
38
  method = ''.method(:tr)
39
- method.ai.should == "\e[1;33mString\e[0m#\e[0;35mtr\e[0m\e[0;37m(arg1, arg2)\e[0m"
39
+ expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35mtr\e[0m\e[0;37m(arg1, arg2)\e[0m")
40
40
  end
41
41
 
42
42
  it "plain: should handle a method with multiple arguments" do
43
43
  method = ''.method(:split)
44
- method.ai(:plain => true).should == 'String#split(*arg1)'
44
+ expect(method.ai(:plain => true)).to eq('String#split(*arg1)')
45
45
  end
46
46
 
47
47
  it "color: should handle a method with multiple arguments" do
48
48
  method = ''.method(:split)
49
- method.ai.should == "\e[1;33mString\e[0m#\e[0;35msplit\e[0m\e[0;37m(*arg1)\e[0m"
49
+ expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35msplit\e[0m\e[0;37m(*arg1)\e[0m")
50
50
  end
51
51
 
52
52
  it "plain: should handle a method defined in mixin" do
53
53
  method = ''.method(:is_a?)
54
- method.ai(:plain => true).should == 'String (Kernel)#is_a?(arg1)'
54
+ expect(method.ai(:plain => true)).to eq('String (Kernel)#is_a?(arg1)')
55
55
  end
56
56
 
57
57
  it "color: should handle a method defined in mixin" do
58
58
  method = ''.method(:is_a?)
59
- method.ai.should == "\e[1;33mString (Kernel)\e[0m#\e[0;35mis_a?\e[0m\e[0;37m(arg1)\e[0m"
59
+ expect(method.ai).to eq("\e[1;33mString (Kernel)\e[0m#\e[0;35mis_a?\e[0m\e[0;37m(arg1)\e[0m")
60
60
  end
61
61
 
62
62
  it "plain: should handle an unbound method" do
@@ -64,7 +64,7 @@ describe "Single method" do
64
64
  def world; end
65
65
  end
66
66
  method = Hello.instance_method(:world)
67
- method.ai(:plain => true).should == 'Hello (unbound)#world()'
67
+ expect(method.ai(:plain => true)).to eq('Hello (unbound)#world()')
68
68
  end
69
69
 
70
70
  it "color: should handle an unbound method" do
@@ -73,14 +73,14 @@ describe "Single method" do
73
73
  end
74
74
  method = Hello.instance_method(:world)
75
75
  if RUBY_VERSION < '1.9.2'
76
- method.ai.should == "\e[1;33mHello (unbound)\e[0m#\e[0;35mworld\e[0m\e[0;37m(arg1, arg2)\e[0m"
76
+ expect(method.ai).to eq("\e[1;33mHello (unbound)\e[0m#\e[0;35mworld\e[0m\e[0;37m(arg1, arg2)\e[0m")
77
77
  else
78
- method.ai.should == "\e[1;33mHello (unbound)\e[0m#\e[0;35mworld\e[0m\e[0;37m(a, b)\e[0m"
78
+ expect(method.ai).to eq("\e[1;33mHello (unbound)\e[0m#\e[0;35mworld\e[0m\e[0;37m(a, b)\e[0m")
79
79
  end
80
80
  end
81
81
  end
82
82
 
83
- describe "Object methods" do
83
+ RSpec.describe "Object methods" do
84
84
  before do
85
85
  stub_dotfile!
86
86
  end
@@ -92,36 +92,36 @@ describe "Object methods" do
92
92
  describe "object.methods" do
93
93
  it "index: should handle object.methods" do
94
94
  out = nil.methods.ai(:plain => true).split("\n").grep(/is_a\?/).first
95
- out.should =~ /^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/
95
+ expect(out).to match(/^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/)
96
96
  end
97
97
 
98
98
  it "no index: should handle object.methods" do
99
99
  out = nil.methods.ai(:plain => true, :index => false).split("\n").grep(/is_a\?/).first
100
- out.should =~ /^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/
100
+ expect(out).to match(/^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/)
101
101
  end
102
102
  end
103
103
 
104
104
  describe "object.public_methods" do
105
105
  it "index: should handle object.public_methods" do
106
106
  out = nil.public_methods.ai(:plain => true).split("\n").grep(/is_a\?/).first
107
- out.should =~ /^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/
107
+ expect(out).to match(/^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/)
108
108
  end
109
109
 
110
110
  it "no index: should handle object.public_methods" do
111
111
  out = nil.public_methods.ai(:plain => true, :index => false).split("\n").grep(/is_a\?/).first
112
- out.should =~ /^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/
112
+ expect(out).to match(/^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/)
113
113
  end
114
114
  end
115
115
 
116
116
  describe "object.private_methods" do
117
117
  it "index: should handle object.private_methods" do
118
118
  out = nil.private_methods.ai(:plain => true).split("\n").grep(/sleep/).first
119
- out.should =~ /^\s+\[\s*\d+\]\s+sleep\(\*arg1\)\s+NilClass \(Kernel\)$/
119
+ expect(out).to match(/^\s+\[\s*\d+\]\s+sleep\(\*arg1\)\s+NilClass \(Kernel\)$/)
120
120
  end
121
121
 
122
122
  it "no index: should handle object.private_methods" do
123
123
  out = nil.private_methods.ai(:plain => true, :index => false).split("\n").grep(/sleep/).first
124
- out.should =~ /^\s+sleep\(\*arg1\)\s+NilClass \(Kernel\)$/
124
+ expect(out).to match(/^\s+sleep\(\*arg1\)\s+NilClass \(Kernel\)$/)
125
125
  end
126
126
  end
127
127
 
@@ -132,7 +132,7 @@ describe "Object methods" do
132
132
  def m1; end
133
133
  def m2; end
134
134
  end
135
- Hello.new.protected_methods.ai(:plain => true).should == "[\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
138
  it "no index: should handle object.protected_methods" do
@@ -141,9 +141,9 @@ describe "Object methods" do
141
141
  def m3(a,b); end
142
142
  end
143
143
  if RUBY_VERSION < '1.9.2'
144
- Hello.new.protected_methods.ai(:plain => true, :index => false).should == "[\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
- Hello.new.protected_methods.ai(:plain => true, :index => false).should == "[\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
@@ -155,9 +155,10 @@ describe "Object methods" do
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.first.should =~ /^\s+\[\d+\]\s+m1\(\)\s+Hello$/
160
- out.last.should =~ /^\s+\[\d+\]\s+m2\(\)\s+Hello$/
160
+ expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/)
161
+ expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello$/)
161
162
  end
162
163
 
163
164
  it "no index: should handle object.private_methods" do
@@ -167,9 +168,9 @@ describe "Object methods" do
167
168
  end
168
169
  out = Hello.new.private_methods.ai(:plain => true).split("\n").grep(/m\d/)
169
170
  if RUBY_VERSION < '1.9.2'
170
- out.first.should =~ /^\s+\[\d+\]\s+m3\(arg1, arg2\)\s+Hello$/
171
+ expect(out.first).to match(/^\s+\[\s*\d+\]\s+m3\(arg1, arg2\)\s+Hello$/)
171
172
  else
172
- out.first.should =~ /^\s+\[\d+\]\s+m3\(a, b\)\s+Hello$/
173
+ expect(out.first).to match(/^\s+\[\s*\d+\]\s+m3\(a, b\)\s+Hello$/)
173
174
  end
174
175
  end
175
176
  end
@@ -183,8 +184,8 @@ describe "Object methods" do
183
184
  end
184
185
  end
185
186
  out = Hello.singleton_methods.ai(:plain => true).split("\n").grep(/m\d/)
186
- out.first.should =~ /^\s+\[\d+\]\s+m1\(\)\s+Hello$/
187
- out.last.should =~ /^\s+\[\d+\]\s+m2\(\)\s+Hello$/
187
+ expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/)
188
+ expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello$/)
188
189
  end
189
190
 
190
191
  it "no index: should handle object.singleton_methods" do
@@ -193,15 +194,15 @@ describe "Object methods" do
193
194
  end
194
195
  out = Hello.singleton_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
195
196
  if RUBY_VERSION < '1.9.2'
196
- out.first.should =~ /^\s+m3\(arg1, arg2\)\s+Hello$/
197
+ expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello$/)
197
198
  else
198
- out.first.should =~ /^\s+m3\(a, b\)\s+Hello$/
199
+ expect(out.first).to match(/^\s+m3\(a, b\)\s+Hello$/)
199
200
  end
200
201
  end
201
202
  end
202
203
  end
203
204
 
204
- describe "Class methods" do
205
+ RSpec.describe "Class methods" do
205
206
  before do
206
207
  stub_dotfile!
207
208
  end
@@ -217,8 +218,8 @@ describe "Class methods" do
217
218
  def m2; end
218
219
  end
219
220
  out = Hello.instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
220
- out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/
221
- out.last.should =~ /^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/
221
+ expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
222
+ expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
222
223
  end
223
224
 
224
225
  it "no index: should handle unbound class.instance_methods" do
@@ -227,9 +228,9 @@ describe "Class methods" do
227
228
  end
228
229
  out = Hello.instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
229
230
  if RUBY_VERSION < '1.9.2'
230
- out.first.should =~ /^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/
231
+ expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
231
232
  else
232
- out.first.should =~ /^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/
233
+ expect(out.first).to match(/^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/)
233
234
  end
234
235
  end
235
236
  end
@@ -241,8 +242,8 @@ describe "Class methods" do
241
242
  def m2; end
242
243
  end
243
244
  out = Hello.public_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
244
- out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/
245
- out.last.should =~ /^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/
245
+ expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
246
+ expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
246
247
  end
247
248
 
248
249
  it "no index: should handle class.public_instance_methods" do
@@ -251,9 +252,9 @@ describe "Class methods" do
251
252
  end
252
253
  out = Hello.public_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
253
254
  if RUBY_VERSION < '1.9.2'
254
- out.first.should =~ /^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/
255
+ expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
255
256
  else
256
- out.first.should =~ /^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/
257
+ expect(out.first).to match(/^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/)
257
258
  end
258
259
  end
259
260
  end
@@ -266,8 +267,8 @@ describe "Class methods" do
266
267
  def m2; end
267
268
  end
268
269
  out = Hello.protected_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
269
- out.first.should =~ /^\s+\[\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/
270
- out.last.should =~ /^\s+\[\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/
270
+ expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
271
+ expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
271
272
  end
272
273
 
273
274
  it "no index: should handle class.protected_instance_methods" do
@@ -277,9 +278,9 @@ describe "Class methods" do
277
278
  end
278
279
  out = Hello.protected_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
279
280
  if RUBY_VERSION < '1.9.2'
280
- out.first.should =~ /^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/
281
+ expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
281
282
  else
282
- out.first.should =~ /^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/
283
+ expect(out.first).to match(/^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/)
283
284
  end
284
285
  end
285
286
  end
@@ -292,8 +293,8 @@ describe "Class methods" do
292
293
  def m2; end
293
294
  end
294
295
  out = Hello.private_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
295
- out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/
296
- out.last.should =~ /^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/
296
+ expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
297
+ expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
297
298
  end
298
299
 
299
300
  it "no index: should handle class.private_instance_methods" do
@@ -303,16 +304,16 @@ describe "Class methods" do
303
304
  end
304
305
  out = Hello.private_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
305
306
  if RUBY_VERSION < '1.9.2'
306
- out.first.should =~ /^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/
307
+ expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
307
308
  else
308
- out.first.should =~ /^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/
309
+ expect(out.first).to match(/^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/)
309
310
  end
310
311
  end
311
312
  end
312
313
  end
313
314
 
314
315
  if RUBY_VERSION >= '1.9.2'
315
- describe "Ruby 1.9.2+ Method#parameters" do
316
+ RSpec.describe "Ruby 1.9.2+ Method#parameters" do
316
317
  before do
317
318
  stub_dotfile!
318
319
  end
@@ -326,7 +327,7 @@ if RUBY_VERSION >= '1.9.2'
326
327
  def m1; end
327
328
  end
328
329
  out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
329
- out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/
330
+ expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/)
330
331
  end
331
332
 
332
333
  it ":req" do
@@ -334,7 +335,7 @@ if RUBY_VERSION >= '1.9.2'
334
335
  def m1(a, b, c); end
335
336
  end
336
337
  out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
337
- out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(a, b, c\)\s+Hello$/
338
+ expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(a, b, c\)\s+Hello$/)
338
339
  end
339
340
 
340
341
  it ":opt" do
@@ -342,7 +343,7 @@ if RUBY_VERSION >= '1.9.2'
342
343
  def m1(a, b = 1, c = 2); end # m1(a, *b, *c)
343
344
  end
344
345
  out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
345
- out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(a, \*b, \*c\)\s+Hello$/
346
+ expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(a, \*b, \*c\)\s+Hello$/)
346
347
  end
347
348
 
348
349
  it ":rest" do
@@ -350,7 +351,7 @@ if RUBY_VERSION >= '1.9.2'
350
351
  def m1(*a); end # m1(*a)
351
352
  end
352
353
  out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
353
- out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(\*a\)\s+Hello$/
354
+ expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\*a\)\s+Hello$/)
354
355
  end
355
356
 
356
357
  it ":block" do
@@ -358,12 +359,12 @@ if RUBY_VERSION >= '1.9.2'
358
359
  def m1(a, b = nil, &blk); end # m1(a, *b, &blk)
359
360
  end
360
361
  out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
361
- out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(a, \*b, &blk\)\s+Hello$/
362
+ expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(a, \*b, &blk\)\s+Hello$/)
362
363
  end
363
364
  end
364
365
  end
365
366
 
366
- describe "Methods arrays" do
367
+ RSpec.describe "Methods arrays" do
367
368
  after do
368
369
  Object.instance_eval{ remove_const :Hello } if defined?(Hello)
369
370
  Object.instance_eval{ remove_const :World } if defined?(World)
@@ -375,7 +376,7 @@ describe "Methods arrays" do
375
376
  def self.m1; end
376
377
  end
377
378
  out = (Hello.methods - Class.methods).ai(:plain => true)
378
- out.should == "[\n [0] m1() Hello\n]"
379
+ expect(out).to eq("[\n [0] m1() Hello\n]")
379
380
  end
380
381
 
381
382
  it "obj1.methods & obj2.methods should be awesome printed" do
@@ -388,7 +389,7 @@ describe "Methods arrays" do
388
389
  def self.m1; end
389
390
  end
390
391
  out = (Hello.methods & World.methods - Class.methods).ai(:plain => true)
391
- out.should == "[\n [0] m1() Hello\n]"
392
+ expect(out).to eq("[\n [0] m1() Hello\n]")
392
393
  end
393
394
 
394
395
  it "obj1.methods.grep(pattern) should be awesome printed" do
@@ -399,9 +400,9 @@ describe "Methods arrays" do
399
400
  def self.m3; end
400
401
  end
401
402
  out = Hello.methods.grep(/^m1$/).ai(:plain => true)
402
- out.should == "[\n [0] m1() Hello\n]"
403
+ expect(out).to eq("[\n [0] m1() Hello\n]")
403
404
  out = Hello.methods.grep(/^m\d$/).ai(:plain => true)
404
- out.should == "[\n [0] m1() Hello\n [1] m2() Hello\n [2] m3() Hello\n]"
405
+ expect(out).to eq("[\n [0] m1() Hello\n [1] m2() Hello\n [2] m3() Hello\n]")
405
406
  end
406
407
 
407
408
  it "obj1.methods.grep(pattern, &block) should pass the matching string within the block" do
@@ -410,8 +411,8 @@ describe "Methods arrays" do
410
411
  def self.m_two; end
411
412
  end
412
413
 
413
- out = Hello.methods.grep(/^m_(.+)$/) { $1.to_sym }
414
- out.should == [:one, :two]
414
+ out = Hello.methods.sort.grep(/^m_(.+)$/) { $1.to_sym }
415
+ expect(out).to eq([:one, :two])
415
416
  end
416
417
 
417
418
  it "obj1.methods.grep(pattern, &block) should be awesome printed" do
@@ -424,7 +425,7 @@ describe "Methods arrays" do
424
425
  end
425
426
 
426
427
  out = Hello.methods.grep(/^m(\d)$/) { %w(none one)[$1.to_i] }.ai(:plain => true)
427
- out.should == "[\n [0] none() Hello\n [1] one() Hello\n]"
428
+ expect(out).to eq("[\n [0] none() Hello\n [1] one() Hello\n]")
428
429
  end
429
430
 
430
431
  # See https://github.com/michaeldv/awesome_print/issues/30 for details.
@@ -443,16 +444,16 @@ describe "Methods arrays" do
443
444
  end
444
445
 
445
446
  hello = Hello.new
446
- (hello.send(:his) - hello.send(:her)).sort_by { |x| x.to_s }.should == [ :him, :his ]
447
+ expect((hello.send(:his) - hello.send(:her)).sort_by { |x| x.to_s }).to eq([ :him, :his ])
447
448
  end
448
449
 
449
450
  it "appending garbage to methods array should not raise error" do
450
451
  arr = 42.methods << [ :wtf ]
451
- arr.ai(:plain => true).should_not raise_error(TypeError)
452
+ expect { arr.ai(:plain => true) }.not_to raise_error
452
453
  if RUBY_VERSION < '1.9.2'
453
- arr.ai(:plain => true).should =~ /\s+wtf\(\?\)\s+\?/ # [ :wtf ].to_s => "wtf"
454
+ expect(arr.ai(:plain => true)).to match(/\s+wtf\(\?\)\s+\?/) # [ :wtf ].to_s => "wtf"
454
455
  else
455
- arr.ai(:plain => true).should =~ /\s+\[:wtf\]\(\?\)\s+\?/ # [ :wtf ].to_s => [:wtf]
456
+ expect(arr.ai(:plain => true)).to match(/\s+\[:wtf\]\(\?\)\s+\?/) # [ :wtf ].to_s => [:wtf]
456
457
  end
457
458
  end
458
459
  end