representable 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +17 -0
  3. data/CHANGES.md +25 -0
  4. data/Gemfile +4 -12
  5. data/LICENSE +1 -1
  6. data/README.md +6 -6
  7. data/Rakefile +1 -6
  8. data/TODO +1 -3
  9. data/TODO-4.0.md +72 -0
  10. data/lib/representable.rb +19 -25
  11. data/lib/representable/binding.rb +32 -12
  12. data/lib/representable/cached.rb +1 -1
  13. data/lib/representable/coercion.rb +8 -6
  14. data/lib/representable/config.rb +13 -3
  15. data/lib/representable/debug.rb +23 -15
  16. data/lib/representable/declarative.rb +12 -7
  17. data/lib/representable/decorator.rb +1 -1
  18. data/lib/representable/definition.rb +7 -3
  19. data/lib/representable/deserializer.rb +5 -4
  20. data/lib/representable/for_collection.rb +1 -1
  21. data/lib/representable/hash.rb +9 -2
  22. data/lib/representable/hash/allow_symbols.rb +9 -11
  23. data/lib/representable/hash/binding.rb +1 -0
  24. data/lib/representable/hash/collection.rb +4 -2
  25. data/lib/representable/hash_methods.rb +3 -2
  26. data/lib/representable/insert.rb +1 -1
  27. data/lib/representable/json.rb +8 -7
  28. data/lib/representable/json/collection.rb +3 -0
  29. data/lib/representable/object.rb +1 -1
  30. data/lib/representable/object/binding.rb +5 -1
  31. data/lib/representable/option.rb +19 -0
  32. data/lib/representable/pipeline.rb +3 -2
  33. data/lib/representable/pipeline_factories.rb +4 -2
  34. data/lib/representable/populator.rb +1 -1
  35. data/lib/representable/represent.rb +1 -0
  36. data/lib/representable/serializer.rb +3 -2
  37. data/lib/representable/version.rb +1 -1
  38. data/lib/representable/virtus_coercion.rb +38 -0
  39. data/lib/representable/xml.rb +12 -10
  40. data/lib/representable/xml/binding.rb +19 -13
  41. data/lib/representable/xml/namespace.rb +122 -0
  42. data/lib/representable/yaml.rb +6 -2
  43. data/lib/representable/yaml/binding.rb +1 -0
  44. data/representable.gemspec +8 -9
  45. data/test/as_test.rb +7 -7
  46. data/test/binding_test.rb +14 -14
  47. data/test/cached_test.rb +59 -49
  48. data/test/class_test.rb +9 -9
  49. data/test/coercion_test.rb +33 -22
  50. data/test/config/inherit_test.rb +14 -14
  51. data/test/config_test.rb +20 -20
  52. data/test/decorator_scope_test.rb +4 -4
  53. data/test/decorator_test.rb +33 -20
  54. data/test/default_test.rb +8 -8
  55. data/test/defaults_options_test.rb +3 -3
  56. data/test/definition_test.rb +38 -40
  57. data/test/{example.rb → examples/example.rb} +0 -1
  58. data/test/examples/object.rb +1 -5
  59. data/test/exec_context_test.rb +8 -8
  60. data/test/features_test.rb +6 -6
  61. data/test/filter_test.rb +8 -8
  62. data/test/for_collection_test.rb +10 -10
  63. data/test/generic_test.rb +13 -13
  64. data/test/getter_setter_test.rb +5 -5
  65. data/test/hash_bindings_test.rb +1 -1
  66. data/test/hash_test.rb +45 -23
  67. data/test/heritage_test.rb +16 -13
  68. data/test/if_test.rb +9 -9
  69. data/test/include_exclude_test.rb +14 -14
  70. data/test/inherit_test.rb +18 -18
  71. data/test/inline_test.rb +24 -24
  72. data/test/instance_test.rb +31 -31
  73. data/test/is_representable_test.rb +10 -10
  74. data/test/json_test.rb +29 -7
  75. data/test/lonely_test.rb +31 -31
  76. data/test/nested_test.rb +13 -13
  77. data/test/object_test.rb +9 -9
  78. data/test/option_test.rb +36 -0
  79. data/test/parse_pipeline_test.rb +3 -5
  80. data/test/pipeline_test.rb +50 -50
  81. data/test/populator_test.rb +18 -18
  82. data/test/prepare_test.rb +4 -4
  83. data/test/private_options_test.rb +2 -2
  84. data/test/reader_writer_test.rb +2 -2
  85. data/test/render_nil_test.rb +2 -2
  86. data/test/represent_test.rb +14 -14
  87. data/test/representable_test.rb +34 -36
  88. data/test/schema_test.rb +8 -11
  89. data/test/serialize_deserialize_test.rb +2 -2
  90. data/test/skip_test.rb +14 -14
  91. data/test/stringify_hash_test.rb +3 -3
  92. data/test/test_helper.rb +26 -14
  93. data/test/uncategorized_test.rb +10 -10
  94. data/test/user_options_test.rb +4 -4
  95. data/test/virtus_coercion_test.rb +52 -0
  96. data/test/wrap_test.rb +19 -19
  97. data/test/xml_bindings_test.rb +0 -4
  98. data/test/xml_namespace_test.rb +186 -0
  99. data/test/xml_test.rb +103 -43
  100. data/test/yaml_test.rb +51 -26
  101. metadata +101 -39
  102. data/.travis.yml +0 -7
  103. data/lib/representable/TODO.getting_serious +0 -11
  104. data/lib/representable/autoload.rb +0 -10
  105. data/test/mongoid_test.rb +0 -31
@@ -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
data/test/if_test.rb CHANGED
@@ -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
@@ -44,20 +44,20 @@ class IfTest < MiniTest::Spec
44
44
  subject { OpenStruct.new(:signed_contract => false, :label => "Fat") }
45
45
 
46
46
  it "skips when false" do
47
- subject.extend(representer).to_hash.must_equal({})
47
+ _(subject.extend(representer).to_hash).must_equal({})
48
48
  end
49
49
 
50
50
  it "represents when true" do
51
51
  subject.signed_contract= true
52
- subject.extend(representer).to_hash.must_equal({"label"=>"Fat"})
52
+ _(subject.extend(representer).to_hash).must_equal({"label"=>"Fat"})
53
53
  end
54
54
 
55
55
  it "works with decorator" do
56
56
  rpr = representer
57
- Class.new(Representable::Decorator) do
57
+ _(Class.new(Representable::Decorator) do
58
58
  include Representable::Hash
59
59
  include rpr
60
- end.new(subject).to_hash.must_equal({})
60
+ end.new(subject).to_hash).must_equal({})
61
61
  end
62
62
  end
63
63
 
@@ -69,11 +69,11 @@ class IfTest < MiniTest::Spec
69
69
  subject { OpenStruct.new(:name => "Outbound").extend(representer) }
70
70
 
71
71
  it "works without specifying options" do
72
- subject.to_hash.must_equal({})
72
+ _(subject.to_hash).must_equal({})
73
73
  end
74
74
 
75
75
  it "passes user options to block" do
76
- subject.to_hash(user_options: { include_name: true }).must_equal({"name" => "Outbound"})
76
+ _(subject.to_hash(user_options: { include_name: true })).must_equal({"name" => "Outbound"})
77
77
  end
78
78
  end
79
79
  end
@@ -17,22 +17,22 @@ 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
25
25
  decorator.from_hash({"title"=>"Don't Smile In Trouble", "artist"=>{"id"=>2}}, exclude: [:title])
26
26
 
27
- song.title.must_equal "Listless"
28
- song.artist.must_equal Artist.new(nil, 2)
27
+ _(song.title).must_equal "Listless"
28
+ _(song.artist).must_equal Artist.new(nil, 2)
29
29
  end
30
30
 
31
31
  it "accepts :include option" do
32
32
  decorator.from_hash({"title"=>"Don't Smile In Trouble", "artist"=>{"id"=>2}}, include: [:title])
33
33
 
34
- song.title.must_equal "Don't Smile In Trouble"
35
- song.artist.must_equal Artist.new("7yearsbadluck", 1)
34
+ _(song.title).must_equal "Don't Smile In Trouble"
35
+ _(song.artist).must_equal Artist.new("7yearsbadluck", 1)
36
36
  end
37
37
 
38
38
  it "accepts nested :exclude/:include option" do
@@ -44,30 +44,30 @@ class IncludeExcludeTest < Minitest::Spec
44
44
  }
45
45
  )
46
46
 
47
- song.title.must_equal "Listless"
48
- song.artist.must_equal Artist.new("Foo", nil, [Song.new("Listless", nil, nil)])
47
+ _(song.title).must_equal "Listless"
48
+ _(song.artist).must_equal Artist.new("Foo", nil, [Song.new("Listless", nil, nil)])
49
49
  end
50
50
  end
51
51
 
52
52
  describe "#to_hash" do
53
53
  it "accepts :exclude option" do
54
- decorator.to_hash(exclude: [:title]).must_equal({"artist"=>{"name"=>"7yearsbadluck", "id"=>1}})
54
+ _(decorator.to_hash(exclude: [:title])).must_equal({"artist"=>{"name"=>"7yearsbadluck", "id"=>1}})
55
55
  end
56
56
 
57
57
  it "accepts :include option" do
58
- decorator.to_hash(include: [:title]).must_equal({"title"=>"Listless"})
58
+ _(decorator.to_hash(include: [:title])).must_equal({"title"=>"Listless"})
59
59
  end
60
60
 
61
61
  it "accepts nested :exclude/:include option" do
62
62
  decorator = representer.new(Song.new("Listless", Artist.new("7yearsbadluck", 1, [Song.new("C.O.A.B.I.E.T.L.")])))
63
63
 
64
- decorator.to_hash(
64
+ _(decorator.to_hash(
65
65
  exclude: [:title],
66
66
  artist: {
67
67
  exclude: [:id],
68
68
  songs: { include: [:title] }
69
69
  }
70
- ).must_equal({"artist"=>{"name"=>"7yearsbadluck", "songs"=>[{"title"=>"C.O.A.B.I.E.T.L."}]}})
70
+ )).must_equal({"artist"=>{"name"=>"7yearsbadluck", "songs"=>[{"title"=>"C.O.A.B.I.E.T.L."}]}})
71
71
  end
72
72
  end
73
73
 
@@ -82,7 +82,7 @@ class IncludeExcludeTest < Minitest::Spec
82
82
 
83
83
  # FIXME: we should test all representable-options (:include, :exclude, ?)
84
84
 
85
- Cover.new("Roxanne", Cover.new("Roxanne (Don't Put On The Red Light)")).extend(cover_rpr).
86
- to_hash(:include => [:original]).must_equal({"original"=>{"title"=>"Roxanne (Don't Put On The Red Light)"}})
85
+ _(Cover.new("Roxanne", Cover.new("Roxanne (Don't Put On The Red Light)")).extend(cover_rpr).
86
+ to_hash(:include => [:original])).must_equal({"original"=>{"title"=>"Roxanne (Don't Put On The Red Light)"}})
87
87
  end
88
88
  end
data/test/inherit_test.rb CHANGED
@@ -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
@@ -19,8 +19,8 @@ class InheritTest < MiniTest::Spec
19
19
  property :track, :inherit => true, :getter => lambda { |*| "n/a" }
20
20
  end
21
21
 
22
- it { SongRepresenter.prepare(song).to_hash.must_equal({"title"=>{"str"=>"Roxanne"}, "no"=>1}) }
23
- it { representer.prepare(song).to_hash.must_equal({"title"=>{"str"=>"Roxanne"}, "no"=>"n/a"}) } # as: inherited.
22
+ it { _(SongRepresenter.prepare(song).to_hash).must_equal({"title"=>{"str"=>"Roxanne"}, "no"=>1}) }
23
+ it { _(representer.prepare(song).to_hash).must_equal({"title"=>{"str"=>"Roxanne"}, "no"=>"n/a"}) } # as: inherited.
24
24
  end
25
25
 
26
26
  describe ":inherit with empty inline representer" do
@@ -32,23 +32,23 @@ class InheritTest < MiniTest::Spec
32
32
  end
33
33
  end
34
34
 
35
- it { SongRepresenter.prepare(Song.new(Struct.new(:string).new("Believe It"), 1)).to_hash.must_equal({"title"=>{"str"=>"Believe It"}, "no"=>1}) }
35
+ it { _(SongRepresenter.prepare(Song.new(Struct.new(:string).new("Believe It"), 1)).to_hash).must_equal({"title"=>{"str"=>"Believe It"}, "no"=>1}) }
36
36
  # the block doesn't override the inline representer.
37
- it { representer.prepare( Song.new(Struct.new(:string).new("Believe It"), 1)).to_hash.must_equal({"title"=>{"str"=>"Believe It"}, "no"=>1}) }
37
+ it { _(representer.prepare( Song.new(Struct.new(:string).new("Believe It"), 1)).to_hash).must_equal({"title"=>{"str"=>"Believe It"}, "no"=>1}) }
38
38
  end
39
39
 
40
40
  describe ":inherit with overriding inline representer" do
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
48
48
  end
49
49
  end
50
50
 
51
- it { representer.prepare( Song.new(Struct.new(:string, :length).new("Believe It", 10), 1)).to_hash.must_equal({"title"=>{"s"=>"Believe It","length"=>10}, "no"=>1}) }
51
+ it { _(representer.prepare( Song.new(Struct.new(:string, :length).new("Believe It", 10), 1)).to_hash).must_equal({"title"=>{"s"=>"Believe It","length"=>10}, "no"=>1}) }
52
52
  end
53
53
 
54
54
  describe ":inherit with empty inline and options" do
@@ -60,8 +60,8 @@ class InheritTest < MiniTest::Spec
60
60
  end
61
61
  end
62
62
 
63
- it { SongRepresenter.prepare(Song.new(Struct.new(:string).new("Believe It"), 1)).to_hash.must_equal({"title"=>{"str"=>"Believe It"}, "no"=>1}) }
64
- it { representer.prepare( Song.new(Struct.new(:string).new("Believe It"), 1)).to_hash.must_equal({"name"=>{"str"=>"Believe It"}, "no"=>1}) }
63
+ it { _(SongRepresenter.prepare(Song.new(Struct.new(:string).new("Believe It"), 1)).to_hash).must_equal({"title"=>{"str"=>"Believe It"}, "no"=>1}) }
64
+ it { _(representer.prepare( Song.new(Struct.new(:string).new("Believe It"), 1)).to_hash).must_equal({"name"=>{"str"=>"Believe It"}, "no"=>1}) }
65
65
  end
66
66
 
67
67
  describe ":inherit with inline without block but options" do
@@ -71,8 +71,8 @@ class InheritTest < MiniTest::Spec
71
71
  property :name, :inherit => true, :as => :name # FIXME: add :getter or something else dynamic since this is double-wrapped.
72
72
  end
73
73
 
74
- it { SongRepresenter.prepare(Song.new(Struct.new(:string).new("Believe It"), 1)).to_hash.must_equal({"title"=>{"str"=>"Believe It"}, "no"=>1}) }
75
- it { representer.prepare( Song.new(Struct.new(:string).new("Believe It"), 1)).to_hash.must_equal({"name"=>{"str"=>"Believe It"}, "no"=>1}) }
74
+ it { _(SongRepresenter.prepare(Song.new(Struct.new(:string).new("Believe It"), 1)).to_hash).must_equal({"title"=>{"str"=>"Believe It"}, "no"=>1}) }
75
+ it { _(representer.prepare( Song.new(Struct.new(:string).new("Believe It"), 1)).to_hash).must_equal({"name"=>{"str"=>"Believe It"}, "no"=>1}) }
76
76
  end
77
77
 
78
78
 
@@ -86,12 +86,12 @@ class InheritTest < MiniTest::Spec
86
86
  end
87
87
 
88
88
  it "replaces inherited property" do
89
- representer.representable_attrs.size.must_equal 2
89
+ _(representer.representable_attrs.size).must_equal 2
90
90
 
91
91
  definition = representer.representable_attrs.get(:track) # TODO: find a better way to assert Definition identity.
92
92
  # definition.keys.size.must_equal 2
93
- definition[:representable]. must_equal true
94
- definition.name.must_equal "track" # was "no".
93
+ _(definition[:representable]). must_equal true
94
+ _(definition.name).must_equal "track" # was "no".
95
95
  end
96
96
  end
97
97
 
@@ -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
@@ -119,12 +119,12 @@ class InheritTest < MiniTest::Spec
119
119
  end
120
120
  }
121
121
 
122
- it { representer.new(OpenStruct.new(hit: OpenStruct.new(title: "I WILL BE OVERRIDDEN", :length => "2:59"))).to_hash.must_equal(
122
+ it { _(representer.new(OpenStruct.new(hit: OpenStruct.new(title: "I WILL BE OVERRIDDEN", :length => "2:59"))).to_hash).must_equal(
123
123
  {"hit"=>{"title"=>"Cheap Transistor Radio"}}) }
124
124
 
125
125
  # inheriting decorator inherits inline representer class (InlineRepresenter#title).
126
126
  # inheriting decorator adds :length.
127
- it { inheriting.new(OpenStruct.new(:hit => OpenStruct.new(:title => "Hole In Your Soul", :length => "2:59"))).to_hash.must_equal(
127
+ it { _(inheriting.new(OpenStruct.new(:hit => OpenStruct.new(:title => "Hole In Your Soul", :length => "2:59"))).to_hash).must_equal(
128
128
  {"hit"=>{"title"=>"Cheap Transistor Radio", "length"=>"2:59"}}) }
129
129
  end
130
130
 
@@ -135,7 +135,7 @@ class InheritTest < MiniTest::Spec
135
135
  property :name, :inherit => true
136
136
  end
137
137
 
138
- it { representer.prepare(Song.new("The Beginning")).to_hash.must_equal({"name"=>"The Beginning"})}
138
+ it { _(representer.prepare(Song.new("The Beginning")).to_hash).must_equal({"name"=>"The Beginning"})}
139
139
  end
140
140
  end
141
141
 
data/test/inline_test.rb CHANGED
@@ -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,10 +19,10 @@ 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
- 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
 
@@ -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,10 +44,10 @@ 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
- 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,14 +76,14 @@ 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
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,10 +94,10 @@ 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
- 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
 
@@ -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
@@ -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