representable 3.3.1 → 3.4.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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +6 -0
  3. data/Gemfile +0 -1
  4. data/README.md +1 -7
  5. data/lib/representable/json.rb +11 -14
  6. data/lib/representable/version.rb +1 -1
  7. data/representable.gemspec +1 -2
  8. metadata +1 -60
  9. data/test/as_test.rb +0 -60
  10. data/test/benchmarking.rb +0 -78
  11. data/test/binding_test.rb +0 -54
  12. data/test/cached_test.rb +0 -177
  13. data/test/class_test.rb +0 -132
  14. data/test/coercion_test.rb +0 -73
  15. data/test/config/inherit_test.rb +0 -130
  16. data/test/config_test.rb +0 -120
  17. data/test/decorator_scope_test.rb +0 -30
  18. data/test/decorator_test.rb +0 -109
  19. data/test/default_test.rb +0 -34
  20. data/test/defaults_options_test.rb +0 -121
  21. data/test/definition_test.rb +0 -253
  22. data/test/examples/example.rb +0 -314
  23. data/test/examples/object.rb +0 -28
  24. data/test/exec_context_test.rb +0 -88
  25. data/test/features_test.rb +0 -89
  26. data/test/filter_test.rb +0 -66
  27. data/test/for_collection_test.rb +0 -71
  28. data/test/generic_test.rb +0 -109
  29. data/test/getter_setter_test.rb +0 -26
  30. data/test/hash_bindings_test.rb +0 -96
  31. data/test/hash_test.rb +0 -197
  32. data/test/heritage_test.rb +0 -64
  33. data/test/if_test.rb +0 -83
  34. data/test/include_exclude_test.rb +0 -96
  35. data/test/inherit_test.rb +0 -246
  36. data/test/inline_test.rb +0 -281
  37. data/test/instance_test.rb +0 -289
  38. data/test/is_representable_test.rb +0 -79
  39. data/test/json_test.rb +0 -379
  40. data/test/lonely_test.rb +0 -241
  41. data/test/nested_test.rb +0 -112
  42. data/test/object_test.rb +0 -60
  43. data/test/option_test.rb +0 -38
  44. data/test/parse_pipeline_test.rb +0 -68
  45. data/test/pipeline_test.rb +0 -309
  46. data/test/populator_test.rb +0 -108
  47. data/test/prepare_test.rb +0 -64
  48. data/test/private_options_test.rb +0 -19
  49. data/test/reader_writer_test.rb +0 -19
  50. data/test/realistic_benchmark.rb +0 -96
  51. data/test/render_nil_test.rb +0 -21
  52. data/test/represent_test.rb +0 -84
  53. data/test/representable_test.rb +0 -526
  54. data/test/schema_test.rb +0 -175
  55. data/test/serialize_deserialize_test.rb +0 -33
  56. data/test/skip_test.rb +0 -92
  57. data/test/stringify_hash_test.rb +0 -39
  58. data/test/test_helper.rb +0 -153
  59. data/test/test_helper_test.rb +0 -25
  60. data/test/uncategorized_test.rb +0 -72
  61. data/test/user_options_test.rb +0 -24
  62. data/test/wrap_test.rb +0 -162
  63. data/test/xml_assertions.rb +0 -29
  64. data/test/xml_bindings_test.rb +0 -55
  65. data/test/xml_namespace_test.rb +0 -193
  66. data/test/xml_test.rb +0 -584
  67. data/test/yaml_test.rb +0 -209
data/test/json_test.rb DELETED
@@ -1,379 +0,0 @@
1
- require "test_helper"
2
- require "json"
3
-
4
- module JsonTest
5
- class JSONPublicMethodsTest < Minitest::Spec
6
- #---
7
- # from_json
8
- class BandRepresenter < Representable::Decorator
9
- include Representable::JSON
10
- property :id
11
- property :name
12
- end
13
-
14
- let(:json) { '{"id":1,"name":"Rancid"}' }
15
-
16
- it { _(BandRepresenter.new(Band.new).from_json(json)[:id, :name]).must_equal [1, "Rancid"] }
17
- it { _(BandRepresenter.new(Band.new).parse(json)[:id, :name]).must_equal [1, "Rancid"] }
18
-
19
- #---
20
- # to_json
21
- let(:band) { Band.new(1, "Rancid") }
22
-
23
- it { _(BandRepresenter.new(band).to_json).must_equal json }
24
- it { _(BandRepresenter.new(band).render).must_equal json }
25
- end
26
-
27
- class APITest < Minitest::Spec
28
- Json = Representable::JSON
29
- Def = Representable::Definition
30
-
31
- describe "JSON module" do
32
- before do
33
- @Band = Class.new do
34
- include Representable::JSON
35
- property :name
36
- property :label
37
- attr_accessor :name, :label
38
-
39
- def initialize(name = nil)
40
- self.name = name if name
41
- end
42
- end
43
-
44
- @band = @Band.new
45
- end
46
-
47
- describe "#from_json" do
48
- before do
49
- @band = @Band.new
50
- @json = {:name => "Nofx", :label => "NOFX"}.to_json
51
- end
52
-
53
- it "parses JSON and assigns properties" do
54
- @band.from_json(@json)
55
- assert_equal %w[Nofx NOFX], [@band.name, @band.label]
56
- end
57
- end
58
-
59
- describe "#from_hash" do
60
- before do
61
- @band = @Band.new
62
- @hash = {"name" => "Nofx", "label" => "NOFX"}
63
- end
64
-
65
- it "receives hash and assigns properties" do
66
- @band.from_hash(@hash)
67
- assert_equal %w[Nofx NOFX], [@band.name, @band.label]
68
- end
69
-
70
- it "respects :wrap option" do
71
- @band.from_hash({"band" => {"name" => "This Is A Standoff"}}, :wrap => :band)
72
- assert_equal "This Is A Standoff", @band.name
73
- end
74
-
75
- it "respects :wrap option over representation_wrap" do
76
- @Band.class_eval do
77
- self.representation_wrap = :group
78
- end
79
- @band.from_hash({"band" => {"name" => "This Is A Standoff"}}, :wrap => :band)
80
- assert_equal "This Is A Standoff", @band.name
81
- end
82
- end
83
-
84
- describe "#to_json" do
85
- it "delegates to #to_hash and returns string" do
86
- assert_json "{\"name\":\"Rise Against\"}", @Band.new("Rise Against").to_json
87
- end
88
- end
89
-
90
- describe "#to_hash" do
91
- it "returns unwrapped hash" do
92
- hash = @Band.new("Rise Against").to_hash
93
- assert_equal({"name"=>"Rise Against"}, hash)
94
- end
95
-
96
- it "respects :wrap option" do
97
- assert_equal({:band=>{"name"=>"NOFX"}}, @Band.new("NOFX").to_hash(:wrap => :band))
98
- end
99
-
100
- it "respects :wrap option over representation_wrap" do
101
- @Band.class_eval do
102
- self.representation_wrap = :group
103
- end
104
- assert_equal({:band=>{"name"=>"Rise Against"}}, @Band.new("Rise Against").to_hash(:wrap => :band))
105
- end
106
- end
107
-
108
- describe "#build_for" do
109
- it "returns TextBinding" do
110
- assert_kind_of Representable::Hash::Binding, Representable::Hash::Binding.build_for(Def.new(:band))
111
- end
112
-
113
- it "returns CollectionBinding" do
114
- assert_kind_of Representable::Hash::Binding::Collection,
115
- Representable::Hash::Binding.build_for(Def.new(:band, :collection => true))
116
- end
117
- end
118
- end
119
-
120
- describe "DCI" do
121
- module SongRepresenter
122
- include Representable::JSON
123
- property :name
124
- end
125
-
126
- module AlbumRepresenter
127
- include Representable::JSON
128
- property :best_song, :class => Song, :extend => SongRepresenter
129
- collection :songs, :class => Song, :extend => SongRepresenter
130
- end
131
-
132
- it "allows adding the representer by using #extend" do
133
- module BandRepresenter
134
- include Representable::JSON
135
- property :name
136
- end
137
-
138
- civ = Object.new
139
- civ.instance_eval do
140
- def name; "CIV"; end
141
-
142
- def name=(v)
143
- @name = v
144
- end
145
- end
146
-
147
- civ.extend(BandRepresenter)
148
- assert_json "{\"name\":\"CIV\"}", civ.to_json
149
- end
150
-
151
- it "extends contained models when serializing" do
152
- @album = Album.new([Song.new("I Hate My Brain"), mr = Song.new("Mr. Charisma")], mr)
153
- @album.extend(AlbumRepresenter)
154
-
155
- assert_json "{\"best_song\":{\"name\":\"Mr. Charisma\"},\"songs\":[{\"name\":\"I Hate My Brain\"},{\"name\":\"Mr. Charisma\"}]}",
156
- @album.to_json
157
- end
158
-
159
- it "extends contained models when deserializing" do
160
- # @album = Album.new(Song.new("I Hate My Brain"), Song.new("Mr. Charisma"))
161
- @album = Album.new
162
- @album.extend(AlbumRepresenter)
163
-
164
- @album.from_json("{\"best_song\":{\"name\":\"Mr. Charisma\"},\"songs\":[{\"name\":\"I Hate My Brain\"},{\"name\":\"Mr. Charisma\"}]}")
165
- assert_equal "Mr. Charisma", @album.best_song.name
166
- end
167
- end
168
- end
169
-
170
- class PropertyTest < Minitest::Spec
171
- describe "property :name" do
172
- class Band
173
- include Representable::JSON
174
- property :name
175
- attr_accessor :name
176
- end
177
-
178
- it "#from_json creates correct accessors" do
179
- band = Band.new.from_json({:name => "Bombshell Rocks"}.to_json)
180
- assert_equal "Bombshell Rocks", band.name
181
- end
182
-
183
- it "#to_json serializes correctly" do
184
- band = Band.new
185
- band.name = "Cigar"
186
-
187
- assert_json '{"name":"Cigar"}', band.to_json
188
- end
189
- end
190
-
191
- describe ":class => Item" do
192
- class Label
193
- include Representable::JSON
194
- property :name
195
- attr_accessor :name
196
- end
197
-
198
- class Album
199
- include Representable::JSON
200
- property :label, :class => Label
201
- attr_accessor :label
202
- end
203
-
204
- it "#from_json creates one Item instance" do
205
- album = Album.new.from_json('{"label":{"name":"Fat Wreck"}}')
206
- assert_equal "Fat Wreck", album.label.name
207
- end
208
-
209
- it "#to_json serializes" do
210
- label = Label.new; label.name = "Fat Wreck"
211
- album = Album.new; album.label = label
212
-
213
- assert_json '{"label":{"name":"Fat Wreck"}}', album.to_json
214
- end
215
-
216
- describe ":different_name, :class => Label" do
217
- before do
218
- @Album = Class.new do
219
- include Representable::JSON
220
- property :seller, :class => Label
221
- attr_accessor :seller
222
- end
223
- end
224
-
225
- it "#to_xml respects the different name" do
226
- label = Label.new; label.name = "Fat Wreck"
227
- album = @Album.new; album.seller = label
228
-
229
- assert_json "{\"seller\":{\"name\":\"Fat Wreck\"}}", album.to_json(:wrap => false)
230
- end
231
- end
232
- end
233
-
234
- describe ":as => :songName" do
235
- class Song
236
- include Representable::JSON
237
- property :name, :as => :songName
238
- attr_accessor :name
239
- end
240
-
241
- it "respects :as in #from_json" do
242
- song = Song.new.from_json({:songName => "Run To The Hills"}.to_json)
243
- assert_equal "Run To The Hills", song.name
244
- end
245
-
246
- it "respects :as in #to_json" do
247
- song = Song.new; song.name = "22 Acacia Avenue"
248
- assert_json '{"songName":"22 Acacia Avenue"}', song.to_json
249
- end
250
- end
251
- end
252
-
253
- class CollectionTest < Minitest::Spec
254
- describe "collection :name" do
255
- class CD
256
- include Representable::JSON
257
- collection :songs
258
- attr_accessor :songs
259
- end
260
-
261
- it "#from_json creates correct accessors" do
262
- cd = CD.new.from_json({:songs => ["Out in the cold", "Microphone"]}.to_json)
263
- assert_equal ["Out in the cold", "Microphone"], cd.songs
264
- end
265
-
266
- it "zzz#to_json serializes correctly" do
267
- cd = CD.new
268
- cd.songs = ["Out in the cold", "Microphone"]
269
-
270
- assert_json '{"songs":["Out in the cold","Microphone"]}', cd.to_json
271
- end
272
- end
273
-
274
- describe "collection :name, :class => Band" do
275
- class Band
276
- include Representable::JSON
277
- property :name
278
- attr_accessor :name
279
-
280
- def initialize(name = "")
281
- self.name = name
282
- end
283
- end
284
-
285
- class Compilation
286
- include Representable::JSON
287
- collection :bands, :class => Band
288
- attr_accessor :bands
289
- end
290
-
291
- describe "#from_json" do
292
- it "pushes collection items to array" do
293
- cd = Compilation.new.from_json(
294
- {
295
- :bands => [
296
- {:name => "Cobra Skulls"},
297
- {:name => "Diesel Boy"}
298
- ]
299
- }.to_json
300
- )
301
- assert_equal ["Cobra Skulls", "Diesel Boy"], cd.bands.map(&:name).sort
302
- end
303
- end
304
-
305
- it "responds to #to_json" do
306
- cd = Compilation.new
307
- cd.bands = [Band.new("Diesel Boy"), Band.new("Bad Religion")]
308
-
309
- assert_json '{"bands":[{"name":"Diesel Boy"},{"name":"Bad Religion"}]}', cd.to_json
310
- end
311
- end
312
-
313
- describe ":as => :songList" do
314
- class Songs
315
- include Representable::JSON
316
- collection :tracks, :as => :songList
317
- attr_accessor :tracks
318
- end
319
-
320
- it "respects :as in #from_json" do
321
- songs = Songs.new.from_json({:songList => ["Out in the cold", "Microphone"]}.to_json)
322
- assert_equal ["Out in the cold", "Microphone"], songs.tracks
323
- end
324
-
325
- it "respects option in #to_json" do
326
- songs = Songs.new
327
- songs.tracks = ["Out in the cold", "Microphone"]
328
-
329
- assert_json '{"songList":["Out in the cold","Microphone"]}', songs.to_json
330
- end
331
- end
332
- end
333
-
334
- class HashTest < Minitest::Spec
335
- describe "hash :songs" do
336
- representer!(:module => Representable::JSON) do
337
- hash :songs
338
- end
339
-
340
- subject { OpenStruct.new.extend(representer) }
341
-
342
- it "renders with #to_json" do
343
- subject.songs = {:one => "65", :two => "Emo Boy"}
344
- assert_json "{\"songs\":{\"one\":\"65\",\"two\":\"Emo Boy\"}}", subject.to_json
345
- end
346
-
347
- it "parses with #from_json" do
348
- assert_equal(
349
- {"one" => "65", "two" => ["Emo Boy"]},
350
- subject.from_json("{\"songs\":{\"one\":\"65\",\"two\":[\"Emo Boy\"]}}").songs
351
- )
352
- end
353
- end
354
-
355
- describe "hash :songs, :class => Song" do
356
- representer!(:module => Representable::JSON) do
357
- hash :songs, :extend => Module.new { include Representable::JSON; property :name }, :class => Song
358
- end
359
-
360
- it "renders" do
361
- _(OpenStruct.new(:songs => {"7" => Song.new("Contemplation")}).extend(representer).to_hash).must_equal("songs"=>{"7"=>{"name"=>"Contemplation"}})
362
- end
363
-
364
- describe "parsing" do
365
- subject { OpenStruct.new.extend(representer) }
366
- let(:hsh) { {"7"=>{"name"=>"Contemplation"}} }
367
-
368
- it "parses incoming hash" do
369
- _(subject.from_hash("songs"=>hsh).songs).must_equal({"7"=>Song.new("Contemplation")})
370
- end
371
-
372
- it "doesn't modify the incoming hash" do
373
- subject.from_hash("songs"=> incoming_hash = hsh.dup)
374
- _(hsh).must_equal incoming_hash
375
- end
376
- end
377
- end
378
- end
379
- end
data/test/lonely_test.rb DELETED
@@ -1,241 +0,0 @@
1
- require "test_helper"
2
-
3
- require "representable/json/hash"
4
-
5
- class LonelyRepresenterTest < Minitest::Spec
6
- # test ::items without arguments, render-only.
7
- for_formats(
8
- :hash => [Representable::Hash::Collection, [{"name"=>"Resist Stance"}, {"name"=>"Suffer"}]],
9
- :json => [Representable::JSON::Collection, "[{\"name\":\"Resist Stance\"},{\"name\":\"Suffer\"}]"],
10
- :xml => [
11
- Representable::XML::Collection,
12
- "<array><song><name>Resist Stance</name></song><song><name>Suffer</name></song></array>"
13
- ]
14
- ) do |format, mod, output, _input|
15
- describe "[#{format}] lonely collection, render-only" do # TODO: introduce :representable option?
16
- let(:format) { format }
17
-
18
- representer!(module: mod) do
19
- items do
20
- property :name
21
- end
22
- end
23
-
24
- let(:album) { [Song.new("Resist Stance"), Song.new("Suffer")].extend(representer) }
25
-
26
- it "calls #to_hash on song instances, nothing else" do
27
- render(album).must_equal_document(output)
28
- end
29
- end
30
- end
31
-
32
- module SongRepresenter
33
- include Representable::JSON
34
-
35
- property :name
36
- end
37
-
38
- let(:decorator) { rpr = representer; Class.new(Representable::Decorator) { include Representable::Hash; include rpr } }
39
-
40
- describe "JSON::Collection" do
41
- let(:songs) { [Song.new("Days Go By"), Song.new("Can't Take Them All")] }
42
- let(:json) { "[{\"name\":\"Days Go By\"},{\"name\":\"Can't Take Them All\"}]" }
43
-
44
- describe "with contained objects" do
45
- let(:representer) do
46
- Module.new do
47
- include Representable::JSON::Collection
48
- items :class => Song, :extend => SongRepresenter
49
- end
50
- end
51
-
52
- it "renders array" do
53
- assert_json json, songs.extend(representer).to_json
54
- end
55
-
56
- it "renders array with decorator" do
57
- assert_json json, decorator.new(songs).to_json
58
- end
59
-
60
- it "parses array" do
61
- _([].extend(representer).from_json(json)).must_equal songs
62
- end
63
-
64
- it "parses array with decorator" do
65
- _(decorator.new([]).from_json(json)).must_equal songs
66
- end
67
- end
68
-
69
- describe "with inline representer" do
70
- representer!(:module => Representable::JSON::Collection) do
71
- items :class => Song do
72
- property :name
73
- end
74
- end
75
-
76
- it { _(songs.extend(representer).to_json).must_equal json }
77
- it { _([].extend(representer).from_json(json)).must_equal songs }
78
- end
79
-
80
- describe "with contained text" do
81
- let(:representer) do
82
- Module.new do
83
- include Representable::JSON::Collection
84
- end
85
- end
86
- let(:songs) { ["Days Go By", "Can't Take Them All"] }
87
- let(:json) { "[\"Days Go By\",\"Can't Take Them All\"]" }
88
-
89
- it "renders contained items #to_json" do
90
- assert_json json, songs.extend(representer).to_json
91
- end
92
-
93
- it "returns objects array from #from_json" do
94
- _([].extend(representer).from_json(json)).must_equal songs
95
- end
96
- end
97
- end
98
-
99
- describe "Hash::Collection with dynamic options" do
100
- class One < Representable::Decorator
101
- def to_hash(*); "One: #{represented}"; end
102
- end
103
-
104
- class Two < Representable::Decorator
105
- def to_hash(*); "Two: #{represented}"; end
106
- end
107
-
108
- representer!(module: Representable::Hash::Collection) do
109
- items extend: ->(options) { options[:input] == 1 ? options[:user_options][:one] : options[:user_options][:two] }
110
- end
111
-
112
- it { _([1, 2].extend(representer).to_hash(user_options: {one: One, two: Two})).must_equal(["One: 1", "Two: 2"]) }
113
- end
114
-
115
- describe "JSON::Hash" do # TODO: move to HashTest.
116
- describe "with contained objects" do
117
- let(:representer) do
118
- Module.new do
119
- include Representable::JSON::Hash
120
- values :class => Song, :extend => SongRepresenter
121
- end
122
- end
123
- let(:json) { "{\"one\":{\"name\":\"Days Go By\"},\"two\":{\"name\":\"Can't Take Them All\"}}" }
124
- let(:songs) { {"one" => Song.new("Days Go By"), "two" => Song.new("Can't Take Them All")} }
125
-
126
- describe "#to_json" do
127
- it "renders hash" do
128
- _(songs.extend(representer).to_json).must_equal json
129
- end
130
-
131
- it "renders hash with decorator" do
132
- _(decorator.new(songs).to_json).must_equal json
133
- end
134
-
135
- it "respects :exclude" do
136
- assert_json "{\"two\":{\"name\":\"Can't Take Them All\"}}",
137
- {
138
- :one => Song.new("Days Go By"),
139
- :two => Song.new("Can't Take Them All")
140
- }.extend(representer).to_json(:exclude => [:one])
141
- end
142
-
143
- it "respects :include" do
144
- assert_json "{\"two\":{\"name\":\"Can't Take Them All\"}}",
145
- {
146
- :one => Song.new("Days Go By"),
147
- :two => Song.new("Can't Take Them All")
148
- }.extend(representer).to_json(:include => [:two])
149
- end
150
- end
151
-
152
- describe "#from_json" do
153
- it "returns objects array" do
154
- _({}.extend(representer).from_json(json)).must_equal songs
155
- end
156
-
157
- it "parses hash with decorator" do
158
- _(decorator.new({}).from_json(json)).must_equal songs
159
- end
160
-
161
- it "respects :exclude" do
162
- assert_equal({"two" => Song.new("Can't Take Them All")}, {}.extend(representer).from_json(json, :exclude => [:one]))
163
- end
164
-
165
- it "respects :include" do
166
- assert_equal({"one" => Song.new("Days Go By")}, {}.extend(representer).from_json(json, :include => [:one]))
167
- end
168
- end
169
-
170
- describe "with inline representer" do
171
- representer!(:module => Representable::JSON::Hash) do
172
- values :class => Song do
173
- property :name
174
- end
175
- end
176
-
177
- it { _(songs.extend(representer).to_json).must_equal json }
178
- it { _({}.extend(representer).from_json(json)).must_equal songs }
179
- end
180
- end
181
-
182
- describe "with scalar" do
183
- let(:representer) do
184
- Module.new do
185
- include Representable::JSON::Hash
186
- end
187
- end
188
- let(:json) { %{{"one":1,"two":2}} }
189
- let(:data) { {one: 2, two: 3} }
190
-
191
- describe "#to_json" do
192
- it { _(data.extend(representer).to_json).must_equal %{{"one":2,"two":3}} }
193
-
194
- # it "respects :exclude" do
195
- # assert_json "{\"two\":{\"name\":\"Can't Take Them All\"}}", {:one => Song.new("Days Go By"), :two => Song.new("Can't Take Them All")}.extend(representer).to_json(:exclude => [:one])
196
- # end
197
-
198
- # it "respects :include" do
199
- # assert_json "{\"two\":{\"name\":\"Can't Take Them All\"}}", {:one => Song.new("Days Go By"), :two => Song.new("Can't Take Them All")}.extend(representer).to_json(:include => [:two])
200
- # end
201
- end
202
-
203
- describe "#from_json" do # FIXME: what's the point of this?
204
- it { _(data.extend(representer).from_hash(data)).must_equal data }
205
- end
206
- end
207
-
208
- describe "with contained text" do
209
- before do
210
- @songs_representer = Module.new do
211
- include Representable::JSON::Collection
212
- end
213
- end
214
-
215
- it "renders contained items #to_json" do
216
- assert_json "[\"Days Go By\",\"Can't Take Them All\"]",
217
- ["Days Go By", "Can't Take Them All"].extend(@songs_representer).to_json
218
- end
219
-
220
- it "returns objects array from #from_json" do
221
- assert_equal ["Days Go By", "Can't Take Them All"],
222
- [].extend(@songs_representer).from_json("[\"Days Go By\",\"Can't Take Them All\"]")
223
- end
224
- end
225
- end
226
- end
227
-
228
- # describe "Hash::Collection with :include" do
229
- class CollectionWithIncludeTest < Minitest::Spec
230
- Song = Struct.new(:id, :title)
231
-
232
- representer!(decorator: true, module: Representable::Hash::Collection) do
233
- items do
234
- property :id
235
- property :title
236
- end
237
- end
238
-
239
- it { _(representer.new([Song.new(1, "ACAB")]).to_hash).must_equal([{"id" => 1, "title" => "ACAB"}]) }
240
- it { _(representer.new([Song.new(1, "ACAB")]).to_hash(include: [:title])).must_equal([{"title"=>"ACAB"}]) }
241
- end