amazing_print 1.3.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +0 -6
- data/CHANGELOG.md +24 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +51 -47
- data/README.md +9 -7
- data/lib/amazing_print/colorize.rb +5 -14
- data/lib/amazing_print/colors.rb +37 -0
- data/lib/amazing_print/core_ext/awesome_method_array.rb +4 -4
- data/lib/amazing_print/core_ext/class.rb +1 -1
- data/lib/amazing_print/core_ext/logger.rb +1 -3
- data/lib/amazing_print/core_ext/object.rb +1 -1
- data/lib/amazing_print/custom_defaults.rb +10 -3
- data/lib/amazing_print/ext/active_record.rb +5 -9
- data/lib/amazing_print/ext/active_support.rb +1 -3
- data/lib/amazing_print/ext/mongo_mapper.rb +4 -7
- data/lib/amazing_print/ext/mongoid.rb +2 -6
- data/lib/amazing_print/ext/nobrainer.rb +3 -5
- data/lib/amazing_print/ext/nokogiri.rb +1 -3
- data/lib/amazing_print/ext/ostruct.rb +1 -3
- data/lib/amazing_print/ext/ripple.rb +4 -5
- data/lib/amazing_print/formatter.rb +5 -6
- data/lib/amazing_print/formatters/array_formatter.rb +7 -6
- data/lib/amazing_print/formatters/base_formatter.rb +20 -25
- data/lib/amazing_print/formatters/class_formatter.rb +1 -0
- data/lib/amazing_print/formatters/dir_formatter.rb +11 -1
- data/lib/amazing_print/formatters/file_formatter.rb +11 -1
- data/lib/amazing_print/formatters/hash_formatter.rb +5 -3
- data/lib/amazing_print/formatters/method_formatter.rb +1 -0
- data/lib/amazing_print/formatters/mswin_helper.rb +63 -0
- data/lib/amazing_print/formatters/object_formatter.rb +2 -1
- data/lib/amazing_print/formatters/simple_formatter.rb +1 -0
- data/lib/amazing_print/formatters/struct_formatter.rb +2 -1
- data/lib/amazing_print/inspector.rb +29 -5
- data/lib/amazing_print/version.rb +1 -1
- data/lib/amazing_print.rb +3 -7
- data/spec/active_record_helper.rb +3 -0
- data/spec/colors_spec.rb +15 -6
- data/spec/core_ext/logger_spec.rb +7 -7
- data/spec/ext/action_controller_spec.rb +5 -5
- data/spec/ext/active_model_spec.rb +1 -1
- data/spec/ext/active_record_spec.rb +39 -73
- data/spec/ext/active_support_spec.rb +3 -3
- data/spec/ext/mongo_mapper_spec.rb +15 -11
- data/spec/ext/mongoid_spec.rb +7 -3
- data/spec/ext/nobrainer_spec.rb +6 -2
- data/spec/ext/nokogiri_spec.rb +7 -7
- data/spec/ext/ripple_spec.rb +6 -2
- data/spec/ext/sequel_spec.rb +1 -1
- data/spec/formats_spec.rb +101 -90
- data/spec/methods_spec.rb +12 -4
- data/spec/misc_spec.rb +29 -70
- data/spec/objects_spec.rb +4 -0
- data/spec/spec_helper.rb +11 -9
- metadata +10 -142
- data/lib/amazing_print/core_ext/string.rb +0 -45
- data/spec/core_ext/string_spec.rb +0 -15
@@ -23,11 +23,7 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
|
|
23
23
|
:rank => 1
|
24
24
|
}
|
25
25
|
EOS
|
26
|
-
|
27
|
-
str.sub!('?', 'Sat Oct 10 12:30:00 UTC 1992')
|
28
|
-
else
|
29
|
-
str.sub!('?', '1992-10-10 12:30:00 UTC')
|
30
|
-
end
|
26
|
+
str.sub!('?', '1992-10-10 12:30:00 UTC')
|
31
27
|
expect(out).to be_similar_to(str)
|
32
28
|
end
|
33
29
|
|
@@ -51,13 +47,8 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
|
|
51
47
|
}
|
52
48
|
]
|
53
49
|
EOS
|
54
|
-
|
55
|
-
|
56
|
-
str.sub!('?!', 'Mon May 26 14:15:00 UTC 2003')
|
57
|
-
else
|
58
|
-
str.sub!('??', '1992-10-10 12:30:00 UTC')
|
59
|
-
str.sub!('?!', '2003-05-26 14:15:00 UTC')
|
60
|
-
end
|
50
|
+
str.sub!('??', '1992-10-10 12:30:00 UTC')
|
51
|
+
str.sub!('?!', '2003-05-26 14:15:00 UTC')
|
61
52
|
expect(out).to be_similar_to(str)
|
62
53
|
end
|
63
54
|
|
@@ -83,13 +74,8 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
|
|
83
74
|
}
|
84
75
|
]
|
85
76
|
EOS
|
86
|
-
|
87
|
-
|
88
|
-
str.sub!('?!', 'Mon May 26 14:15:00 UTC 2003')
|
89
|
-
else
|
90
|
-
str.sub!('??', '1992-10-10 12:30:00 UTC')
|
91
|
-
str.sub!('?!', '2003-05-26 14:15:00 UTC')
|
92
|
-
end
|
77
|
+
str.sub!('??', '1992-10-10 12:30:00 UTC')
|
78
|
+
str.sub!('?!', '2003-05-26 14:15:00 UTC')
|
93
79
|
expect(out).to be_similar_to(str)
|
94
80
|
end
|
95
81
|
end
|
@@ -99,7 +85,7 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
|
|
99
85
|
@ap = AmazingPrint::Inspector.new(plain: true)
|
100
86
|
end
|
101
87
|
|
102
|
-
it '
|
88
|
+
it 'shows the entire record' do
|
103
89
|
e = Email.create(email_address: 'foo@bar.com')
|
104
90
|
u = User.last
|
105
91
|
u.emails << e
|
@@ -139,21 +125,13 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
|
|
139
125
|
elsif activerecord_5_0?
|
140
126
|
ActiveRecordData.raw_5_0_diana
|
141
127
|
elsif activerecord_4_2?
|
142
|
-
|
143
|
-
ActiveRecordData.raw_4_2_diana
|
144
|
-
else
|
145
|
-
ActiveRecordData.raw_4_2_diana_legacy
|
146
|
-
end
|
128
|
+
ActiveRecordData.raw_4_2_diana
|
147
129
|
elsif activerecord_4_1?
|
148
130
|
ActiveRecordData.raw_4_1_diana
|
149
131
|
elsif activerecord_4_0?
|
150
132
|
ActiveRecordData.raw_4_0_diana
|
151
133
|
elsif activerecord_3_2?
|
152
|
-
|
153
|
-
ActiveRecordData.raw_3_2_diana
|
154
|
-
else
|
155
|
-
ActiveRecordData.raw_3_2_diana_legacy
|
156
|
-
end
|
134
|
+
ActiveRecordData.raw_3_2_diana
|
157
135
|
end
|
158
136
|
|
159
137
|
if RUBY_PLATFORM == 'java' && !activerecord_6_1?
|
@@ -181,21 +159,13 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
|
|
181
159
|
elsif activerecord_5_0?
|
182
160
|
ActiveRecordData.raw_5_0_multi
|
183
161
|
elsif activerecord_4_2?
|
184
|
-
|
185
|
-
ActiveRecordData.raw_4_2_multi
|
186
|
-
else
|
187
|
-
ActiveRecordData.raw_4_2_multi_legacy
|
188
|
-
end
|
162
|
+
ActiveRecordData.raw_4_2_multi
|
189
163
|
elsif activerecord_4_1?
|
190
164
|
ActiveRecordData.raw_4_1_multi
|
191
165
|
elsif activerecord_4_0?
|
192
166
|
ActiveRecordData.raw_4_0_multi
|
193
167
|
elsif activerecord_3_2?
|
194
|
-
|
195
|
-
ActiveRecordData.raw_3_2_multi
|
196
|
-
else
|
197
|
-
ActiveRecordData.raw_3_2_multi_legacy
|
198
|
-
end
|
168
|
+
ActiveRecordData.raw_3_2_multi
|
199
169
|
end
|
200
170
|
|
201
171
|
if RUBY_PLATFORM == 'java' && !activerecord_6_1?
|
@@ -216,7 +186,7 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
|
|
216
186
|
@ap = AmazingPrint::Inspector.new(plain: true)
|
217
187
|
end
|
218
188
|
|
219
|
-
it '
|
189
|
+
it 'prints the class' do
|
220
190
|
expect(@ap.awesome(User)).to eq <<~EOS.strip
|
221
191
|
class User < ActiveRecord::Base {
|
222
192
|
:id => :integer,
|
@@ -228,7 +198,7 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
|
|
228
198
|
EOS
|
229
199
|
end
|
230
200
|
|
231
|
-
it '
|
201
|
+
it 'prints the class for non-direct subclasses of ActiveRecord::Base' do
|
232
202
|
out = @ap.awesome(SubUser)
|
233
203
|
expect(out).to eq <<~EOS.strip
|
234
204
|
class SubUser < User {
|
@@ -241,11 +211,11 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
|
|
241
211
|
EOS
|
242
212
|
end
|
243
213
|
|
244
|
-
it '
|
214
|
+
it 'prints ActiveRecord::Base objects (ex. ancestors)' do
|
245
215
|
expect { @ap.awesome(User.ancestors) }.not_to raise_error
|
246
216
|
end
|
247
217
|
|
248
|
-
it '
|
218
|
+
it 'prints valid HTML for subclasses' do
|
249
219
|
@ap = AmazingPrint::Inspector.new(html: true)
|
250
220
|
expect(@ap.awesome(SubUser)).to match('SubUser < User')
|
251
221
|
end
|
@@ -257,7 +227,7 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
|
|
257
227
|
@ap = AmazingPrint::Inspector.new(plain: true)
|
258
228
|
end
|
259
229
|
|
260
|
-
it '
|
230
|
+
it 'formats class methods properly' do
|
261
231
|
# spec 1
|
262
232
|
out = @ap.awesome(User.methods.grep(/first/))
|
263
233
|
|
@@ -266,24 +236,24 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
|
|
266
236
|
expect(out).to match(
|
267
237
|
/\s+first\(\*args,\s&block\)\s+#<Class:\w+>\s+\(ActiveRecord::Querying\)/
|
268
238
|
)
|
269
|
-
elsif RUBY_VERSION >= '3.
|
239
|
+
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0')
|
240
|
+
expect(out).to match(
|
241
|
+
/\s*first\(\*(\*|args),\s+\?,\s+&(&|block)\)\s+#<Class:User> \(ActiveRecord::Querying\)/
|
242
|
+
)
|
243
|
+
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
|
270
244
|
expect(out).to match(
|
271
245
|
/\s*first\(\*(\*|args),\s+&(&|block)\)\s+#<Class:User> \(ActiveRecord::Querying\)/
|
272
246
|
)
|
273
|
-
elsif RUBY_VERSION >= '2.7.2'
|
247
|
+
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.2')
|
274
248
|
expect(out).to match(
|
275
249
|
/\s*first\(\*(\*|args),\s+&(&|block)\)\s+User/
|
276
250
|
)
|
277
|
-
elsif RUBY_VERSION >= '2.7
|
251
|
+
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.7')
|
278
252
|
expect(out).to match(
|
279
253
|
/\s*first\(\*(\*|args),\s+&(&|block)\)\s+#<Class:ActiveRecord::Base> \(ActiveRecord::Querying\)/
|
280
254
|
)
|
281
|
-
elsif RUBY_VERSION
|
255
|
+
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.4.4')
|
282
256
|
expect(out).to match(/\sfirst\(\*arg.*?\)\s+User/)
|
283
|
-
elsif RUBY_VERSION >= '1.9'
|
284
|
-
expect(out).to match(/\sfirst\(\*args,\s&block\)\s+Class \(ActiveRecord::Querying\)/)
|
285
|
-
else
|
286
|
-
expect(out).to match(/\sfirst\(\*arg1\)\s+Class \(ActiveRecord::Querying\)/)
|
287
257
|
end
|
288
258
|
else
|
289
259
|
expect(out).to match(/\sfirst\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/)
|
@@ -295,16 +265,16 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
|
|
295
265
|
expect(out).to match(
|
296
266
|
/\sprimary_key\(.*?\)\s+#<Class:\w+>\s\(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/
|
297
267
|
)
|
298
|
-
elsif RUBY_VERSION >= '3.0.0'
|
268
|
+
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
|
299
269
|
expect(out).to match(/\sprimary_key\(.*?\)\s+#<Class:User> \(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/)
|
300
|
-
elsif RUBY_VERSION
|
270
|
+
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.7') && Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7.0')
|
271
|
+
expect(out).to match(/\sprimary_key\(.*?\)\s+#<Class:ActiveRecord::Base> \(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/)
|
272
|
+
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.4.4') || Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.2')
|
273
|
+
expect(out).to match(/\sprimary_key\(.*?\)\s+User/)
|
274
|
+
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
|
301
275
|
expect(out).to match(
|
302
276
|
/\sprimary_key\(.*?\)\s+.+Class.+\(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/
|
303
277
|
)
|
304
|
-
elsif RUBY_VERSION =~ /^2\.4\.([4-9]|[1-9][0-9])|^2\.[56]\./ || RUBY_VERSION >= '2.7.2'
|
305
|
-
expect(out).to match(/\sprimary_key\(.*?\)\s+User/)
|
306
|
-
else
|
307
|
-
expect(out).to match(/\sprimary_key\(.*?\)\s+Class \(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/)
|
308
278
|
end
|
309
279
|
|
310
280
|
# spec 3
|
@@ -312,20 +282,16 @@ RSpec.describe 'AmazingPrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }
|
|
312
282
|
|
313
283
|
if ActiveRecord::VERSION::MAJOR < 3
|
314
284
|
expect(out).to match(/\svalidate\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/)
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
expect(out).to match(/\svalidate\(\*arg.*?\)\s+User/)
|
326
|
-
else
|
327
|
-
expect(out).to match(/\svalidate\(\*arg.*?\)\s+Class \(ActiveModel::Validations::ClassMethods\)/)
|
328
|
-
end
|
285
|
+
elsif RUBY_PLATFORM == 'java'
|
286
|
+
expect(out).to match(/\svalidate\(\*arg.*?\)\s+#<Class:\w+> \(ActiveModel::Validations::ClassMethods\)/)
|
287
|
+
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
|
288
|
+
expect(out).to match(/\svalidate\(\*arg.*?\)\s+#<Class:User> \(ActiveModel::Validations::ClassMethods\)/)
|
289
|
+
elsif (Gem::Version.new('2.6.7')..Gem::Version.new('2.7.1')).cover? Gem::Version.new(RUBY_VERSION)
|
290
|
+
expect(out).to match(
|
291
|
+
/\svalidate\(\*args.*?\)\s+#<Class:ActiveRecord::Base> \(ActiveModel::Validations::ClassMethods\)/
|
292
|
+
)
|
293
|
+
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.4.4') || Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.2')
|
294
|
+
expect(out).to match(/\svalidate\(\*arg.*?\)\s+User/)
|
329
295
|
end
|
330
296
|
end
|
331
297
|
end
|
@@ -15,21 +15,21 @@ RSpec.describe 'AmazingPrint::ActiveSupport', skip: -> { !ExtVerifier.has_rails?
|
|
15
15
|
@ap = AmazingPrint::Inspector.new
|
16
16
|
end
|
17
17
|
|
18
|
-
it '
|
18
|
+
it 'formats ActiveSupport::TimeWithZone as regular Time' do
|
19
19
|
Time.zone = 'Eastern Time (US & Canada)'
|
20
20
|
time = Time.utc(2007, 2, 10, 20, 30, 45).in_time_zone
|
21
21
|
expect(@ap.send(:awesome, time))
|
22
22
|
.to eq("\e[0;32mSat, 10 Feb 2007 #{expected_ar_time_str} EST -05:00\e[0m")
|
23
23
|
end
|
24
24
|
|
25
|
-
it '
|
25
|
+
it 'formats HashWithIndifferentAccess as regular Hash' do
|
26
26
|
hash = HashWithIndifferentAccess.new({ hello: 'world' })
|
27
27
|
expect(@ap.send(:awesome, hash)).to eq("{\n \"hello\"\e[0;37m => \e[0m\e[0;33m\"world\"\e[0m\n}")
|
28
28
|
end
|
29
29
|
|
30
30
|
# ActiveSupport sticks in instance variables to the date object. Make sure
|
31
31
|
# we ignore that and format Date instance as regular date.
|
32
|
-
it '
|
32
|
+
it 'formates Date object as date' do
|
33
33
|
date = Date.new(2003, 5, 26)
|
34
34
|
expect(date.ai(plain: true)).to eq('Mon, 26 May 2003')
|
35
35
|
expect(date.ai).to eq("\e[0;32mMon, 26 May 2003\e[0m")
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# rubocop:disable Lint/ConstantDefinitionInBlock
|
4
|
+
|
3
5
|
require 'spec_helper'
|
4
6
|
|
5
7
|
RSpec.describe 'AmazingPrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_mapper? }.call do
|
@@ -27,11 +29,11 @@ RSpec.describe 'AmazingPrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_map
|
|
27
29
|
# before { @ap.options[:raw] = true }
|
28
30
|
before { @ap = AmazingPrint::Inspector.new(plain: true, sort_keys: true, raw: true) }
|
29
31
|
|
30
|
-
it '
|
32
|
+
it 'prints class instance' do
|
31
33
|
user = MongoUser.new(first_name: 'Al', last_name: 'Capone')
|
32
34
|
|
33
35
|
out = @ap.send(:awesome, user)
|
34
|
-
.gsub(
|
36
|
+
.gsub(/#<Proc:.+?>/, 'amazing_print_PROC_STUB')
|
35
37
|
.gsub(/BSON::ObjectId\('[\da-f]+?'\)/, "BSON::ObjectId('123456789')")
|
36
38
|
|
37
39
|
str = if MongoMapper::Version >= '0.13'
|
@@ -129,7 +131,7 @@ RSpec.describe 'AmazingPrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_map
|
|
129
131
|
expect(out).to be_similar_to(str)
|
130
132
|
end
|
131
133
|
|
132
|
-
it '
|
134
|
+
it 'prints the class' do
|
133
135
|
expect(@ap.send(:awesome, MongoUser)).to eq <<~EOS.strip
|
134
136
|
class MongoUser < Object {
|
135
137
|
"_id" => :object_id,
|
@@ -139,7 +141,7 @@ RSpec.describe 'AmazingPrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_map
|
|
139
141
|
EOS
|
140
142
|
end
|
141
143
|
|
142
|
-
it '
|
144
|
+
it 'prints the class when type is undefined' do
|
143
145
|
class Chamelion
|
144
146
|
include MongoMapper::Document
|
145
147
|
key :last_attribute
|
@@ -178,7 +180,7 @@ RSpec.describe 'AmazingPrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_map
|
|
178
180
|
end
|
179
181
|
|
180
182
|
describe 'with show associations turned off (default)' do
|
181
|
-
it '
|
183
|
+
it 'renders the class as normal' do
|
182
184
|
expect(@ap.send(:awesome, Parent)).to eq <<~EOS.strip
|
183
185
|
class Parent < Object {
|
184
186
|
"_id" => :object_id,
|
@@ -187,7 +189,7 @@ RSpec.describe 'AmazingPrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_map
|
|
187
189
|
EOS
|
188
190
|
end
|
189
191
|
|
190
|
-
it '
|
192
|
+
it 'renders an instance as normal' do
|
191
193
|
parent = Parent.new(name: 'test')
|
192
194
|
out = @ap.send(:awesome, parent)
|
193
195
|
str = <<~EOS.strip
|
@@ -201,11 +203,11 @@ RSpec.describe 'AmazingPrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_map
|
|
201
203
|
end
|
202
204
|
|
203
205
|
describe 'with show associations turned on and inline embedded turned off' do
|
204
|
-
before
|
206
|
+
before do
|
205
207
|
@ap = AmazingPrint::Inspector.new(plain: true, mongo_mapper: { show_associations: true })
|
206
208
|
end
|
207
209
|
|
208
|
-
it '
|
210
|
+
it 'renders the class with associations shown' do
|
209
211
|
expect(@ap.send(:awesome, Parent)).to eq <<~EOS.strip
|
210
212
|
class Parent < Object {
|
211
213
|
"_id" => :object_id,
|
@@ -216,7 +218,7 @@ RSpec.describe 'AmazingPrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_map
|
|
216
218
|
EOS
|
217
219
|
end
|
218
220
|
|
219
|
-
it '
|
221
|
+
it 'renders an instance with associations shown' do
|
220
222
|
parent = Parent.new(name: 'test')
|
221
223
|
out = @ap.send(:awesome, parent)
|
222
224
|
str = <<~EOS.strip
|
@@ -232,7 +234,7 @@ RSpec.describe 'AmazingPrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_map
|
|
232
234
|
end
|
233
235
|
|
234
236
|
describe 'with show associations turned on and inline embedded turned on' do
|
235
|
-
before
|
237
|
+
before do
|
236
238
|
@ap = AmazingPrint::Inspector.new plain: true,
|
237
239
|
mongo_mapper: {
|
238
240
|
show_associations: true,
|
@@ -240,7 +242,7 @@ RSpec.describe 'AmazingPrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_map
|
|
240
242
|
}
|
241
243
|
end
|
242
244
|
|
243
|
-
it '
|
245
|
+
it 'renders an instance with associations shown and embeds there' do
|
244
246
|
parent = Parent.new(name: 'test', child: Child.new(data: 5))
|
245
247
|
out = @ap.send(:awesome, parent)
|
246
248
|
str = <<~EOS.strip
|
@@ -259,3 +261,5 @@ RSpec.describe 'AmazingPrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_map
|
|
259
261
|
end
|
260
262
|
end
|
261
263
|
end
|
264
|
+
|
265
|
+
# rubocop:enable Lint/ConstantDefinitionInBlock
|
data/spec/ext/mongoid_spec.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# rubocop:disable Lint/ConstantDefinitionInBlock
|
4
|
+
|
3
5
|
require 'spec_helper'
|
4
6
|
|
5
7
|
RSpec.describe 'AmazingPrint/Mongoid', skip: -> { !ExtVerifier.has_mongoid? }.call do
|
@@ -23,7 +25,7 @@ RSpec.describe 'AmazingPrint/Mongoid', skip: -> { !ExtVerifier.has_mongoid? }.ca
|
|
23
25
|
@ap = AmazingPrint::Inspector.new plain: true, sort_keys: true
|
24
26
|
end
|
25
27
|
|
26
|
-
it '
|
28
|
+
it 'prints class instance' do
|
27
29
|
user = MongoUser.new first_name: 'Al', last_name: 'Capone'
|
28
30
|
out = @ap.send :awesome, user
|
29
31
|
|
@@ -38,7 +40,7 @@ RSpec.describe 'AmazingPrint/Mongoid', skip: -> { !ExtVerifier.has_mongoid? }.ca
|
|
38
40
|
expect(out).to be_similar_to(str, { skip_bson: true })
|
39
41
|
end
|
40
42
|
|
41
|
-
it '
|
43
|
+
it 'prints the class' do
|
42
44
|
class_spec = <<~EOS.strip
|
43
45
|
class MongoUser < Object {
|
44
46
|
:_id => :"bson/object_id",
|
@@ -50,7 +52,7 @@ RSpec.describe 'AmazingPrint/Mongoid', skip: -> { !ExtVerifier.has_mongoid? }.ca
|
|
50
52
|
expect(@ap.send(:awesome, MongoUser)).to eq class_spec
|
51
53
|
end
|
52
54
|
|
53
|
-
it '
|
55
|
+
it 'prints the class when type is undefined' do
|
54
56
|
class Chamelion
|
55
57
|
include Mongoid::Document
|
56
58
|
field :last_attribute
|
@@ -66,3 +68,5 @@ RSpec.describe 'AmazingPrint/Mongoid', skip: -> { !ExtVerifier.has_mongoid? }.ca
|
|
66
68
|
expect(@ap.send(:awesome, Chamelion)).to eq class_spec
|
67
69
|
end
|
68
70
|
end
|
71
|
+
|
72
|
+
# rubocop:enable Lint/ConstantDefinitionInBlock
|
data/spec/ext/nobrainer_spec.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# rubocop:disable Lint/ConstantDefinitionInBlock
|
4
|
+
|
3
5
|
require 'spec_helper'
|
4
6
|
|
5
7
|
RSpec.describe 'AmazingPrint/NoBrainer', skip: -> { !ExtVerifier.has_nobrainer? }.call do
|
@@ -30,7 +32,7 @@ RSpec.describe 'AmazingPrint/NoBrainer', skip: -> { !ExtVerifier.has_nobrainer?
|
|
30
32
|
@ap = AmazingPrint::Inspector.new plain: true
|
31
33
|
end
|
32
34
|
|
33
|
-
it '
|
35
|
+
it 'prints class instance' do
|
34
36
|
user = SomeModel.new first_name: 'Al', last_name: 'Capone'
|
35
37
|
out = @ap.send :awesome, user
|
36
38
|
|
@@ -45,7 +47,7 @@ RSpec.describe 'AmazingPrint/NoBrainer', skip: -> { !ExtVerifier.has_nobrainer?
|
|
45
47
|
expect(out).to eq(str)
|
46
48
|
end
|
47
49
|
|
48
|
-
it '
|
50
|
+
it 'prints the class' do
|
49
51
|
class_spec = <<~EOS.strip
|
50
52
|
class SomeModel < Object {
|
51
53
|
:id => :string,
|
@@ -58,3 +60,5 @@ RSpec.describe 'AmazingPrint/NoBrainer', skip: -> { !ExtVerifier.has_nobrainer?
|
|
58
60
|
expect(@ap.send(:awesome, SomeModel)).to eq class_spec
|
59
61
|
end
|
60
62
|
end
|
63
|
+
|
64
|
+
# rubocop:enable Lint/ConstantDefinitionInBlock
|
data/spec/ext/nokogiri_spec.rb
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe 'AmazingPrint/Nokogiri' do
|
6
|
-
it '
|
6
|
+
it 'colorizes tags' do
|
7
7
|
xml = Nokogiri::XML('<html><body><h1></h1></body></html>')
|
8
8
|
# FIXME: Due to something strange with Nokogiri and JRuby, we need to remove extra blank lines.
|
9
9
|
output = xml.ai.gsub(/\n\n/, "\n")
|
10
10
|
expect(output).to eq <<~EOS
|
11
|
-
<?xml version
|
11
|
+
<?xml version="1.0"?>\e[1;32m
|
12
12
|
\e[0m<\e[1;36mhtml\e[0m>\e[1;32m
|
13
13
|
\e[0m<\e[1;36mbody\e[0m>\e[1;32m
|
14
14
|
\e[0m<\e[1;36mh1\e[0m/>\e[1;32m
|
@@ -17,10 +17,10 @@ RSpec.describe 'AmazingPrint/Nokogiri' do
|
|
17
17
|
EOS
|
18
18
|
end
|
19
19
|
|
20
|
-
it '
|
20
|
+
it 'colorizes contents' do
|
21
21
|
xml = Nokogiri::XML('<html><body><h1>Hello</h1></body></html>')
|
22
22
|
expect(xml.ai).to eq <<~EOS
|
23
|
-
<?xml version
|
23
|
+
<?xml version="1.0"?>\e[1;32m
|
24
24
|
\e[0m<\e[1;36mhtml\e[0m>\e[1;32m
|
25
25
|
\e[0m<\e[1;36mbody\e[0m>\e[1;32m
|
26
26
|
\e[0m<\e[1;36mh1\e[0m>\e[1;32mHello\e[0m<\e[1;36m/h1\e[0m>\e[1;32m
|
@@ -29,16 +29,16 @@ RSpec.describe 'AmazingPrint/Nokogiri' do
|
|
29
29
|
EOS
|
30
30
|
end
|
31
31
|
|
32
|
-
it '
|
32
|
+
it 'colorizes class and id' do
|
33
33
|
xml = Nokogiri::XML('<html><body><h1><span class="world" id="hello"></span></h1></body></html>')
|
34
34
|
# FIXME: Due to something strange with Nokogiri and JRuby, we need to remove extra blank lines.
|
35
35
|
output = xml.ai.gsub(/\n\n/, "\n")
|
36
36
|
expect(output).to eq <<~EOS
|
37
|
-
<?xml version
|
37
|
+
<?xml version="1.0"?>\e[1;32m
|
38
38
|
\e[0m<\e[1;36mhtml\e[0m>\e[1;32m
|
39
39
|
\e[0m<\e[1;36mbody\e[0m>\e[1;32m
|
40
40
|
\e[0m<\e[1;36mh1\e[0m>\e[1;32m
|
41
|
-
\e[0m<\e[1;36mspan\e[0m \e[1;33mclass
|
41
|
+
\e[0m<\e[1;36mspan\e[0m \e[1;33mclass="world"\e[0m \e[1;33mid="hello"\e[0m/>\e[1;32m
|
42
42
|
\e[0m<\e[1;36m/h1\e[0m>\e[1;32m
|
43
43
|
\e[0m<\e[1;36m/body\e[0m>\e[1;32m
|
44
44
|
\e[0m<\e[1;36m/html\e[0m>
|
data/spec/ext/ripple_spec.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# rubocop:disable Lint/ConstantDefinitionInBlock
|
4
|
+
|
3
5
|
require 'spec_helper'
|
4
6
|
|
5
7
|
RSpec.describe 'AmazingPrint/Ripple', skip: -> { !ExtVerifier.has_ripple? }.call do
|
@@ -24,7 +26,7 @@ RSpec.describe 'AmazingPrint/Ripple', skip: -> { !ExtVerifier.has_ripple? }.call
|
|
24
26
|
@ap = AmazingPrint::Inspector.new plain: true, sort_keys: true
|
25
27
|
end
|
26
28
|
|
27
|
-
it '
|
29
|
+
it 'prints class instance' do
|
28
30
|
user = RippleUser.new _id: '12345', first_name: 'Al', last_name: 'Capone'
|
29
31
|
out = @ap.send :awesome, user
|
30
32
|
|
@@ -37,7 +39,7 @@ RSpec.describe 'AmazingPrint/Ripple', skip: -> { !ExtVerifier.has_ripple? }.call
|
|
37
39
|
EOS
|
38
40
|
end
|
39
41
|
|
40
|
-
it '
|
42
|
+
it 'prints the class' do
|
41
43
|
expect(@ap.send(:awesome, RippleUser)).to eq <<~EOS.strip
|
42
44
|
class RippleUser < Object {
|
43
45
|
:_id => :string,
|
@@ -47,3 +49,5 @@ RSpec.describe 'AmazingPrint/Ripple', skip: -> { !ExtVerifier.has_ripple? }.call
|
|
47
49
|
EOS
|
48
50
|
end
|
49
51
|
end
|
52
|
+
|
53
|
+
# rubocop:enable Lint/ConstantDefinitionInBlock
|
data/spec/ext/sequel_spec.rb
CHANGED
@@ -39,7 +39,7 @@ RSpec.describe 'AmazingPrint/Sequel', skip: -> { !ExtVerifier.has_sequel? }.call
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'does not crash if on Sequel::Model' do
|
42
|
-
out = @ap.awesome(
|
42
|
+
out = @ap.awesome(Sequel::Model)
|
43
43
|
expect(out).to be_similar_to('Sequel::Model < Object')
|
44
44
|
end
|
45
45
|
end
|