representable 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -1
  3. data/CHANGES.md +5 -0
  4. data/README.md +1 -1
  5. data/TODO +1 -3
  6. data/TODO-4.0.md +72 -0
  7. data/lib/representable/declarative.rb +3 -3
  8. data/lib/representable/deserializer.rb +1 -1
  9. data/lib/representable/serializer.rb +1 -1
  10. data/lib/representable/version.rb +1 -1
  11. data/lib/representable/xml.rb +6 -4
  12. data/lib/representable/xml/binding.rb +19 -12
  13. data/lib/representable/xml/namespace.rb +122 -0
  14. data/representable.gemspec +2 -2
  15. data/test/as_test.rb +2 -2
  16. data/test/binding_test.rb +7 -7
  17. data/test/cached_test.rb +13 -13
  18. data/test/class_test.rb +2 -2
  19. data/test/coercion_test.rb +1 -1
  20. data/test/config_test.rb +5 -5
  21. data/test/decorator_scope_test.rb +1 -1
  22. data/test/decorator_test.rb +8 -8
  23. data/test/default_test.rb +1 -1
  24. data/test/defaults_options_test.rb +3 -3
  25. data/test/definition_test.rb +9 -11
  26. data/test/examples/object.rb +1 -5
  27. data/test/exec_context_test.rb +2 -2
  28. data/test/features_test.rb +3 -3
  29. data/test/filter_test.rb +2 -2
  30. data/test/for_collection_test.rb +8 -8
  31. data/test/generic_test.rb +11 -11
  32. data/test/hash_bindings_test.rb +1 -1
  33. data/test/hash_test.rb +13 -13
  34. data/test/heritage_test.rb +16 -13
  35. data/test/if_test.rb +3 -3
  36. data/test/include_exclude_test.rb +2 -2
  37. data/test/inherit_test.rb +3 -3
  38. data/test/inline_test.rb +13 -13
  39. data/test/instance_test.rb +2 -2
  40. data/test/json_test.rb +4 -6
  41. data/test/lonely_test.rb +15 -15
  42. data/test/nested_test.rb +6 -6
  43. data/test/object_test.rb +4 -4
  44. data/test/parse_pipeline_test.rb +0 -2
  45. data/test/pipeline_test.rb +7 -7
  46. data/test/populator_test.rb +7 -7
  47. data/test/prepare_test.rb +2 -2
  48. data/test/represent_test.rb +10 -10
  49. data/test/representable_test.rb +7 -7
  50. data/test/schema_test.rb +3 -6
  51. data/test/skip_test.rb +6 -6
  52. data/test/test_helper.rb +16 -6
  53. data/test/wrap_test.rb +8 -8
  54. data/test/xml_namespace_test.rb +186 -0
  55. data/test/xml_test.rb +53 -34
  56. data/test/yaml_test.rb +11 -11
  57. metadata +9 -7
  58. data/lib/representable/TODO.getting_serious +0 -11
@@ -21,7 +21,7 @@ class HashBindingTest < MiniTest::Spec
21
21
  it "returns fragment if present" do
22
22
  assert_equal "Stick The Flag Up Your Goddamn Ass, You Sonofabitch", @property.read({"song" => "Stick The Flag Up Your Goddamn Ass, You Sonofabitch"}, "song")
23
23
  assert_equal "", @property.read({"song" => ""}, "song")
24
- assert_equal nil, @property.read({"song" => nil}, "song")
24
+ assert_nil @property.read({"song" => nil}, "song")
25
25
  end
26
26
 
27
27
  it "returns FRAGMENT_NOT_FOUND if not in document" do
@@ -9,14 +9,14 @@ class HashPublicMethodsTest < Minitest::Spec
9
9
  property :name
10
10
  end
11
11
 
12
- let (:data) { {"id"=>1,"name"=>"Rancid"} }
12
+ let(:data) { {"id"=>1,"name"=>"Rancid"} }
13
13
 
14
14
  it { BandRepresenter.new(Band.new).from_hash(data)[:id, :name].must_equal [1, "Rancid"] }
15
15
  it { BandRepresenter.new(Band.new).parse(data)[:id, :name].must_equal [1, "Rancid"] }
16
16
 
17
17
  #---
18
18
  # to_hash
19
- let (:band) { Band.new(1, "Rancid") }
19
+ let(:band) { Band.new(1, "Rancid") }
20
20
 
21
21
  it { BandRepresenter.new(band).to_hash.must_equal data }
22
22
  it { BandRepresenter.new(band).render.must_equal data }
@@ -29,7 +29,7 @@ class HashWithScalarPropertyTest < MiniTest::Spec
29
29
  property :title
30
30
  end
31
31
 
32
- let (:album) { Album.new("Liar") }
32
+ let(:album) { Album.new("Liar") }
33
33
 
34
34
  describe "#to_hash" do
35
35
  it "renders plain property" do
@@ -46,7 +46,7 @@ class HashWithScalarPropertyTest < MiniTest::Spec
46
46
  # Fixes issue #115
47
47
  it "allows nil value in the incoming document and corresponding nil value for the represented" do
48
48
  album = Album.new
49
- album.title.must_equal nil
49
+ album.title.must_be_nil
50
50
  album.extend(representer).from_hash("title" => nil)
51
51
  end
52
52
  end
@@ -62,7 +62,7 @@ class HashWithTypedPropertyTest < MiniTest::Spec
62
62
  end
63
63
  end
64
64
 
65
- let (:album) { Album.new(Song.new("Liar")) }
65
+ let(:album) { Album.new(Song.new("Liar")) }
66
66
 
67
67
  describe "#to_hash" do
68
68
  it "renders embedded typed property" do
@@ -80,21 +80,21 @@ class HashWithTypedPropertyTest < MiniTest::Spec
80
80
  it do
81
81
  album = Album.new(Song.new("Pre-medicated Murder"))
82
82
  album.extend(representer).from_hash("best_song" => nil)
83
- album.best_song.must_equal nil
83
+ album.best_song.must_be_nil
84
84
  end
85
85
 
86
86
  # nested blank hash creates blank object when not populated.
87
87
  it do
88
88
  album = Album.new#(Song.new("Pre-medicated Murder"))
89
89
  album.extend(representer).from_hash("best_song" => {})
90
- album.best_song.name.must_equal nil
90
+ album.best_song.name.must_be_nil
91
91
  end
92
92
 
93
93
  # Fixes issue #115
94
94
  it "allows nil value in the incoming document and corresponding nil value for the represented" do
95
95
  album = Album.new
96
96
  album.extend(representer).from_hash("best_song" => nil)
97
- album.best_song.must_equal nil
97
+ album.best_song.must_be_nil
98
98
  end
99
99
  end
100
100
  end
@@ -107,7 +107,7 @@ class HashWithTypedPropertyAndAs < MiniTest::Spec
107
107
  end
108
108
  end
109
109
 
110
- let (:album) { OpenStruct.new(:song => Song.new("Liar")).extend(representer) }
110
+ let(:album) { OpenStruct.new(:song => Song.new("Liar")).extend(representer) }
111
111
 
112
112
  it { album.to_hash.must_equal("hit" => {"name" => "Liar"}) }
113
113
  it { album.from_hash("hit" => {"name" => "Go With Me"}).must_equal OpenStruct.new(:song => Song.new("Go With Me")) }
@@ -119,13 +119,13 @@ end
119
119
  # # property :name
120
120
  # # end
121
121
 
122
- # # let (:hash_album) { Module.new do
122
+ # # let(:hash_album) { Module.new do
123
123
  # # include Representable::XML
124
124
  # # self.representation_wrap = :album
125
125
  # # property :song, :extend => hash_song, :class => Song, :as => :hit
126
126
  # # end }
127
127
 
128
- # # let (:album) { OpenStruct.new(:song => Song.new("Liar")).extend(hash_album) }
128
+ # # let(:album) { OpenStruct.new(:song => Song.new("Liar")).extend(hash_album) }
129
129
 
130
130
  # # it { album.to_xml.must_equal_xml("<album><hit><name>Liar</name></hit></album>") }
131
131
  # # #it { album.from_hash("hit" => {"name" => "Go With Me"}).must_equal OpenStruct.new(:song => Song.new("Go With Me")) }
@@ -144,7 +144,7 @@ class HashWithTypedCollectionTest < MiniTest::Spec
144
144
  end
145
145
  end
146
146
 
147
- let (:album) { Album.new([Song.new("Liar", 1), Song.new("What I Know", 2)]) }
147
+ let(:album) { Album.new([Song.new("Liar", 1), Song.new("What I Know", 2)]) }
148
148
 
149
149
  describe "#to_hash" do
150
150
  it "renders collection of typed property" do
@@ -164,7 +164,7 @@ class HashWithScalarCollectionTest < MiniTest::Spec
164
164
  Album = Struct.new(:songs)
165
165
  representer! { collection :songs }
166
166
 
167
- let (:album) { Album.new(["Jackhammer", "Terrible Man"]) }
167
+ let(:album) { Album.new(["Jackhammer", "Terrible Man"]) }
168
168
 
169
169
 
170
170
  describe "#to_hash" do
@@ -3,16 +3,16 @@ require "test_helper"
3
3
  class HeritageTest < Minitest::Spec
4
4
  module Hello
5
5
  def hello
6
- puts "Hello!"
6
+ "Hello!"
7
7
  end
8
8
  end
9
- module Ciao
9
+
10
+ module Ciao
10
11
  def ciao
11
- puts "Ciao!"
12
+ "Ciao!"
12
13
  end
13
14
  end
14
15
 
15
-
16
16
  class A < Representable::Decorator
17
17
  include Representable::Hash
18
18
 
@@ -34,15 +34,16 @@ class HeritageTest < Minitest::Spec
34
34
  property :id do end # overwrite old :id.
35
35
  end
36
36
 
37
- it do
38
- # puts A.heritage.inspect
39
- # puts B.heritage.inspect
37
+ it "B must inherit Hello! feature from A" do
38
+ B.representable_attrs.get(:id)[:extend].(nil).new(nil).hello.must_equal "Hello!"
39
+ end
40
40
 
41
- puts B.representable_attrs.get(:id)[:extend].(nil).new(nil).hello
42
- puts B.representable_attrs.get(:id)[:extend].(nil).new(nil).ciao
41
+ it "B must have Ciao from module (feauture) Ciao" do
42
+ B.representable_attrs.get(:id)[:extend].(nil).new(nil).ciao.must_equal "Ciao!"
43
+ end
43
44
 
44
- # feature Hello must be "inherited" from A and included in new C properties, too.
45
- puts C.representable_attrs.get(:id)[:extend].(nil).new(nil).hello
45
+ it "C must inherit Hello! feature from A" do
46
+ C.representable_attrs.get(:id)[:extend].(nil).new(nil).hello.must_equal "Hello!"
46
47
  end
47
48
 
48
49
  module M
@@ -56,7 +57,9 @@ class HeritageTest < Minitest::Spec
56
57
  feature Ciao
57
58
  end
58
59
 
59
- it do
60
- Object.new.extend(N).hello
60
+ let(:obj_extending_N) { Object.new.extend(N) }
61
+
62
+ it "obj should inherit from N, and N from M" do
63
+ obj_extending_N.hello.must_equal "Hello!"
61
64
  end
62
65
  end
@@ -1,7 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class IfTest < MiniTest::Spec
4
- let (:band_class) { Class.new do
4
+ let(:band_class) { Class.new do
5
5
  include Representable::Hash
6
6
  attr_accessor :fame
7
7
  self
@@ -18,14 +18,14 @@ class IfTest < MiniTest::Spec
18
18
  band_class.class_eval { property :fame, :if => lambda { |*| false } }
19
19
  band = band_class.new
20
20
  band.from_hash({"fame"=>"oh yes"})
21
- assert_equal nil, band.fame
21
+ assert_nil band.fame
22
22
  end
23
23
 
24
24
  it "ignores property when :exclude'ed even when condition is true" do
25
25
  band_class.class_eval { property :fame, :if => lambda { |*| true } }
26
26
  band = band_class.new
27
27
  band.from_hash({"fame"=>"oh yes"}, {:exclude => [:fame]})
28
- assert_equal nil, band.fame
28
+ assert_nil band.fame
29
29
  end
30
30
 
31
31
  it "executes block in instance context" do
@@ -17,8 +17,8 @@ class IncludeExcludeTest < Minitest::Spec
17
17
  end
18
18
  end
19
19
 
20
- let (:song) { Song.new("Listless", Artist.new("7yearsbadluck", 1 )) }
21
- let (:decorator) { representer.new(song) }
20
+ let(:song) { Song.new("Listless", Artist.new("7yearsbadluck", 1 )) }
21
+ let(:decorator) { representer.new(song) }
22
22
 
23
23
  describe "#from_hash" do
24
24
  it "accepts :exclude option" do
@@ -10,7 +10,7 @@ class InheritTest < MiniTest::Spec
10
10
  property :track, :as => :no
11
11
  end
12
12
 
13
- let (:song) { Song.new(Struct.new(:string).new("Roxanne"), 1) }
13
+ let(:song) { Song.new(Struct.new(:string).new("Roxanne"), 1) }
14
14
 
15
15
  describe ":inherit plain property" do
16
16
  representer! do
@@ -41,7 +41,7 @@ class InheritTest < MiniTest::Spec
41
41
  representer! do
42
42
  include SongRepresenter
43
43
 
44
- puts "passing block"
44
+ # passing block
45
45
  property :name, :inherit => true do # inherit as: title
46
46
  property :string, :as => :s
47
47
  property :length
@@ -108,7 +108,7 @@ class InheritTest < MiniTest::Spec
108
108
  end
109
109
  end
110
110
 
111
- let (:inheriting) {
111
+ let(:inheriting) {
112
112
  class InheritingDecorator < representer
113
113
  include Representable::Debug
114
114
  property :hit, :inherit => true do
@@ -1,8 +1,8 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class InlineTest < MiniTest::Spec
4
- let (:song) { Song.new("Alive") }
5
- let (:request) { representer.prepare(OpenStruct.new(:song => song)) }
4
+ let(:song) { Song.new("Alive") }
5
+ let(:request) { representer.prepare(OpenStruct.new(:song => song)) }
6
6
 
7
7
  {
8
8
  :hash => [Representable::Hash, {"song"=>{"name"=>"Alive"}}, {"song"=>{"name"=>"You've Taken Everything"}}],
@@ -19,7 +19,7 @@ class InlineTest < MiniTest::Spec
19
19
  end
20
20
  end
21
21
 
22
- let (:format) { format }
22
+ let(:format) { format }
23
23
 
24
24
  it { render(request).must_equal_document output }
25
25
  it { parse(request, input).song.name.must_equal "You've Taken Everything"}
@@ -36,7 +36,7 @@ class InlineTest < MiniTest::Spec
36
36
  collection_options ||= {}
37
37
 
38
38
  describe "[#{format}] collection with :class" do
39
- let (:request) { representer.prepare(OpenStruct.new(:songs => [song])) }
39
+ let(:request) { representer.prepare(OpenStruct.new(:songs => [song])) }
40
40
 
41
41
  representer!(:module => mod) do
42
42
  collection :songs, collection_options.merge(:class => Song) do
@@ -44,7 +44,7 @@ class InlineTest < MiniTest::Spec
44
44
  end
45
45
  end
46
46
 
47
- let (:format) { format } # FIXME: why do we have to define this?
47
+ let(:format) { format } # FIXME: why do we have to define this?
48
48
 
49
49
  it { render(request).must_equal_document output }
50
50
  it { parse(request, input).songs.first.name.must_equal "You've Taken Everything"}
@@ -83,7 +83,7 @@ class InlineTest < MiniTest::Spec
83
83
 
84
84
 
85
85
  describe "inheriting from outer representer" do
86
- let (:request) { Struct.new(:song, :requester).new(song, "Josephine") }
86
+ let(:request) { Struct.new(:song, :requester).new(song, "Josephine") }
87
87
 
88
88
  [false, true].each do |is_decorator| # test for module and decorator.
89
89
  representer!(:decorator => is_decorator) do
@@ -94,7 +94,7 @@ class InlineTest < MiniTest::Spec
94
94
  end
95
95
  end
96
96
 
97
- let (:decorator) { representer.prepare(request) }
97
+ let(:decorator) { representer.prepare(request) }
98
98
 
99
99
  it { decorator.to_hash.must_equal({"requester"=>"Josephine", "song"=>{"name"=>"Alive"}}) }
100
100
  it { decorator.from_hash({"song"=>{"name"=>"You've Taken Everything"}}).song.name.must_equal "You've Taken Everything"}
@@ -128,7 +128,7 @@ class InlineTest < MiniTest::Spec
128
128
  # end
129
129
 
130
130
  # describe ":getter with inline representer" do
131
- # let (:format) { format }
131
+ # let(:format) { format }
132
132
 
133
133
  # representer!(:module => mod) do
134
134
  # self.representation_wrap = :album
@@ -136,7 +136,7 @@ class InlineTest < MiniTest::Spec
136
136
  # property :artist, :getter => lambda { |args| represented }, :extend => ArtistRepresenter
137
137
  # end
138
138
 
139
- # let (:album) { OpenStruct.new(:label => "Epitaph").extend(representer) }
139
+ # let(:album) { OpenStruct.new(:label => "Epitaph").extend(representer) }
140
140
 
141
141
  # it "renders nested Album-properties in separate section" do
142
142
  # render(album).must_equal_document output
@@ -157,7 +157,7 @@ class InlineTest < MiniTest::Spec
157
157
  end
158
158
 
159
159
  describe ":getter with :decorator" do
160
- let (:format) { format }
160
+ let(:format) { format }
161
161
 
162
162
  representer!(:module => mod) do
163
163
  self.representation_wrap = "album"
@@ -165,7 +165,7 @@ class InlineTest < MiniTest::Spec
165
165
  property :artist, :getter => lambda { |args| represented }, :decorator => ArtistDecorator
166
166
  end
167
167
 
168
- let (:album) { OpenStruct.new(:label => "Epitaph").extend(representer) }
168
+ let(:album) { OpenStruct.new(:label => "Epitaph").extend(representer) }
169
169
 
170
170
  it "renders nested Album-properties in separate section" do
171
171
  render(album).must_equal_document output
@@ -182,7 +182,7 @@ class InlineTest < MiniTest::Spec
182
182
  }) do |format, mod, output|
183
183
 
184
184
  describe "helper method within inline representer [#{format}]" do
185
- let (:format) { format }
185
+ let(:format) { format }
186
186
 
187
187
  representer!(:module => mod, :decorator => true) do
188
188
  self.representation_wrap = :request if format == :xml
@@ -199,7 +199,7 @@ class InlineTest < MiniTest::Spec
199
199
  end
200
200
  end
201
201
 
202
- let (:request) { representer.prepare(OpenStruct.new(:song => Song.new("Alive"))) }
202
+ let(:request) { representer.prepare(OpenStruct.new(:song => Song.new("Alive"))) }
203
203
 
204
204
  it do
205
205
  render(request).must_equal_document output
@@ -55,7 +55,7 @@ class InstanceTest < BaseTest
55
55
  end
56
56
 
57
57
  it {
58
- album= Struct.new(:songs).new(songs = [
58
+ album= Struct.new(:songs).new([
59
59
  Song.new(1, "The Answer Is Still No"),
60
60
  Song.new(2, "")])
61
61
 
@@ -81,7 +81,7 @@ class InstanceTest < BaseTest
81
81
  # property :song, :instance => lambda { |*| nil }, :extend => song_representer
82
82
  # end
83
83
 
84
- # let (:hit) { hit = OpenStruct.new(:song => song).extend(representer) }
84
+ # let(:hit) { hit = OpenStruct.new(:song => song).extend(representer) }
85
85
 
86
86
  # it "calls #to_hash on song instance, nothing else" do
87
87
  # hit.to_hash.must_equal("song"=>{"title"=>"Resist Stance"})
@@ -11,14 +11,14 @@ class JSONPublicMethodsTest < Minitest::Spec
11
11
  property :name
12
12
  end
13
13
 
14
- let (:json) { '{"id":1,"name":"Rancid"}' }
14
+ let(:json) { '{"id":1,"name":"Rancid"}' }
15
15
 
16
16
  it { BandRepresenter.new(Band.new).from_json(json)[:id, :name].must_equal [1, "Rancid"] }
17
17
  it { BandRepresenter.new(Band.new).parse(json)[:id, :name].must_equal [1, "Rancid"] }
18
18
 
19
19
  #---
20
20
  # to_json
21
- let (:band) { Band.new(1, "Rancid") }
21
+ let(:band) { Band.new(1, "Rancid") }
22
22
 
23
23
  it { BandRepresenter.new(band).to_json.must_equal json }
24
24
  it { BandRepresenter.new(band).render.must_equal json }
@@ -253,9 +253,7 @@ end
253
253
  assert_json '{"songName":"22 Acacia Avenue"}', song.to_json
254
254
  end
255
255
  end
256
-
257
- end
258
-
256
+ end
259
257
 
260
258
  class CollectionTest < MiniTest::Spec
261
259
  describe "collection :name" do
@@ -363,7 +361,7 @@ end
363
361
 
364
362
  describe "parsing" do
365
363
  subject { OpenStruct.new.extend(representer) }
366
- let (:hsh) { {"7"=>{"name"=>"Contemplation"}} }
364
+ let(:hsh) { {"7"=>{"name"=>"Contemplation"}} }
367
365
 
368
366
  it "parses incoming hash" do
369
367
  subject.from_hash("songs"=>hsh).songs.must_equal({"7"=>Song.new("Contemplation")})
@@ -12,7 +12,7 @@ class LonelyRepresenterTest < MiniTest::Spec
12
12
  ) do |format, mod, output, input|
13
13
 
14
14
  describe "[#{format}] lonely collection, render-only" do # TODO: introduce :representable option?
15
- let (:format) { format }
15
+ let(:format) { format }
16
16
 
17
17
  representer!(module: mod) do
18
18
  items do
@@ -20,7 +20,7 @@ class LonelyRepresenterTest < MiniTest::Spec
20
20
  end
21
21
  end
22
22
 
23
- let (:album) { [Song.new("Resist Stance"), Song.new("Suffer")].extend(representer) }
23
+ let(:album) { [Song.new("Resist Stance"), Song.new("Suffer")].extend(representer) }
24
24
 
25
25
  it "calls #to_hash on song instances, nothing else" do
26
26
  render(album).must_equal_document(output)
@@ -36,14 +36,14 @@ class LonelyRepresenterTest < MiniTest::Spec
36
36
  property :name
37
37
  end
38
38
 
39
- let (:decorator) { rpr = representer; Class.new(Representable::Decorator) { include Representable::Hash; include rpr } }
39
+ let(:decorator) { rpr = representer; Class.new(Representable::Decorator) { include Representable::Hash; include rpr } }
40
40
 
41
41
  describe "JSON::Collection" do
42
- let (:songs) { [Song.new("Days Go By"), Song.new("Can't Take Them All")] }
43
- let (:json) { "[{\"name\":\"Days Go By\"},{\"name\":\"Can't Take Them All\"}]" }
42
+ let(:songs) { [Song.new("Days Go By"), Song.new("Can't Take Them All")] }
43
+ let(:json) { "[{\"name\":\"Days Go By\"},{\"name\":\"Can't Take Them All\"}]" }
44
44
 
45
45
  describe "with contained objects" do
46
- let (:representer) {
46
+ let(:representer) {
47
47
  Module.new do
48
48
  include Representable::JSON::Collection
49
49
  items :class => Song, :extend => SongRepresenter
@@ -80,13 +80,13 @@ class LonelyRepresenterTest < MiniTest::Spec
80
80
  end
81
81
 
82
82
  describe "with contained text" do
83
- let (:representer) {
83
+ let(:representer) {
84
84
  Module.new do
85
85
  include Representable::JSON::Collection
86
86
  end
87
87
  }
88
- let (:songs) { ["Days Go By", "Can't Take Them All"] }
89
- let (:json) { "[\"Days Go By\",\"Can't Take Them All\"]" }
88
+ let(:songs) { ["Days Go By", "Can't Take Them All"] }
89
+ let(:json) { "[\"Days Go By\",\"Can't Take Them All\"]" }
90
90
 
91
91
  it "renders contained items #to_json" do
92
92
  assert_json json, songs.extend(representer).to_json
@@ -118,14 +118,14 @@ class LonelyRepresenterTest < MiniTest::Spec
118
118
 
119
119
  describe "JSON::Hash" do # TODO: move to HashTest.
120
120
  describe "with contained objects" do
121
- let (:representer) {
121
+ let(:representer) {
122
122
  Module.new do
123
123
  include Representable::JSON::Hash
124
124
  values :class => Song, :extend => SongRepresenter
125
125
  end
126
126
  }
127
- let (:json) { "{\"one\":{\"name\":\"Days Go By\"},\"two\":{\"name\":\"Can't Take Them All\"}}" }
128
- let (:songs) { {"one" => Song.new("Days Go By"), "two" => Song.new("Can't Take Them All")} }
127
+ let(:json) { "{\"one\":{\"name\":\"Days Go By\"},\"two\":{\"name\":\"Can't Take Them All\"}}" }
128
+ let(:songs) { {"one" => Song.new("Days Go By"), "two" => Song.new("Can't Take Them All")} }
129
129
 
130
130
  describe "#to_json" do
131
131
  it "renders hash" do
@@ -178,13 +178,13 @@ class LonelyRepresenterTest < MiniTest::Spec
178
178
 
179
179
 
180
180
  describe "with scalar" do
181
- let (:representer) {
181
+ let(:representer) {
182
182
  Module.new do
183
183
  include Representable::JSON::Hash
184
184
  end
185
185
  }
186
- let (:json) { %{{"one":1,"two":2}} }
187
- let (:data) { {one: 2, two: 3} }
186
+ let(:json) { %{{"one":1,"two":2}} }
187
+ let(:data) { {one: 2, two: 3} }
188
188
 
189
189
  describe "#to_json" do
190
190
  it { data.extend(representer).to_json.must_equal %{{"one":2,"two":3}} }