representable 3.2.0 → 3.3.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 (73) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +17 -10
  3. data/.github/workflows/ci_jruby.yml +21 -0
  4. data/.github/workflows/ci_truffleruby.yml +19 -0
  5. data/CHANGES.md +5 -0
  6. data/Gemfile +1 -1
  7. data/README.md +0 -1
  8. data/lib/representable/hash/binding.rb +1 -0
  9. data/lib/representable/json.rb +14 -2
  10. data/lib/representable/version.rb +1 -1
  11. data/lib/representable/xml/binding.rb +0 -7
  12. data/lib/representable/xml.rb +7 -0
  13. data/representable.gemspec +1 -3
  14. data/test/as_test.rb +8 -13
  15. data/test/benchmarking.rb +20 -25
  16. data/test/binding_test.rb +13 -5
  17. data/test/cached_test.rb +55 -35
  18. data/test/class_test.rb +46 -33
  19. data/test/coercion_test.rb +29 -19
  20. data/test/config/inherit_test.rb +12 -17
  21. data/test/config_test.rb +5 -7
  22. data/test/decorator_scope_test.rb +13 -11
  23. data/test/decorator_test.rb +11 -11
  24. data/test/default_test.rb +2 -2
  25. data/test/defaults_options_test.rb +37 -9
  26. data/test/definition_test.rb +10 -12
  27. data/test/examples/example.rb +43 -38
  28. data/test/examples/object.rb +7 -6
  29. data/test/exec_context_test.rb +18 -23
  30. data/test/features_test.rb +29 -10
  31. data/test/filter_test.rb +29 -20
  32. data/test/for_collection_test.rb +12 -15
  33. data/test/generic_test.rb +15 -22
  34. data/test/getter_setter_test.rb +11 -6
  35. data/test/hash_bindings_test.rb +21 -12
  36. data/test/hash_test.rb +53 -38
  37. data/test/heritage_test.rb +0 -1
  38. data/test/if_test.rb +25 -21
  39. data/test/include_exclude_test.rb +24 -16
  40. data/test/inherit_test.rb +114 -27
  41. data/test/inline_test.rb +42 -33
  42. data/test/instance_test.rb +151 -109
  43. data/test/is_representable_test.rb +19 -17
  44. data/test/json_test.rb +48 -46
  45. data/test/lonely_test.rb +35 -33
  46. data/test/nested_test.rb +16 -19
  47. data/test/object_test.rb +6 -6
  48. data/test/option_test.rb +10 -8
  49. data/test/parse_pipeline_test.rb +21 -15
  50. data/test/pipeline_test.rb +144 -108
  51. data/test/populator_test.rb +18 -15
  52. data/test/prepare_test.rb +15 -17
  53. data/test/private_options_test.rb +3 -2
  54. data/test/reader_writer_test.rb +4 -4
  55. data/test/realistic_benchmark.rb +21 -27
  56. data/test/render_nil_test.rb +1 -1
  57. data/test/represent_test.rb +14 -18
  58. data/test/representable_test.rb +86 -53
  59. data/test/schema_test.rb +51 -21
  60. data/test/serialize_deserialize_test.rb +14 -14
  61. data/test/skip_test.rb +39 -28
  62. data/test/stringify_hash_test.rb +29 -31
  63. data/test/test_helper.rb +31 -25
  64. data/test/test_helper_test.rb +7 -7
  65. data/test/uncategorized_test.rb +20 -15
  66. data/test/user_options_test.rb +12 -3
  67. data/test/wrap_test.rb +27 -17
  68. data/test/xml_assertions.rb +29 -0
  69. data/test/xml_bindings_test.rb +5 -8
  70. data/test/xml_namespace_test.rb +46 -39
  71. data/test/xml_test.rb +109 -88
  72. data/test/yaml_test.rb +73 -51
  73. metadata +7 -32
data/test/class_test.rb CHANGED
@@ -1,7 +1,6 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  class ClassTest < BaseTest
4
-
5
4
  class RepresentingSong
6
5
  attr_reader :name
7
6
 
@@ -12,7 +11,6 @@ class ClassTest < BaseTest
12
11
  end
13
12
  end
14
13
 
15
-
16
14
  describe "class: ClassName, only" do
17
15
  representer! do
18
16
  property :song, :class => RepresentingSong # supposed this class exposes #from_hash itself.
@@ -25,10 +23,9 @@ class ClassTest < BaseTest
25
23
  end
26
24
  end
27
25
 
28
-
29
26
  describe "class: lambda, only" do
30
27
  representer! do
31
- property :song, :class => lambda { |*| RepresentingSong }
28
+ property :song, :class => ->(*) { RepresentingSong }
32
29
  end
33
30
 
34
31
  it "creates fresh instance and doesn't extend" do
@@ -38,11 +35,10 @@ class ClassTest < BaseTest
38
35
  end
39
36
  end
40
37
 
41
-
42
38
  # this throws a DeserializationError now.
43
39
  describe "lambda { nil }" do
44
40
  representer! do
45
- property :title, :class => nil
41
+ property :title, :class => nil
46
42
  end
47
43
 
48
44
  it do
@@ -52,54 +48,71 @@ class ClassTest < BaseTest
52
48
  end
53
49
  end
54
50
 
55
-
56
51
  describe "lambda receiving fragment and args" do
57
- let(:klass) { Class.new do
58
- class << self
59
- attr_accessor :args
60
- end
52
+ let(:klass) do
53
+ Class.new do
54
+ class << self
55
+ attr_accessor :args
56
+ end
61
57
 
62
- def from_hash(*)
63
- self.class.new
58
+ def from_hash(*)
59
+ self.class.new
60
+ end
64
61
  end
65
- end }
62
+ end
66
63
 
67
64
  representer!(:inject => :klass) do
68
65
  _klass = klass
69
- property :song, :class => lambda { |options| _klass.args=([options[:fragment],options[:user_options]]); _klass }
66
+ property :song, :class => ->(options) { _klass.args = ([options[:fragment], options[:user_options]]); _klass }
70
67
  end
71
68
 
72
- it { _(representer.prepare(OpenStruct.new).from_hash({"song" => {"name" => "Captured"}}, user_options: {volume: true}).song.class.args).
73
- must_equal([{"name"=>"Captured"}, {:volume=>true}]) }
69
+ it {
70
+ _(
71
+ representer.prepare(OpenStruct.new).from_hash(
72
+ {"song" => {"name" => "Captured"}},
73
+ user_options: {volume: true}
74
+ ).song.class.args
75
+ )
76
+ .must_equal([{"name"=>"Captured"}, {:volume=>true}])
77
+ }
74
78
  end
75
79
 
76
-
77
80
  describe "collection: lambda receiving fragment and args" do
78
- let(:klass) { Class.new do
79
- class << self
80
- attr_accessor :args
81
- end
81
+ let(:klass) do
82
+ Class.new do
83
+ class << self
84
+ attr_accessor :args
85
+ end
82
86
 
83
- def from_hash(*)
84
- self.class.new
87
+ def from_hash(*)
88
+ self.class.new
89
+ end
85
90
  end
86
- end }
91
+ end
87
92
 
88
93
  representer!(:inject => :klass) do
89
94
  _klass = klass
90
- collection :songs, :class => lambda { |options| _klass.args=([options[:fragment],options[:index],options[:user_options]]); _klass }
95
+ collection :songs, class: ->(options) {
96
+ _klass.args = ([options[:fragment], options[:index], options[:user_options]]); _klass
97
+ }
91
98
  end
92
99
 
93
- it { _(representer.prepare(OpenStruct.new).from_hash({"songs" => [{"name" => "Captured"}]}, user_options: {volume: true}).songs.first.class.args).
94
- must_equal([{"name"=>"Captured"}, 0, {:volume=>true}]) }
100
+ it {
101
+ _(
102
+ representer.prepare(OpenStruct.new).from_hash(
103
+ {"songs" => [{"name" => "Captured"}]},
104
+ user_options: {volume: true}
105
+ ).songs.first.class.args
106
+ )
107
+ .must_equal([{"name"=>"Captured"}, 0, {:volume=>true}])
108
+ }
95
109
  end
96
110
 
97
-
98
111
  describe "class: implementing #from_hash" do
99
112
  let(:parser) do
100
113
  Class.new do
101
114
  def from_hash(*)
102
- [1,2,3,4]
115
+ [1, 2, 3, 4]
103
116
  end
104
117
  end
105
118
  end
@@ -109,11 +122,11 @@ class ClassTest < BaseTest
109
122
  end
110
123
 
111
124
  it "allows returning arbitrary objects in #from_hash" do
112
- _(representer.prepare(OpenStruct.new).from_hash({"song" => 1}).song).must_equal [1,2,3,4]
125
+ _(representer.prepare(OpenStruct.new).from_hash({"song" => 1}).song).must_equal [1, 2, 3, 4]
113
126
  end
114
127
  end
115
128
  end
116
129
 
117
- #TODO: test fragment,
130
+ # TODO: test fragment,
118
131
 
119
132
  # `class: Song` only, no :extend.
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'test_helper'
4
- require 'representable/coercion'
3
+ require "test_helper"
4
+ require "representable/coercion"
5
5
 
6
- class CoercionTest < MiniTest::Spec
6
+ class CoercionTest < Minitest::Spec
7
7
  representer! do
8
8
  include Representable::Coercion
9
9
 
@@ -20,25 +20,35 @@ class CoercionTest < MiniTest::Spec
20
20
  end
21
21
 
22
22
  let(:album) do
23
- OpenStruct.new(title: 'Dire Straits', length: 41.34,
24
- band: OpenStruct.new(founded: '1977'),
25
- songs: [OpenStruct.new(ok: 1), OpenStruct.new(ok: 0)])
23
+ OpenStruct.new(
24
+ title: "Dire Straits", length: 41.34,
25
+ band: OpenStruct.new(founded: "1977"),
26
+ songs: [OpenStruct.new(ok: 1), OpenStruct.new(ok: 0)]
27
+ )
26
28
  end
27
29
 
28
30
  it do
29
- _(album.extend(representer).to_hash).must_equal({ 'title' => 'Dire Straits',
30
- 'length' => 41.34,
31
- 'band' => { 'founded' => 1977 },
32
- 'songs' => [{ 'ok' => true }, { 'ok' => false }] })
31
+ _(album.extend(representer).to_hash).must_equal(
32
+ {
33
+ "title" => "Dire Straits",
34
+ "length" => 41.34,
35
+ "band" => {"founded" => 1977},
36
+ "songs" => [{"ok" => true}, {"ok" => false}]
37
+ }
38
+ )
33
39
  end
34
40
 
35
41
  it {
36
42
  album = OpenStruct.new
37
43
  album.extend(representer)
38
- album.from_hash({ 'title' => 'Dire Straits',
39
- 'length' => '41.34',
40
- 'band' => { 'founded' => '1977' },
41
- 'songs' => [{ 'ok' => 1 }, { 'ok' => 0 }] })
44
+ album.from_hash(
45
+ {
46
+ "title" => "Dire Straits",
47
+ "length" => "41.34",
48
+ "band" => {"founded" => "1977"},
49
+ "songs" => [{"ok" => 1}, {"ok" => 0}]
50
+ }
51
+ )
42
52
 
43
53
  # it
44
54
  _(album.length).must_equal 41.34
@@ -46,18 +56,18 @@ class CoercionTest < MiniTest::Spec
46
56
  _(album.songs[0].ok).must_equal true
47
57
  }
48
58
 
49
- describe 'with user :parse_filter and :render_filter' do
59
+ describe "with user :parse_filter and :render_filter" do
50
60
  representer! do
51
61
  include Representable::Coercion
52
62
 
53
- property :length, type: Representable::Coercion::Types::Params::Float,
54
- parse_filter: ->(input, _options) { "#{input}.1" }, # happens BEFORE coercer.
63
+ property :length, type: Representable::Coercion::Types::Params::Float,
64
+ parse_filter: ->(input, _options) { "#{input}.1" }, # happens BEFORE coercer.
55
65
  render_filter: ->(fragment, *) { "#{fragment}.1" }
56
66
  end
57
67
 
58
68
  # user's :parse_filter(s) are run before coercion.
59
- it { _(OpenStruct.new.extend(representer).from_hash('length' => '1').length).must_equal 1.1 }
69
+ it { _(OpenStruct.new.extend(representer).from_hash("length" => "1").length).must_equal 1.1 }
60
70
  # user's :render_filter(s) are run before coercion.
61
- it { _(OpenStruct.new(length: 1).extend(representer).to_hash).must_equal({ 'length' => 1.1 }) }
71
+ it { _(OpenStruct.new(length: 1).extend(representer).to_hash).must_equal({"length" => 1.1}) }
62
72
  end
63
73
  end
@@ -1,8 +1,8 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  # tests defining representers in modules, decorators and classes and the inheritance when combined.
4
4
 
5
- class ConfigInheritTest < MiniTest::Spec
5
+ class ConfigInheritTest < Minitest::Spec
6
6
  def assert_cloned(child, parent, property)
7
7
  child_def = child.representable_attrs.get(property)
8
8
  parent_def = parent.representable_attrs.get(property)
@@ -20,7 +20,6 @@ class ConfigInheritTest < MiniTest::Spec
20
20
  property :genre
21
21
  end
22
22
 
23
-
24
23
  # in Decorator ------------------------------------------------
25
24
  class Decorator < Representable::Decorator
26
25
  include Representable::Hash
@@ -30,7 +29,7 @@ class ConfigInheritTest < MiniTest::Spec
30
29
  end
31
30
  end
32
31
 
33
- it { _(Decorator.definitions.keys).must_equal ["title", "artist"] }
32
+ it { _(Decorator.definitions.keys).must_equal %w[title artist] }
34
33
 
35
34
  # in inheriting Decorator
36
35
 
@@ -38,7 +37,7 @@ class ConfigInheritTest < MiniTest::Spec
38
37
  property :location
39
38
  end
40
39
 
41
- it { _(InheritingDecorator.definitions.keys).must_equal ["title", "artist", "location"] }
40
+ it { _(InheritingDecorator.definitions.keys).must_equal %w[title artist location] }
42
41
  it { assert_cloned(InheritingDecorator, Decorator, "title") }
43
42
  it do
44
43
  _(InheritingDecorator.representable_attrs.get(:artist).representer_module.object_id).wont_equal Decorator.representable_attrs.get(:artist).representer_module.object_id
@@ -51,10 +50,9 @@ class ConfigInheritTest < MiniTest::Spec
51
50
  property :location
52
51
  end
53
52
 
54
- it { _(InheritingAndIncludingDecorator.definitions.keys).must_equal ["title", "artist", "genre", "location"] }
53
+ it { _(InheritingAndIncludingDecorator.definitions.keys).must_equal %w[title artist genre location] }
55
54
  it { assert_cloned(InheritingAndIncludingDecorator, GenreModule, :genre) }
56
55
 
57
-
58
56
  # in module ---------------------------------------------------
59
57
  module Module
60
58
  include Representable
@@ -63,7 +61,6 @@ class ConfigInheritTest < MiniTest::Spec
63
61
 
64
62
  it { _(Module.definitions.keys).must_equal ["title"] }
65
63
 
66
-
67
64
  # in module including module
68
65
  module SubModule
69
66
  include Representable
@@ -72,7 +69,7 @@ class ConfigInheritTest < MiniTest::Spec
72
69
  property :location
73
70
  end
74
71
 
75
- it { _(SubModule.definitions.keys).must_equal ["title", "location"] }
72
+ it { _(SubModule.definitions.keys).must_equal %w[title location] }
76
73
  it { assert_cloned(SubModule, Module, :title) }
77
74
 
78
75
  # including preserves order
@@ -84,8 +81,7 @@ class ConfigInheritTest < MiniTest::Spec
84
81
  property :location
85
82
  end
86
83
 
87
- it { _(IncludingModule.definitions.keys).must_equal ["genre", "title", "location"] }
88
-
84
+ it { _(IncludingModule.definitions.keys).must_equal %w[genre title location] }
89
85
 
90
86
  # included in class -------------------------------------------
91
87
  class Class
@@ -93,7 +89,7 @@ class ConfigInheritTest < MiniTest::Spec
93
89
  include IncludingModule
94
90
  end
95
91
 
96
- it { _(Class.definitions.keys).must_equal ["genre", "title", "location"] }
92
+ it { _(Class.definitions.keys).must_equal %w[genre title location] }
97
93
  it { assert_cloned(Class, IncludingModule, :title) }
98
94
  it { assert_cloned(Class, IncludingModule, :location) }
99
95
  it { assert_cloned(Class, IncludingModule, :genre) }
@@ -105,7 +101,7 @@ class ConfigInheritTest < MiniTest::Spec
105
101
  include IncludingModule
106
102
  end
107
103
 
108
- it { _(DefiningClass.definitions.keys).must_equal ["street_cred", "genre", "title", "location"] }
104
+ it { _(DefiningClass.definitions.keys).must_equal %w[street_cred genre title location] }
109
105
 
110
106
  # in class
111
107
  class RepresenterClass
@@ -115,14 +111,13 @@ class ConfigInheritTest < MiniTest::Spec
115
111
 
116
112
  it { _(RepresenterClass.definitions.keys).must_equal ["title"] }
117
113
 
118
-
119
114
  # in inheriting class
120
115
  class InheritingClass < RepresenterClass
121
116
  include Representable
122
117
  property :location
123
118
  end
124
119
 
125
- it { _(InheritingClass.definitions.keys).must_equal ["title", "location"] }
120
+ it { _(InheritingClass.definitions.keys).must_equal %w[title location] }
126
121
  it { assert_cloned(InheritingClass, RepresenterClass, :title) }
127
122
 
128
123
  # in inheriting class and including
@@ -131,5 +126,5 @@ class ConfigInheritTest < MiniTest::Spec
131
126
  include GenreModule
132
127
  end
133
128
 
134
- it { _(InheritingAndIncludingClass.definitions.keys).must_equal ["title", "location", "genre"] }
135
- end
129
+ it { _(InheritingAndIncludingClass.definitions.keys).must_equal %w[title location genre] }
130
+ end
data/test/config_test.rb CHANGED
@@ -1,6 +1,6 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
- class ConfigTest < MiniTest::Spec
3
+ class ConfigTest < Minitest::Spec
4
4
  subject { Representable::Config.new(Representable::Definition) }
5
5
  PunkRock = Class.new
6
6
  Definition = Representable::Definition
@@ -64,17 +64,16 @@ class ConfigTest < MiniTest::Spec
64
64
  end
65
65
 
66
66
  describe "inherit: true" do
67
- before {
67
+ before do
68
68
  subject.add(:title, {:me => true})
69
69
  subject.add(:title, {:peer => Module, :inherit => true})
70
- }
70
+ end
71
71
 
72
72
  it { _(subject.get(:title)[:me]).must_equal true }
73
73
  it { _(subject.get(:title)[:peer]).must_equal Module }
74
74
  end
75
75
  end
76
76
 
77
-
78
77
  describe "#remove" do
79
78
  subject { Representable::Config.new(Representable::Definition) }
80
79
 
@@ -88,7 +87,6 @@ class ConfigTest < MiniTest::Spec
88
87
  end
89
88
  end
90
89
 
91
-
92
90
  describe "#each" do
93
91
  before { subject.add(:title, {:me => true}) }
94
92
 
@@ -119,4 +117,4 @@ class ConfigTest < MiniTest::Spec
119
117
  _(subject.get(:length)).must_equal length
120
118
  end
121
119
  end
122
- end
120
+ end
@@ -1,28 +1,30 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  # TODO: remove in 2.0.
4
- class DecoratorScopeTest < MiniTest::Spec
4
+ class DecoratorScopeTest < Minitest::Spec
5
5
  representer! do
6
- property :title, :getter => lambda { |*| title_from_representer }, :decorator_scope => true
6
+ property :title, :getter => ->(*) { title_from_representer }, :decorator_scope => true
7
7
  end
8
8
 
9
- let(:representer_with_method) {
9
+ let(:representer_with_method) do
10
10
  Module.new do
11
11
  include Representable::Hash
12
12
  property :title, :decorator_scope => true
13
13
  def title; "Crystal Planet"; end
14
14
  end
15
- }
15
+ end
16
16
 
17
17
  it "executes lambdas in represented context" do
18
- _(Class.new do
19
- def title_from_representer
20
- "Sounds Of Silence"
21
- end
22
- end.new.extend(representer).to_hash).must_equal({"title"=>"Sounds Of Silence"})
18
+ _(
19
+ Class.new {
20
+ def title_from_representer
21
+ "Sounds Of Silence"
22
+ end
23
+ }.new.extend(representer).to_hash
24
+ ).must_equal({"title"=>"Sounds Of Silence"})
23
25
  end
24
26
 
25
27
  it "executes method in represented context" do
26
28
  _(Object.new.extend(representer_with_method).to_hash).must_equal({"title"=>"Crystal Planet"})
27
29
  end
28
- end
30
+ end
@@ -1,6 +1,6 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
- class DecoratorTest < MiniTest::Spec
3
+ class DecoratorTest < Minitest::Spec
4
4
  class SongRepresentation < Representable::Decorator
5
5
  include Representable::JSON
6
6
  property :name
@@ -22,16 +22,16 @@ class DecoratorTest < MiniTest::Spec
22
22
  let(:song) { Song.new("Mama, I'm Coming Home") }
23
23
  let(:album) { Album.new([song]) }
24
24
 
25
- let(:rating) { OpenStruct.new(system: 'MPAA', value: 'R') }
25
+ let(:rating) { OpenStruct.new(system: "MPAA", value: "R") }
26
26
 
27
27
  describe "inheritance" do
28
28
  let(:inherited_decorator) do
29
- Class.new(AlbumRepresentation) do
29
+ Class.new(AlbumRepresentation) {
30
30
  property :best_song
31
- end.new(Album.new([song], "Stand Up"))
31
+ }.new(Album.new([song], "Stand Up"))
32
32
  end
33
33
 
34
- it { _(inherited_decorator.to_hash).must_equal({"songs"=>[{"name"=>"Mama, I'm Coming Home"}], "best_song"=>"Stand Up"}) }
34
+ it { _(inherited_decorator.to_hash).must_equal({"songs" => [{"name"=>"Mama, I'm Coming Home"}], "best_song" => "Stand Up"}) }
35
35
  end
36
36
 
37
37
  let(:decorator) { AlbumRepresentation.new(album) }
@@ -68,7 +68,6 @@ class DecoratorTest < MiniTest::Spec
68
68
  end
69
69
  end
70
70
 
71
-
72
71
  describe "inline decorators" do
73
72
  representer!(decorator: true) do
74
73
  collection :songs, :class => Song do
@@ -87,18 +86,19 @@ class DecoratorTest < MiniTest::Spec
87
86
  end
88
87
 
89
88
  require "uber/inheritable_attr"
90
- class InheritanceWithDecoratorTest < MiniTest::Spec
89
+ class InheritanceWithDecoratorTest < Minitest::Spec
91
90
  class Twin
92
91
  extend Uber::InheritableAttr
93
92
  inheritable_attr :representer_class
94
- self.representer_class = Class.new(Representable::Decorator){ include Representable::Hash }
93
+ self.representer_class = Class.new(Representable::Decorator) { include Representable::Hash }
95
94
  end
96
95
 
97
96
  class Album < Twin
98
97
  representer_class.property :title # Twin.representer_class.clone
99
98
  end
100
99
 
101
- class Song < Twin # Twin.representer_class.clone
100
+ # Twin.representer_class.clone
101
+ class Song < Twin
102
102
  end
103
103
 
104
104
  it do
@@ -106,4 +106,4 @@ class InheritanceWithDecoratorTest < MiniTest::Spec
106
106
  _(Album.representer_class.definitions.size).must_equal 1
107
107
  _(Song.representer_class.definitions.size).must_equal 0
108
108
  end
109
- end
109
+ end
data/test/default_test.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "test_helper"
2
2
 
3
- class DefaultTest < MiniTest::Spec
3
+ class DefaultTest < Minitest::Spec
4
4
  Song = Struct.new(:id, :title)
5
5
 
6
6
  representer! do
@@ -31,4 +31,4 @@ class DefaultTest < MiniTest::Spec
31
31
  _(Song.new(nil, "").extend(representer).to_hash).must_equal({"title"=>""})
32
32
  end
33
33
  end
34
- end
34
+ end
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  class DefaultsOptionsTest < BaseTest
4
4
  let(:format) { :hash }
@@ -8,7 +8,7 @@ class DefaultsOptionsTest < BaseTest
8
8
  describe "hash options combined with dynamic options" do
9
9
  representer! do
10
10
  defaults render_nil: true do |name|
11
- { as: name.to_s.upcase }
11
+ {as: name.to_s.upcase}
12
12
  end
13
13
 
14
14
  property :title
@@ -17,13 +17,20 @@ class DefaultsOptionsTest < BaseTest
17
17
  property :song_volume
18
18
  end
19
19
 
20
- it { render(prepared).must_equal_document({"TITLE" => "Revolution", "AUTHOR_NAME" => "Some author", "DESCRIPTION" => nil, "SONG_VOLUME" => 20}) }
20
+ it {
21
+ render(prepared).must_equal_document(
22
+ {
23
+ "TITLE" => "Revolution", "AUTHOR_NAME" => "Some author", "DESCRIPTION" => nil,
24
+ "SONG_VOLUME" => 20
25
+ }
26
+ )
27
+ }
21
28
  end
22
29
 
23
30
  describe "with only dynamic property options" do
24
31
  representer! do
25
32
  defaults do |name|
26
- { as: name.to_s.upcase }
33
+ {as: name.to_s.upcase}
27
34
  end
28
35
 
29
36
  property :title
@@ -45,7 +52,14 @@ class DefaultsOptionsTest < BaseTest
45
52
  property :song_volume
46
53
  end
47
54
 
48
- it { render(prepared).must_equal_document({"title" => "Revolution", "author_name" => "Some author", "description" => nil, "song_volume" => 20}) }
55
+ it {
56
+ render(prepared).must_equal_document(
57
+ {
58
+ "title" => "Revolution", "author_name" => "Some author", "description" => nil,
59
+ "song_volume" => 20
60
+ }
61
+ )
62
+ }
49
63
  end
50
64
 
51
65
  describe "direct defaults hash" do
@@ -58,13 +72,20 @@ class DefaultsOptionsTest < BaseTest
58
72
  property :song_volume
59
73
  end
60
74
 
61
- it { render(prepared).must_equal_document({"title" => "Revolution", "author_name" => "Some author", "description" => nil, "song_volume" => 20}) }
75
+ it {
76
+ render(prepared).must_equal_document(
77
+ {
78
+ "title" => "Revolution", "author_name" => "Some author", "description" => nil,
79
+ "song_volume" => 20
80
+ }
81
+ )
82
+ }
62
83
  end
63
84
 
64
85
  describe "direct defaults hash with dynamic options" do
65
86
  representer! do
66
87
  defaults render_nil: true do |name|
67
- { as: name.to_s.upcase }
88
+ {as: name.to_s.upcase}
68
89
  end
69
90
 
70
91
  property :title
@@ -73,13 +94,20 @@ class DefaultsOptionsTest < BaseTest
73
94
  property :song_volume
74
95
  end
75
96
 
76
- it { render(prepared).must_equal_document({"TITLE" => "Revolution", "AUTHOR_NAME" => "Some author", "DESCRIPTION" => nil, "SONG_VOLUME" => 20}) }
97
+ it {
98
+ render(prepared).must_equal_document(
99
+ {
100
+ "TITLE" => "Revolution", "AUTHOR_NAME" => "Some author", "DESCRIPTION" => nil,
101
+ "SONG_VOLUME" => 20
102
+ }
103
+ )
104
+ }
77
105
  end
78
106
 
79
107
  describe "prioritizes specific options" do
80
108
  representer! do
81
109
  defaults render_nil: true do |name|
82
- { as: name.to_s.upcase }
110
+ {as: name.to_s.upcase}
83
111
  end
84
112
 
85
113
  property :title