amazing_print 1.6.0 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -2
  3. data/lib/amazing_print/ext/active_record.rb +32 -2
  4. data/lib/amazing_print/ext/nobrainer.rb +2 -2
  5. data/lib/amazing_print/formatters/base_formatter.rb +5 -1
  6. data/lib/amazing_print/formatters/hash_formatter.rb +29 -9
  7. data/lib/amazing_print/formatters/mswin_helper.rb +4 -4
  8. data/lib/amazing_print/formatters/object_formatter.rb +1 -1
  9. data/lib/amazing_print/formatters/struct_formatter.rb +1 -1
  10. data/lib/amazing_print/inspector.rb +1 -1
  11. data/lib/amazing_print/version.rb +1 -1
  12. metadata +6 -63
  13. data/.gitignore +0 -35
  14. data/Appraisals +0 -66
  15. data/Gemfile +0 -18
  16. data/Gemfile.lock +0 -94
  17. data/LICENSE +0 -22
  18. data/Rakefile +0 -25
  19. data/spec/active_record_helper.rb +0 -43
  20. data/spec/colors_spec.rb +0 -120
  21. data/spec/core_ext/logger_spec.rb +0 -70
  22. data/spec/ext/action_controller_spec.rb +0 -40
  23. data/spec/ext/action_view_spec.rb +0 -24
  24. data/spec/ext/active_model_spec.rb +0 -37
  25. data/spec/ext/active_record_spec.rb +0 -302
  26. data/spec/ext/active_support_spec.rb +0 -37
  27. data/spec/ext/mongo_mapper_spec.rb +0 -265
  28. data/spec/ext/mongoid_spec.rb +0 -135
  29. data/spec/ext/nobrainer_spec.rb +0 -64
  30. data/spec/ext/nokogiri_spec.rb +0 -52
  31. data/spec/ext/ostruct_spec.rb +0 -24
  32. data/spec/ext/ripple_spec.rb +0 -53
  33. data/spec/ext/sequel_spec.rb +0 -45
  34. data/spec/formats_spec.rb +0 -795
  35. data/spec/methods_spec.rb +0 -520
  36. data/spec/misc_spec.rb +0 -206
  37. data/spec/objects_spec.rb +0 -225
  38. data/spec/sequel_helper.rb +0 -18
  39. data/spec/spec_helper.rb +0 -112
  40. data/spec/support/active_record_data/3_2_diana.txt +0 -24
  41. data/spec/support/active_record_data/3_2_diana_legacy.txt +0 -24
  42. data/spec/support/active_record_data/3_2_multi.txt +0 -50
  43. data/spec/support/active_record_data/3_2_multi_legacy.txt +0 -50
  44. data/spec/support/active_record_data/4_0_diana.txt +0 -98
  45. data/spec/support/active_record_data/4_0_multi.txt +0 -198
  46. data/spec/support/active_record_data/4_1_diana.txt +0 -97
  47. data/spec/support/active_record_data/4_1_multi.txt +0 -196
  48. data/spec/support/active_record_data/4_2_diana.txt +0 -109
  49. data/spec/support/active_record_data/4_2_diana_legacy.txt +0 -109
  50. data/spec/support/active_record_data/4_2_multi.txt +0 -220
  51. data/spec/support/active_record_data/4_2_multi_legacy.txt +0 -220
  52. data/spec/support/active_record_data/5_0_diana.txt +0 -105
  53. data/spec/support/active_record_data/5_0_multi.txt +0 -212
  54. data/spec/support/active_record_data/5_1_diana.txt +0 -104
  55. data/spec/support/active_record_data/5_1_multi.txt +0 -210
  56. data/spec/support/active_record_data/5_2_diana.txt +0 -104
  57. data/spec/support/active_record_data/5_2_multi.txt +0 -210
  58. data/spec/support/active_record_data/6_0_diana.txt +0 -104
  59. data/spec/support/active_record_data/6_0_multi.txt +0 -210
  60. data/spec/support/active_record_data/6_1_diana.txt +0 -109
  61. data/spec/support/active_record_data/6_1_multi.txt +0 -220
  62. data/spec/support/active_record_data/7_0_diana.txt +0 -110
  63. data/spec/support/active_record_data/7_0_multi.txt +0 -222
  64. data/spec/support/active_record_data.rb +0 -22
  65. data/spec/support/ext_verifier.rb +0 -46
  66. data/spec/support/mongoid_versions.rb +0 -24
  67. data/spec/support/rails_versions.rb +0 -62
@@ -1,265 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # rubocop:disable Lint/ConstantDefinitionInBlock
4
-
5
- require 'spec_helper'
6
-
7
- RSpec.describe 'AmazingPrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_mapper? }.call do
8
- if ExtVerifier.has_mongo_mapper?
9
- before :all do
10
- class MongoUser
11
- include MongoMapper::Document
12
-
13
- key :first_name, String
14
- key :last_name, String
15
- end
16
- end
17
-
18
- after :all do
19
- Object.instance_eval { remove_const :MongoUser }
20
- Object.instance_eval { remove_const :Chamelion }
21
- end
22
- end
23
-
24
- before do
25
- @ap = AmazingPrint::Inspector.new(plain: true, sort_keys: true)
26
- end
27
-
28
- describe 'with the raw option set to true' do
29
- # before { @ap.options[:raw] = true }
30
- before { @ap = AmazingPrint::Inspector.new(plain: true, sort_keys: true, raw: true) }
31
-
32
- it 'prints class instance' do
33
- user = MongoUser.new(first_name: 'Al', last_name: 'Capone')
34
-
35
- out = @ap.send(:awesome, user)
36
- .gsub(/#<Proc:.+?>/, 'amazing_print_PROC_STUB')
37
- .gsub(/BSON::ObjectId\('[\da-f]+?'\)/, "BSON::ObjectId('123456789')")
38
-
39
- str = if MongoMapper::Version >= '0.13'
40
- <<~EOS.strip
41
- #<MongoUser:placeholder_id
42
- @__mm_default_keys = [
43
- [0] #<MongoMapper::Plugins::Keys::Key:placeholder_id
44
- @dynamic = false,
45
- @embeddable = false,
46
- @has_default = true,
47
- @is_id = true,
48
- @typecast = nil,
49
- attr_accessor :accessors = [],
50
- attr_accessor :default = amazing_print_PROC_STUB,
51
- attr_accessor :ivar = :@_id,
52
- attr_accessor :name = "_id",
53
- attr_accessor :options = {
54
- :default => amazing_print_PROC_STUB
55
- },
56
- attr_accessor :type = ObjectId < Object
57
- >
58
- ],
59
- @__mm_keys = {
60
- "_id" => #<MongoMapper::Plugins::Keys::Key:placeholder_id
61
- @dynamic = false,
62
- @embeddable = false,
63
- @has_default = true,
64
- @is_id = true,
65
- @typecast = nil,
66
- attr_accessor :accessors = [],
67
- attr_accessor :default = amazing_print_PROC_STUB,
68
- attr_accessor :ivar = :@_id,
69
- attr_accessor :name = "_id",
70
- attr_accessor :options = {
71
- :default => amazing_print_PROC_STUB
72
- },
73
- attr_accessor :type = ObjectId < Object
74
- >,
75
- "first_name" => #<MongoMapper::Plugins::Keys::Key:placeholder_id
76
- @dynamic = false,
77
- @embeddable = false,
78
- @has_default = false,
79
- @is_id = false,
80
- @typecast = nil,
81
- attr_accessor :accessors = [],
82
- attr_accessor :ivar = :@first_name,
83
- attr_accessor :name = "first_name",
84
- attr_accessor :options = {},
85
- attr_accessor :type = String < Object
86
- >,
87
- "last_name" => #<MongoMapper::Plugins::Keys::Key:placeholder_id
88
- @dynamic = false,
89
- @embeddable = false,
90
- @has_default = false,
91
- @is_id = false,
92
- @typecast = nil,
93
- attr_accessor :accessors = [],
94
- attr_accessor :ivar = :@last_name,
95
- attr_accessor :name = "last_name",
96
- attr_accessor :options = {},
97
- attr_accessor :type = String < Object
98
- >
99
- },
100
- @__mm_pre_cast = {
101
- "first_name" => "Al",
102
- "last_name" => "Capone"
103
- },
104
- @_dynamic_attributes = {},
105
- @_new = true,
106
- attr_accessor :_id = BSON::ObjectId('123456789'),
107
- attr_accessor :attributes = nil,
108
- attr_accessor :first_name = "Al",
109
- attr_accessor :last_name = "Capone",
110
- attr_reader :changed_attributes = {
111
- "first_name" => nil,
112
- "last_name" => nil
113
- }
114
- >
115
- EOS
116
- else
117
- <<~EOS.strip
118
- #<MongoUser:placeholder_id
119
- @_new = true,
120
- attr_accessor :first_name = "Al",
121
- attr_accessor :last_name = "Capone",
122
- attr_reader :changed_attributes = {
123
- "first_name" => nil,
124
- "last_name" => nil
125
- },
126
- attr_reader :first_name_before_type_cast = "Al",
127
- attr_reader :last_name_before_type_cast = "Capone"
128
- >
129
- EOS
130
- end
131
- expect(out).to be_similar_to(str)
132
- end
133
-
134
- it 'prints the class' do
135
- expect(@ap.send(:awesome, MongoUser)).to eq <<~EOS.strip
136
- class MongoUser < Object {
137
- "_id" => :object_id,
138
- "first_name" => :string,
139
- "last_name" => :string
140
- }
141
- EOS
142
- end
143
-
144
- it 'prints the class when type is undefined' do
145
- class Chamelion
146
- include MongoMapper::Document
147
- key :last_attribute
148
- end
149
-
150
- expect(@ap.send(:awesome, Chamelion)).to eq <<~EOS.strip
151
- class Chamelion < Object {
152
- "_id" => :object_id,
153
- "last_attribute" => :undefined
154
- }
155
- EOS
156
- end
157
- end
158
-
159
- describe 'with associations' do
160
- if ExtVerifier.has_mongo_mapper?
161
- before :all do
162
- class Child
163
- include MongoMapper::EmbeddedDocument
164
- key :data
165
- end
166
-
167
- class Sibling
168
- include MongoMapper::Document
169
- key :title
170
- end
171
-
172
- class Parent
173
- include MongoMapper::Document
174
- key :name
175
-
176
- one :child
177
- one :sibling
178
- end
179
- end
180
- end
181
-
182
- describe 'with show associations turned off (default)' do
183
- it 'renders the class as normal' do
184
- expect(@ap.send(:awesome, Parent)).to eq <<~EOS.strip
185
- class Parent < Object {
186
- "_id" => :object_id,
187
- "name" => :undefined
188
- }
189
- EOS
190
- end
191
-
192
- it 'renders an instance as normal' do
193
- parent = Parent.new(name: 'test')
194
- out = @ap.send(:awesome, parent)
195
- str = <<~EOS.strip
196
- #<Parent:placeholder_id> {
197
- "_id" => placeholder_bson_id,
198
- "name" => "test"
199
- }
200
- EOS
201
- expect(out).to be_similar_to(str)
202
- end
203
- end
204
-
205
- describe 'with show associations turned on and inline embedded turned off' do
206
- before do
207
- @ap = AmazingPrint::Inspector.new(plain: true, mongo_mapper: { show_associations: true })
208
- end
209
-
210
- it 'renders the class with associations shown' do
211
- expect(@ap.send(:awesome, Parent)).to eq <<~EOS.strip
212
- class Parent < Object {
213
- "_id" => :object_id,
214
- "name" => :undefined,
215
- "child" => embeds one Child,
216
- "sibling" => one Sibling
217
- }
218
- EOS
219
- end
220
-
221
- it 'renders an instance with associations shown' do
222
- parent = Parent.new(name: 'test')
223
- out = @ap.send(:awesome, parent)
224
- str = <<~EOS.strip
225
- #<Parent:placeholder_id> {
226
- "_id" => placeholder_bson_id,
227
- "name" => "test",
228
- "child" => embeds one Child,
229
- "sibling" => one Sibling
230
- }
231
- EOS
232
- expect(out).to be_similar_to(str)
233
- end
234
- end
235
-
236
- describe 'with show associations turned on and inline embedded turned on' do
237
- before do
238
- @ap = AmazingPrint::Inspector.new plain: true,
239
- mongo_mapper: {
240
- show_associations: true,
241
- inline_embedded: true
242
- }
243
- end
244
-
245
- it 'renders an instance with associations shown and embeds there' do
246
- parent = Parent.new(name: 'test', child: Child.new(data: 5))
247
- out = @ap.send(:awesome, parent)
248
- str = <<~EOS.strip
249
- #<Parent:placeholder_id> {
250
- "_id" => placeholder_bson_id,
251
- "name" => "test",
252
- "child" => embedded #<Child:placeholder_id> {
253
- "_id" => placeholder_bson_id,
254
- "data" => 5
255
- },
256
- "sibling" => one Sibling
257
- }
258
- EOS
259
- expect(out).to be_similar_to(str)
260
- end
261
- end
262
- end
263
- end
264
-
265
- # rubocop:enable Lint/ConstantDefinitionInBlock
@@ -1,135 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # rubocop:disable Lint/ConstantDefinitionInBlock
4
-
5
- require 'spec_helper'
6
-
7
- RSpec.describe 'AmazingPrint/Mongoid', skip: -> { !ExtVerifier.has_mongoid? }.call do
8
- before do
9
- @ap = AmazingPrint::Inspector.new plain: true, sort_keys: true
10
- end
11
-
12
- describe 'Document' do
13
- if ExtVerifier.has_mongoid?
14
- before :all do
15
- class MongoUser
16
- include Mongoid::Document
17
-
18
- field :first_name, type: String
19
- field :last_name, type: String
20
- end
21
- end
22
-
23
- after :all do
24
- Object.instance_eval { remove_const :MongoUser }
25
- Object.instance_eval { remove_const :Chamelion }
26
- end
27
- end
28
-
29
- it 'prints class instance' do
30
- user = MongoUser.new first_name: 'Al', last_name: 'Capone'
31
- out = @ap.send :awesome, user
32
-
33
- object_id = user.id.inspect
34
- str = <<~EOS.strip
35
- #<MongoUser:placeholder_id> {
36
- :_id => #{object_id},
37
- :first_name => "Al",
38
- :last_name => "Capone"
39
- }
40
- EOS
41
- expect(out).to be_similar_to(str, { skip_bson: true })
42
- end
43
-
44
- it 'prints the class' do
45
- class_spec = <<~EOS.strip
46
- class MongoUser < Object {
47
- :_id => :"bson/object_id",
48
- :first_name => :string,
49
- :last_name => :string
50
- }
51
- EOS
52
-
53
- expect(@ap.send(:awesome, MongoUser)).to eq class_spec
54
- end
55
-
56
- it 'prints the class when type is undefined' do
57
- class Chamelion
58
- include Mongoid::Document
59
- field :last_attribute
60
- end
61
-
62
- class_spec = <<~EOS.strip
63
- class Chamelion < Object {
64
- :_id => :"bson/object_id",
65
- :last_attribute => :object
66
- }
67
- EOS
68
-
69
- expect(@ap.send(:awesome, Chamelion)).to eq class_spec
70
- end
71
- end
72
-
73
- describe 'Document with aliased fields' do
74
- if ExtVerifier.has_mongoid?
75
- before :all do
76
- class MongoUser
77
- include Mongoid::Document
78
-
79
- field :fn, as: :first_name, type: String
80
- field :ln, as: :last_name, type: String
81
- end
82
- end
83
-
84
- after :all do
85
- Object.instance_eval { remove_const :MongoUser }
86
- Object.instance_eval { remove_const :Chamelion }
87
- end
88
- end
89
-
90
- it 'prints class instance' do
91
- user = MongoUser.new first_name: 'Al', last_name: 'Capone'
92
- out = @ap.send :awesome, user
93
-
94
- object_id = user.id.inspect
95
- str = <<~EOS.strip
96
- #<MongoUser:placeholder_id> {
97
- :_id => #{object_id},
98
- :"first_name(fn)" => "Al",
99
- :"last_name(ln)" => "Capone"
100
- }
101
- EOS
102
- expect(out).to be_similar_to(str, { skip_bson: true })
103
- end
104
-
105
- it 'prints the class' do
106
- class_spec = <<~EOS.strip
107
- class MongoUser < Object {
108
- :_id => :"bson/object_id",
109
- :"first_name(fn)" => :string,
110
- :"last_name(ln)" => :string
111
- }
112
- EOS
113
-
114
- expect(@ap.send(:awesome, MongoUser)).to eq class_spec
115
- end
116
-
117
- it 'prints the class when type is undefined' do
118
- class Chamelion
119
- include Mongoid::Document
120
- field :la, as: :last_attribute
121
- end
122
-
123
- class_spec = <<~EOS.strip
124
- class Chamelion < Object {
125
- :_id => :"bson/object_id",
126
- :"last_attribute(la)" => :object
127
- }
128
- EOS
129
-
130
- expect(@ap.send(:awesome, Chamelion)).to eq class_spec
131
- end
132
- end
133
- end
134
-
135
- # rubocop:enable Lint/ConstantDefinitionInBlock
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # rubocop:disable Lint/ConstantDefinitionInBlock
4
-
5
- require 'spec_helper'
6
-
7
- RSpec.describe 'AmazingPrint/NoBrainer', skip: -> { !ExtVerifier.has_nobrainer? }.call do
8
- if ExtVerifier.has_nobrainer?
9
- before :all do
10
- NoBrainer.configure do |config|
11
- config.app_name = 'ap_test'
12
- config.environment = :test
13
- end
14
- end
15
-
16
- before :all do
17
- class SomeModel
18
- include NoBrainer::Document
19
-
20
- field :first_name, type: String
21
- field :last_name, type: String
22
- field :some_field
23
- end
24
- end
25
-
26
- after :all do
27
- Object.instance_eval { remove_const :SomeModel }
28
- end
29
- end
30
-
31
- before do
32
- @ap = AmazingPrint::Inspector.new plain: true
33
- end
34
-
35
- it 'prints class instance' do
36
- user = SomeModel.new first_name: 'Al', last_name: 'Capone'
37
- out = @ap.send :awesome, user
38
-
39
- object_id = user.id.inspect
40
- str = <<~EOS.strip
41
- #<SomeModel id: #{object_id}> {
42
- :id => #{object_id},
43
- :first_name => "Al",
44
- :last_name => "Capone"
45
- }
46
- EOS
47
- expect(out).to eq(str)
48
- end
49
-
50
- it 'prints the class' do
51
- class_spec = <<~EOS.strip
52
- class SomeModel < Object {
53
- :id => :string,
54
- :first_name => :string,
55
- :last_name => :string,
56
- :some_field => :object
57
- }
58
- EOS
59
-
60
- expect(@ap.send(:awesome, SomeModel)).to eq class_spec
61
- end
62
- end
63
-
64
- # rubocop:enable Lint/ConstantDefinitionInBlock
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe 'AmazingPrint/Nokogiri' do
6
- it 'colorizes tags' do
7
- xml = Nokogiri::XML('<html><body><h1></h1></body></html>')
8
- # FIXME: Due to something strange with Nokogiri and JRuby, we need to remove extra blank lines.
9
- output = xml.ai.gsub("\n\n", "\n")
10
- expect(output).to eq <<~EOS
11
- <?xml version="1.0"?>\e[1;32m
12
- \e[0m<\e[1;36mhtml\e[0m>\e[1;32m
13
- \e[0m<\e[1;36mbody\e[0m>\e[1;32m
14
- \e[0m<\e[1;36mh1\e[0m/>\e[1;32m
15
- \e[0m<\e[1;36m/body\e[0m>\e[1;32m
16
- \e[0m<\e[1;36m/html\e[0m>
17
- EOS
18
- end
19
-
20
- it 'colorizes contents' do
21
- xml = Nokogiri::XML('<html><body><h1>Hello</h1></body></html>')
22
- expect(xml.ai).to eq <<~EOS
23
- <?xml version="1.0"?>\e[1;32m
24
- \e[0m<\e[1;36mhtml\e[0m>\e[1;32m
25
- \e[0m<\e[1;36mbody\e[0m>\e[1;32m
26
- \e[0m<\e[1;36mh1\e[0m>\e[1;32mHello\e[0m<\e[1;36m/h1\e[0m>\e[1;32m
27
- \e[0m<\e[1;36m/body\e[0m>\e[1;32m
28
- \e[0m<\e[1;36m/html\e[0m>
29
- EOS
30
- end
31
-
32
- it 'colorizes class and id' do
33
- xml = Nokogiri::XML('<html><body><h1><span class="world" id="hello"></span></h1></body></html>')
34
- # FIXME: Due to something strange with Nokogiri and JRuby, we need to remove extra blank lines.
35
- output = xml.ai.gsub("\n\n", "\n")
36
- expect(output).to eq <<~EOS
37
- <?xml version="1.0"?>\e[1;32m
38
- \e[0m<\e[1;36mhtml\e[0m>\e[1;32m
39
- \e[0m<\e[1;36mbody\e[0m>\e[1;32m
40
- \e[0m<\e[1;36mh1\e[0m>\e[1;32m
41
- \e[0m<\e[1;36mspan\e[0m \e[1;33mclass="world"\e[0m \e[1;33mid="hello"\e[0m/>\e[1;32m
42
- \e[0m<\e[1;36m/h1\e[0m>\e[1;32m
43
- \e[0m<\e[1;36m/body\e[0m>\e[1;32m
44
- \e[0m<\e[1;36m/html\e[0m>
45
- EOS
46
- end
47
-
48
- it 'handle empty NodeSet' do
49
- xml = Nokogiri::XML::NodeSet.new(Nokogiri::XML(''))
50
- expect(xml.ai).to eq('[]')
51
- end
52
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe 'AmazingPrint Ostruct extension' do
6
- before do
7
- @ap = AmazingPrint::Inspector.new(plain: true, sort_keys: true)
8
- end
9
-
10
- it 'empty hash' do
11
- struct = OpenStruct.new
12
- expect(@ap.send(:awesome, struct)).to eq('OpenStruct {}')
13
- end
14
-
15
- it 'plain multiline' do
16
- struct = OpenStruct.new name: 'Foo', address: 'Bar'
17
- expect(@ap.send(:awesome, struct)).to eq <<~EOS.strip
18
- OpenStruct {
19
- :address => "Bar",
20
- :name => "Foo"
21
- }
22
- EOS
23
- end
24
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # rubocop:disable Lint/ConstantDefinitionInBlock
4
-
5
- require 'spec_helper'
6
-
7
- RSpec.describe 'AmazingPrint/Ripple', skip: -> { !ExtVerifier.has_ripple? }.call do
8
- if ExtVerifier.has_ripple?
9
- before :all do
10
- class RippleUser
11
- include Ripple::Document
12
-
13
- key_on :_id
14
- property :_id, String
15
- property :first_name, String
16
- property :last_name, String
17
- end
18
- end
19
-
20
- after :all do
21
- Object.instance_eval { remove_const :RippleUser }
22
- end
23
- end
24
-
25
- before do
26
- @ap = AmazingPrint::Inspector.new plain: true, sort_keys: true
27
- end
28
-
29
- it 'prints class instance' do
30
- user = RippleUser.new _id: '12345', first_name: 'Al', last_name: 'Capone'
31
- out = @ap.send :awesome, user
32
-
33
- expect(out).to be_similar_to <<~EOS.strip
34
- #<RippleUser:placeholder_id> {
35
- :_id => "12345",
36
- :first_name => "Al",
37
- :last_name => "Capone"
38
- }
39
- EOS
40
- end
41
-
42
- it 'prints the class' do
43
- expect(@ap.send(:awesome, RippleUser)).to eq <<~EOS.strip
44
- class RippleUser < Object {
45
- :_id => :string,
46
- :first_name => :string,
47
- :last_name => :string
48
- }
49
- EOS
50
- end
51
- end
52
-
53
- # rubocop:enable Lint/ConstantDefinitionInBlock
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'sequel_helper'
5
-
6
- RSpec.describe 'AmazingPrint/Sequel', skip: -> { !ExtVerifier.has_sequel? }.call do
7
- before do
8
- @ap = AmazingPrint::Inspector.new plain: true, sort_keys: true
9
- @user1 = SequelUser.new first_name: 'Jeremy', last_name: 'Evans'
10
- @user2 = SequelUser.new first_name: 'Sequel', last_name: 'Five'
11
- end
12
-
13
- it 'display single record' do
14
- out = @ap.awesome(@user1)
15
- str = <<~EOS.strip
16
- #<SequelUser:placeholder_id> {
17
- :first_name => "Jeremy",
18
- :last_name => "Evans"
19
- }
20
- EOS
21
- expect(out).to be_similar_to(str)
22
- end
23
-
24
- it 'display multiple records' do
25
- out = @ap.awesome([@user1, @user2])
26
- str = <<~EOS.strip
27
- [
28
- [0] #<SequelUser:placeholder_id> {
29
- :first_name => "Jeremy",
30
- :last_name => "Evans"
31
- },
32
- [1] #<SequelUser:placeholder_id> {
33
- :first_name => "Sequel",
34
- :last_name => "Five"
35
- }
36
- ]
37
- EOS
38
- expect(out).to be_similar_to(str)
39
- end
40
-
41
- it 'does not crash if on Sequel::Model' do
42
- out = @ap.awesome(Sequel::Model)
43
- expect(out).to be_similar_to('Sequel::Model < Object')
44
- end
45
- end