representable 3.0.4 → 3.1.1

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 (98) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +17 -0
  3. data/CHANGES.md +10 -0
  4. data/Gemfile +4 -7
  5. data/LICENSE +1 -1
  6. data/README.md +4 -3
  7. data/Rakefile +1 -6
  8. data/lib/representable.rb +18 -25
  9. data/lib/representable/binding.rb +32 -12
  10. data/lib/representable/cached.rb +1 -1
  11. data/lib/representable/coercion.rb +8 -6
  12. data/lib/representable/config.rb +8 -3
  13. data/lib/representable/debug.rb +23 -15
  14. data/lib/representable/declarative.rb +8 -3
  15. data/lib/representable/decorator.rb +1 -1
  16. data/lib/representable/definition.rb +7 -2
  17. data/lib/representable/deserializer.rb +4 -3
  18. data/lib/representable/for_collection.rb +1 -1
  19. data/lib/representable/hash.rb +6 -2
  20. data/lib/representable/hash/allow_symbols.rb +9 -11
  21. data/lib/representable/hash/binding.rb +1 -0
  22. data/lib/representable/hash/collection.rb +4 -2
  23. data/lib/representable/hash_methods.rb +3 -2
  24. data/lib/representable/insert.rb +1 -1
  25. data/lib/representable/json.rb +5 -7
  26. data/lib/representable/json/collection.rb +3 -0
  27. data/lib/representable/json/hash.rb +1 -0
  28. data/lib/representable/object.rb +1 -1
  29. data/lib/representable/object/binding.rb +5 -1
  30. data/lib/representable/option.rb +19 -0
  31. data/lib/representable/pipeline.rb +3 -2
  32. data/lib/representable/pipeline_factories.rb +4 -2
  33. data/lib/representable/populator.rb +1 -1
  34. data/lib/representable/represent.rb +1 -0
  35. data/lib/representable/serializer.rb +2 -1
  36. data/lib/representable/version.rb +1 -1
  37. data/lib/representable/virtus_coercion.rb +38 -0
  38. data/lib/representable/xml.rb +7 -10
  39. data/lib/representable/xml/binding.rb +2 -3
  40. data/lib/representable/yaml.rb +3 -3
  41. data/lib/representable/yaml/binding.rb +1 -0
  42. data/representable.gemspec +3 -3
  43. data/test/as_test.rb +4 -4
  44. data/test/binding_test.rb +10 -10
  45. data/test/cached_test.rb +19 -19
  46. data/test/class_test.rb +7 -7
  47. data/test/coercion_test.rb +33 -22
  48. data/test/config/inherit_test.rb +14 -14
  49. data/test/config_test.rb +18 -18
  50. data/test/decorator_scope_test.rb +3 -3
  51. data/test/decorator_test.rb +17 -17
  52. data/test/default_test.rb +7 -7
  53. data/test/definition_test.rb +32 -32
  54. data/test/{example.rb → examples/example.rb} +0 -0
  55. data/test/exec_context_test.rb +6 -6
  56. data/test/features_test.rb +3 -3
  57. data/test/filter_test.rb +6 -6
  58. data/test/for_collection_test.rb +2 -2
  59. data/test/generic_test.rb +3 -3
  60. data/test/getter_setter_test.rb +5 -5
  61. data/test/hash_test.rb +19 -19
  62. data/test/heritage_test.rb +4 -4
  63. data/test/if_test.rb +6 -6
  64. data/test/include_exclude_test.rb +12 -12
  65. data/test/inherit_test.rb +15 -15
  66. data/test/inline_test.rb +11 -11
  67. data/test/instance_test.rb +29 -29
  68. data/test/is_representable_test.rb +10 -10
  69. data/test/json_test.rb +7 -7
  70. data/test/lonely_test.rb +16 -16
  71. data/test/nested_test.rb +7 -7
  72. data/test/object_test.rb +7 -7
  73. data/test/option_test.rb +36 -0
  74. data/test/parse_pipeline_test.rb +3 -3
  75. data/test/pipeline_test.rb +43 -43
  76. data/test/populator_test.rb +15 -15
  77. data/test/prepare_test.rb +2 -2
  78. data/test/private_options_test.rb +2 -2
  79. data/test/reader_writer_test.rb +2 -2
  80. data/test/render_nil_test.rb +2 -2
  81. data/test/represent_test.rb +4 -4
  82. data/test/representable_test.rb +27 -27
  83. data/test/schema_test.rb +5 -5
  84. data/test/serialize_deserialize_test.rb +2 -2
  85. data/test/skip_test.rb +10 -10
  86. data/test/stringify_hash_test.rb +3 -3
  87. data/test/test_helper.rb +4 -2
  88. data/test/uncategorized_test.rb +10 -10
  89. data/test/user_options_test.rb +4 -4
  90. data/test/virtus_coercion_test.rb +52 -0
  91. data/test/wrap_test.rb +11 -11
  92. data/test/xml_namespace_test.rb +1 -1
  93. data/test/xml_test.rb +6 -6
  94. data/test/yaml_test.rb +20 -20
  95. metadata +81 -15
  96. data/.travis.yml +0 -16
  97. data/lib/representable/autoload.rb +0 -14
  98. data/test/mongoid_test.rb +0 -31
data/test/inline_test.rb CHANGED
@@ -22,7 +22,7 @@ class InlineTest < MiniTest::Spec
22
22
  let(:format) { format }
23
23
 
24
24
  it { render(request).must_equal_document output }
25
- it { parse(request, input).song.name.must_equal "You've Taken Everything"}
25
+ it { _(parse(request, input).song.name).must_equal "You've Taken Everything"}
26
26
  end
27
27
  end
28
28
 
@@ -47,7 +47,7 @@ class InlineTest < MiniTest::Spec
47
47
  let(:format) { format } # FIXME: why do we have to define this?
48
48
 
49
49
  it { render(request).must_equal_document output }
50
- it { parse(request, input).songs.first.name.must_equal "You've Taken Everything"}
50
+ it { _(parse(request, input).songs.first.name).must_equal "You've Taken Everything"}
51
51
  end
52
52
  end
53
53
 
@@ -58,7 +58,7 @@ class InlineTest < MiniTest::Spec
58
58
  end
59
59
  end
60
60
 
61
- it { request.to_hash.must_equal({"song"=>{"name"=>"Alive"}}) }
61
+ it { _(request.to_hash).must_equal({"song"=>{"name"=>"Alive"}}) }
62
62
  end
63
63
 
64
64
 
@@ -76,7 +76,7 @@ class InlineTest < MiniTest::Spec
76
76
  end
77
77
 
78
78
  it "doesn't change represented object" do
79
- request.send("from_#{format}", input).song.must_equal song
79
+ _(request.send("from_#{format}", input).song).must_equal song
80
80
  end
81
81
  end
82
82
  end
@@ -96,8 +96,8 @@ class InlineTest < MiniTest::Spec
96
96
 
97
97
  let(:decorator) { representer.prepare(request) }
98
98
 
99
- it { decorator.to_hash.must_equal({"requester"=>"Josephine", "song"=>{"name"=>"Alive"}}) }
100
- it { decorator.from_hash({"song"=>{"name"=>"You've Taken Everything"}}).song.name.must_equal "You've Taken Everything"}
99
+ it { _(decorator.to_hash).must_equal({"requester"=>"Josephine", "song"=>{"name"=>"Alive"}}) }
100
+ it { _(decorator.from_hash({"song"=>{"name"=>"You've Taken Everything"}}).song.name).must_equal "You've Taken Everything"}
101
101
  end
102
102
  end
103
103
 
@@ -110,7 +110,7 @@ class InlineTest < MiniTest::Spec
110
110
 
111
111
  it "uses an inline decorator and doesn't alter represented" do
112
112
  representer.prepare(Struct.new(:song).new(song)).to_hash
113
- song.wont_be_kind_of Representable
113
+ _(song).wont_be_kind_of Representable
114
114
  end
115
115
  end
116
116
 
@@ -221,8 +221,8 @@ class InlineTest < MiniTest::Spec
221
221
  end
222
222
  end
223
223
 
224
- it do OpenStruct.new(:song => OpenStruct.new(:title => "The Fever And The Sound", :artist => "Strung Out")).extend(representer).
225
- to_hash.
224
+ it do _(OpenStruct.new(:song => OpenStruct.new(:title => "The Fever And The Sound", :artist => "Strung Out")).extend(representer).
225
+ to_hash).
226
226
  must_equal({"song"=>{"artist"=>"Strung Out", "title"=>"The Fever And The Sound"}})
227
227
  end
228
228
  end
@@ -246,7 +246,7 @@ class InlineTest < MiniTest::Spec
246
246
  end
247
247
  end
248
248
 
249
- it { Object.new.extend(Mod).to_hash.must_equal("song"=>{"duration"=>"6:53"}) }
249
+ it { _(Object.new.extend(Mod).to_hash).must_equal("song"=>{"duration"=>"6:53"}) }
250
250
  end
251
251
 
252
252
  # define method inline with Decorator
@@ -267,6 +267,6 @@ class InlineTest < MiniTest::Spec
267
267
  end
268
268
  end
269
269
 
270
- it { dec.new(Object.new).to_hash.must_equal("song"=>{"duration"=>"6:53"}) }
270
+ it { _(dec.new(Object.new).to_hash).must_equal("song"=>{"duration"=>"6:53"}) }
271
271
  end
272
272
  end
@@ -22,7 +22,7 @@ class InstanceTest < BaseTest
22
22
  end
23
23
 
24
24
  song = OpenStruct.new.extend(representer).from_hash({"title" => object})
25
- song.title.must_equal object
25
+ _(song.title).must_equal object
26
26
  end
27
27
  end
28
28
 
@@ -36,11 +36,11 @@ class InstanceTest < BaseTest
36
36
  :extend => song_representer
37
37
  end
38
38
 
39
- it( "xxx") { OpenStruct.new(:song => Song.new(1, "The Answer Is Still No")).extend(representer).
40
- from_hash("song" => {"id" => 1}).song.must_equal Song.new(1, "The Answer Is Still No") }
39
+ it( "xxx") { _(OpenStruct.new(:song => Song.new(1, "The Answer Is Still No")).extend(representer).
40
+ from_hash("song" => {"id" => 1}).song).must_equal Song.new(1, "The Answer Is Still No") }
41
41
 
42
- it { OpenStruct.new(:song => Song.new(1, "The Answer Is Still No")).extend(representer).
43
- from_hash("song" => {"id" => 2}).song.must_equal Song.new(2, "Invincible") }
42
+ it { _(OpenStruct.new(:song => Song.new(1, "The Answer Is Still No")).extend(representer).
43
+ from_hash("song" => {"id" => 2}).song).must_equal Song.new(2, "Invincible") }
44
44
  end
45
45
 
46
46
 
@@ -59,9 +59,9 @@ class InstanceTest < BaseTest
59
59
  Song.new(1, "The Answer Is Still No"),
60
60
  Song.new(2, "")])
61
61
 
62
- album.
62
+ _(album.
63
63
  extend(representer).
64
- from_hash("songs" => [{"id" => 2},{"id" => 2, "title"=>"The Answer Is Still No"}]).songs.must_equal [
64
+ from_hash("songs" => [{"id" => 2},{"id" => 2, "title"=>"The Answer Is Still No"}]).songs).must_equal [
65
65
  Song.new(2, "Invincible"), Song.new(2, "The Answer Is Still No")]
66
66
  }
67
67
  end
@@ -71,8 +71,8 @@ class InstanceTest < BaseTest
71
71
  property :song, :instance => lambda { |options| Struct.new(:args, :id).new([options[:fragment], options[:user_options]]) }, :extend => song_representer
72
72
  end
73
73
 
74
- it { OpenStruct.new(:song => Song.new(1, "The Answer Is Still No")).extend(representer).
75
- from_hash({"song" => {"id" => 1}}, user_options: { volume: 1 }).song.args.must_equal([{"id"=>1}, {:volume=>1}]) }
74
+ it { _(OpenStruct.new(:song => Song.new(1, "The Answer Is Still No")).extend(representer).
75
+ from_hash({"song" => {"id" => 1}}, user_options: { volume: 1 }).song.args).must_equal([{"id"=>1}, {:volume=>1}]) }
76
76
  end
77
77
 
78
78
  # TODO: raise and test instance:{nil}
@@ -117,13 +117,13 @@ class InstanceTest < BaseTest
117
117
  extend(representer).
118
118
  from_hash("songs" => [{"title" => "The Answer Is Still No"}, {"title" => "Invincible"}])
119
119
 
120
- album.songs.must_equal [
120
+ _(album.songs).must_equal [
121
121
  Song.new(1, "The Answer Is Still No"),
122
122
  Song.new(2, "Invincible")]
123
123
 
124
- songs.object_id.must_equal album.songs.object_id
125
- songs[0].object_id.must_equal album.songs[0].object_id
126
- songs[1].object_id.must_equal album.songs[1].object_id
124
+ _(songs.object_id).must_equal album.songs.object_id
125
+ _(songs[0].object_id).must_equal album.songs[0].object_id
126
+ _(songs[1].object_id).must_equal album.songs[1].object_id
127
127
  }
128
128
  end
129
129
 
@@ -146,17 +146,17 @@ class InstanceTest < BaseTest
146
146
  Song.new(1, "The Answer Is Still No"),
147
147
  Song.new(2, "Invncble")])
148
148
 
149
- album.
149
+ _(album.
150
150
  extend(representer).
151
151
  from_hash("songs" => [{"id" => 2, "title" => "Invincible"}]).
152
- songs.must_equal [
152
+ songs).must_equal [
153
153
  Song.new(1, "The Answer Is Still No"),
154
154
  Song.new(2, "Invincible")]
155
155
  # TODO: check elements object_id!
156
156
 
157
- songs.object_id.must_equal album.songs.object_id
158
- songs[0].object_id.must_equal album.songs[0].object_id
159
- songs[1].object_id.must_equal album.songs[1].object_id
157
+ _(songs.object_id).must_equal album.songs.object_id
158
+ _(songs[0].object_id).must_equal album.songs[0].object_id
159
+ _(songs[1].object_id).must_equal album.songs[1].object_id
160
160
  }
161
161
  end
162
162
 
@@ -178,15 +178,15 @@ class InstanceTest < BaseTest
178
178
  album= Struct.new(:songs).new(songs = [
179
179
  Song.new(1, "The Answer Is Still No")])
180
180
 
181
- album.
181
+ _(album.
182
182
  extend(representer).
183
183
  from_hash("songs" => [{"title" => "Invincible"}]).
184
- songs.must_equal [
184
+ songs).must_equal [
185
185
  Song.new(1, "The Answer Is Still No"),
186
186
  Song.new(2, "Invincible")]
187
187
 
188
- songs.object_id.must_equal album.songs.object_id
189
- songs[0].object_id.must_equal album.songs[0].object_id
188
+ _(songs.object_id).must_equal album.songs.object_id
189
+ _(songs[0].object_id).must_equal album.songs[0].object_id
190
190
  }
191
191
  end
192
192
 
@@ -212,15 +212,15 @@ class InstanceTest < BaseTest
212
212
  Song.new(1, "The Answer Is Still No"),
213
213
  Song.new(2, "Invincible")])
214
214
 
215
- album.
215
+ _(album.
216
216
  extend(representer).
217
217
  from_hash("songs" => [{"replace_id"=>2, "id" => 3, "title" => "Soulmate"}]).
218
- songs.must_equal [
218
+ songs).must_equal [
219
219
  Song.new(1, "The Answer Is Still No"),
220
220
  Song.new(3, "Soulmate")]
221
221
 
222
- songs.object_id.must_equal album.songs.object_id
223
- songs[0].object_id.must_equal album.songs[0].object_id
222
+ _(songs.object_id).must_equal album.songs.object_id
223
+ _(songs[0].object_id).must_equal album.songs[0].object_id
224
224
  }
225
225
  end
226
226
 
@@ -235,13 +235,13 @@ class InstanceTest < BaseTest
235
235
  album= Struct.new(:songs).new(songs = [
236
236
  Song.new(1, "The Answer Is Still No")])
237
237
 
238
- album.
238
+ _(album.
239
239
  extend(representer).
240
240
  from_hash("songs" => [{"title" => "Invincible"}]).
241
- songs.must_equal [
241
+ songs).must_equal [
242
242
  Song.new(nil, "Invincible")]
243
243
 
244
- songs.object_id.wont_equal album.songs.object_id
244
+ _(songs.object_id).wont_equal album.songs.object_id
245
245
  }
246
246
  end
247
247
  end
@@ -9,9 +9,9 @@ class IsRepresentableTest < BaseTest
9
9
  end
10
10
 
11
11
  it "does extend but doesn't call #to_hash" do
12
- Struct.new(:song).new(song = Object.new).extend(representer).
13
- to_hash.must_equal("song" => song)
14
- song.must_be_kind_of Representable::Hash
12
+ _(Struct.new(:song).new(song = Object.new).extend(representer).
13
+ to_hash).must_equal("song" => song)
14
+ _(song).must_be_kind_of Representable::Hash
15
15
  end
16
16
  end
17
17
 
@@ -30,9 +30,9 @@ class IsRepresentableTest < BaseTest
30
30
  end
31
31
  end
32
32
 
33
- Struct.new(:song).new(song).extend(representer).
34
- to_hash.must_equal("song" => 1)
35
- song.wont_be_kind_of Representable::Hash
33
+ _(Struct.new(:song).new(song).extend(representer).
34
+ to_hash).must_equal("song" => 1)
35
+ _(song).wont_be_kind_of Representable::Hash
36
36
  end
37
37
  end
38
38
 
@@ -48,8 +48,8 @@ class IsRepresentableTest < BaseTest
48
48
  hit = Struct.new(:song).new.extend(representer).
49
49
  from_hash("song" => 1)
50
50
 
51
- hit.song.must_equal OpenStruct.new
52
- hit.song.must_be_kind_of Representable::Hash
51
+ _(hit.song).must_equal OpenStruct.new
52
+ _(hit.song).must_be_kind_of Representable::Hash
53
53
  end
54
54
  end
55
55
 
@@ -70,8 +70,8 @@ class IsRepresentableTest < BaseTest
70
70
  hit = Struct.new(:song).new.extend(representer).
71
71
  from_hash("song" => "Sonata No.2")
72
72
 
73
- hit.song.must_equal "Piano?"
74
- hit.song.wont_be_kind_of Representable::Hash
73
+ _(hit.song).must_equal "Piano?"
74
+ _(hit.song).wont_be_kind_of Representable::Hash
75
75
  end
76
76
  end
77
77
  end
data/test/json_test.rb CHANGED
@@ -13,15 +13,15 @@ class JSONPublicMethodsTest < Minitest::Spec
13
13
 
14
14
  let(:json) { '{"id":1,"name":"Rancid"}' }
15
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"] }
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
18
 
19
19
  #---
20
20
  # to_json
21
21
  let(:band) { Band.new(1, "Rancid") }
22
22
 
23
- it { BandRepresenter.new(band).to_json.must_equal json }
24
- it { BandRepresenter.new(band).render.must_equal json }
23
+ it { _(BandRepresenter.new(band).to_json).must_equal json }
24
+ it { _(BandRepresenter.new(band).render).must_equal json }
25
25
  end
26
26
 
27
27
  class APITest < MiniTest::Spec
@@ -356,7 +356,7 @@ end
356
356
  end
357
357
 
358
358
  it "renders" do
359
- OpenStruct.new(:songs => {"7" => Song.new("Contemplation")}).extend(representer).to_hash.must_equal("songs"=>{"7"=>{"name"=>"Contemplation"}})
359
+ _(OpenStruct.new(:songs => {"7" => Song.new("Contemplation")}).extend(representer).to_hash).must_equal("songs"=>{"7"=>{"name"=>"Contemplation"}})
360
360
  end
361
361
 
362
362
  describe "parsing" do
@@ -364,12 +364,12 @@ end
364
364
  let(:hsh) { {"7"=>{"name"=>"Contemplation"}} }
365
365
 
366
366
  it "parses incoming hash" do
367
- subject.from_hash("songs"=>hsh).songs.must_equal({"7"=>Song.new("Contemplation")})
367
+ _(subject.from_hash("songs"=>hsh).songs).must_equal({"7"=>Song.new("Contemplation")})
368
368
  end
369
369
 
370
370
  it "doesn't modify the incoming hash" do
371
371
  subject.from_hash("songs"=> incoming_hash = hsh.dup)
372
- hsh.must_equal incoming_hash
372
+ _(hsh).must_equal incoming_hash
373
373
  end
374
374
  end
375
375
  end
data/test/lonely_test.rb CHANGED
@@ -60,11 +60,11 @@ class LonelyRepresenterTest < MiniTest::Spec
60
60
  end
61
61
 
62
62
  it "parses array" do
63
- [].extend(representer).from_json(json).must_equal songs
63
+ _([].extend(representer).from_json(json)).must_equal songs
64
64
  end
65
65
 
66
66
  it "parses array with decorator" do
67
- decorator.new([]).from_json(json).must_equal songs
67
+ _(decorator.new([]).from_json(json)).must_equal songs
68
68
  end
69
69
  end
70
70
 
@@ -75,8 +75,8 @@ class LonelyRepresenterTest < MiniTest::Spec
75
75
  end
76
76
  end
77
77
 
78
- it { songs.extend(representer).to_json.must_equal json }
79
- it { [].extend(representer).from_json(json).must_equal songs }
78
+ it { _(songs.extend(representer).to_json).must_equal json }
79
+ it { _([].extend(representer).from_json(json)).must_equal songs }
80
80
  end
81
81
 
82
82
  describe "with contained text" do
@@ -93,7 +93,7 @@ class LonelyRepresenterTest < MiniTest::Spec
93
93
  end
94
94
 
95
95
  it "returns objects array from #from_json" do
96
- [].extend(representer).from_json(json).must_equal songs
96
+ _([].extend(representer).from_json(json)).must_equal songs
97
97
  end
98
98
  end
99
99
  end
@@ -112,7 +112,7 @@ class LonelyRepresenterTest < MiniTest::Spec
112
112
  end
113
113
 
114
114
 
115
- it { [1,2].extend(representer).to_hash(user_options: {one: One, two: Two}).must_equal(["One: 1", "Two: 2"]) }
115
+ it { _([1,2].extend(representer).to_hash(user_options: {one: One, two: Two})).must_equal(["One: 1", "Two: 2"]) }
116
116
  end
117
117
 
118
118
 
@@ -129,11 +129,11 @@ class LonelyRepresenterTest < MiniTest::Spec
129
129
 
130
130
  describe "#to_json" do
131
131
  it "renders hash" do
132
- songs.extend(representer).to_json.must_equal json
132
+ _(songs.extend(representer).to_json).must_equal json
133
133
  end
134
134
 
135
135
  it "renders hash with decorator" do
136
- decorator.new(songs).to_json.must_equal json
136
+ _(decorator.new(songs).to_json).must_equal json
137
137
  end
138
138
 
139
139
  it "respects :exclude" do
@@ -147,11 +147,11 @@ class LonelyRepresenterTest < MiniTest::Spec
147
147
 
148
148
  describe "#from_json" do
149
149
  it "returns objects array" do
150
- {}.extend(representer).from_json(json).must_equal songs
150
+ _({}.extend(representer).from_json(json)).must_equal songs
151
151
  end
152
152
 
153
153
  it "parses hash with decorator" do
154
- decorator.new({}).from_json(json).must_equal songs
154
+ _(decorator.new({}).from_json(json)).must_equal songs
155
155
  end
156
156
 
157
157
  it "respects :exclude" do
@@ -171,8 +171,8 @@ class LonelyRepresenterTest < MiniTest::Spec
171
171
  end
172
172
  end
173
173
 
174
- it { songs.extend(representer).to_json.must_equal json }
175
- it { {}.extend(representer).from_json(json).must_equal songs }
174
+ it { _(songs.extend(representer).to_json).must_equal json }
175
+ it { _({}.extend(representer).from_json(json)).must_equal songs }
176
176
  end
177
177
  end
178
178
 
@@ -187,7 +187,7 @@ class LonelyRepresenterTest < MiniTest::Spec
187
187
  let(:data) { {one: 2, two: 3} }
188
188
 
189
189
  describe "#to_json" do
190
- it { data.extend(representer).to_json.must_equal %{{"one":2,"two":3}} }
190
+ it { _(data.extend(representer).to_json).must_equal %{{"one":2,"two":3}} }
191
191
 
192
192
  # it "respects :exclude" do
193
193
  # 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])
@@ -199,7 +199,7 @@ class LonelyRepresenterTest < MiniTest::Spec
199
199
  end
200
200
 
201
201
  describe "#from_json" do # FIXME: what's the point of this?
202
- it { data.extend(representer).from_hash(data).must_equal data }
202
+ it { _(data.extend(representer).from_hash(data)).must_equal data }
203
203
  end
204
204
  end
205
205
 
@@ -234,6 +234,6 @@ class CollectionWithIncludeTest < MiniTest::Spec
234
234
  end
235
235
  end
236
236
 
237
- it { representer.new([Song.new(1, "ACAB")]).to_hash.must_equal([{"id"=>1, "title"=>"ACAB"}]) }
238
- it { representer.new([Song.new(1, "ACAB")]).to_hash(include: [:title]).must_equal([{"title"=>"ACAB"}]) }
237
+ it { _(representer.new([Song.new(1, "ACAB")]).to_hash).must_equal([{"id"=>1, "title"=>"ACAB"}]) }
238
+ it { _(representer.new([Song.new(1, "ACAB")]).to_hash(include: [:title])).must_equal([{"title"=>"ACAB"}]) }
239
239
  end
data/test/nested_test.rb CHANGED
@@ -35,14 +35,14 @@ class NestedTest < MiniTest::Spec
35
35
 
36
36
  # do not use extend on the nested object. # FIXME: make this a proper test with two describes instead of this pseudo-meta stuff.
37
37
  if is_decorator==true
38
- album.wont_be_kind_of(Representable::Hash)
38
+ _(album).wont_be_kind_of(Representable::Hash)
39
39
  end
40
40
  end
41
41
 
42
42
  it "parses nested properties to Album instance" do
43
43
  album = parse(representer.prepare(Album.new), output)
44
- album.label.must_equal "Epitaph"
45
- album.owner.must_equal "Brett Gurewitz"
44
+ _(album.label).must_equal "Epitaph"
45
+ _(album.owner).must_equal "Brett Gurewitz"
46
46
  end
47
47
  end
48
48
  end
@@ -76,9 +76,9 @@ class NestedTest < MiniTest::Spec
76
76
 
77
77
  it "parses nested properties to Album instance" do
78
78
  album = parse(representer.prepare(Album.new), output)
79
- album.label.must_equal "Epitaph"
80
- album.owner.must_equal "Brett Gurewitz"
81
- album.amount.must_equal 19
79
+ _(album.label).must_equal "Epitaph"
80
+ _(album.owner).must_equal "Brett Gurewitz"
81
+ _(album.amount).must_equal 19
82
82
  end
83
83
  end
84
84
  end
@@ -102,7 +102,7 @@ class NestedTest < MiniTest::Spec
102
102
  let(:album) { representer.prepare(Album.new("Epitaph", "Brett Gurewitz", 19)) }
103
103
 
104
104
  it "renders nested Album-properties in separate section" do
105
- representer.prepare(album).to_hash.must_equal({"Label"=>{"owner"=>"Brett Gurewitz"}})
105
+ _(representer.prepare(album).to_hash).must_equal({"Label"=>{"owner"=>"Brett Gurewitz"}})
106
106
  end
107
107
 
108
108
  # it "parses nested properties to Album instance" do