representable 3.0.4 → 3.2.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 (96) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +23 -0
  3. data/CHANGES.md +14 -0
  4. data/Gemfile +4 -7
  5. data/LICENSE +1 -1
  6. data/README.md +12 -12
  7. data/Rakefile +1 -6
  8. data/lib/representable/binding.rb +32 -12
  9. data/lib/representable/cached.rb +1 -1
  10. data/lib/representable/coercion.rb +8 -6
  11. data/lib/representable/config.rb +8 -3
  12. data/lib/representable/debug.rb +23 -15
  13. data/lib/representable/declarative.rb +8 -3
  14. data/lib/representable/decorator.rb +1 -1
  15. data/lib/representable/definition.rb +7 -2
  16. data/lib/representable/deserializer.rb +4 -3
  17. data/lib/representable/for_collection.rb +1 -1
  18. data/lib/representable/hash/allow_symbols.rb +9 -11
  19. data/lib/representable/hash/binding.rb +1 -0
  20. data/lib/representable/hash/collection.rb +4 -2
  21. data/lib/representable/hash.rb +6 -2
  22. data/lib/representable/hash_methods.rb +3 -2
  23. data/lib/representable/insert.rb +1 -1
  24. data/lib/representable/json/collection.rb +3 -0
  25. data/lib/representable/json/hash.rb +1 -0
  26. data/lib/representable/json.rb +5 -7
  27. data/lib/representable/object/binding.rb +5 -1
  28. data/lib/representable/object.rb +1 -1
  29. data/lib/representable/option.rb +19 -0
  30. data/lib/representable/pipeline.rb +3 -2
  31. data/lib/representable/pipeline_factories.rb +4 -2
  32. data/lib/representable/populator.rb +1 -1
  33. data/lib/representable/represent.rb +1 -0
  34. data/lib/representable/serializer.rb +2 -1
  35. data/lib/representable/version.rb +1 -1
  36. data/lib/representable/xml/binding.rb +5 -6
  37. data/lib/representable/xml.rb +7 -10
  38. data/lib/representable/yaml/binding.rb +1 -0
  39. data/lib/representable/yaml.rb +3 -3
  40. data/lib/representable.rb +18 -25
  41. data/representable.gemspec +3 -3
  42. data/test/as_test.rb +4 -4
  43. data/test/binding_test.rb +10 -10
  44. data/test/cached_test.rb +19 -19
  45. data/test/class_test.rb +7 -7
  46. data/test/coercion_test.rb +33 -22
  47. data/test/config/inherit_test.rb +14 -14
  48. data/test/config_test.rb +18 -18
  49. data/test/decorator_scope_test.rb +3 -3
  50. data/test/decorator_test.rb +17 -17
  51. data/test/default_test.rb +7 -7
  52. data/test/definition_test.rb +32 -32
  53. data/test/{example.rb → examples/example.rb} +0 -0
  54. data/test/exec_context_test.rb +6 -6
  55. data/test/features_test.rb +3 -3
  56. data/test/filter_test.rb +6 -6
  57. data/test/for_collection_test.rb +2 -2
  58. data/test/generic_test.rb +3 -3
  59. data/test/getter_setter_test.rb +5 -5
  60. data/test/hash_test.rb +19 -19
  61. data/test/heritage_test.rb +4 -4
  62. data/test/if_test.rb +6 -6
  63. data/test/include_exclude_test.rb +12 -12
  64. data/test/inherit_test.rb +15 -15
  65. data/test/inline_test.rb +11 -11
  66. data/test/instance_test.rb +29 -29
  67. data/test/is_representable_test.rb +10 -10
  68. data/test/json_test.rb +7 -7
  69. data/test/lonely_test.rb +16 -16
  70. data/test/nested_test.rb +7 -7
  71. data/test/object_test.rb +7 -7
  72. data/test/option_test.rb +36 -0
  73. data/test/parse_pipeline_test.rb +3 -3
  74. data/test/pipeline_test.rb +43 -43
  75. data/test/populator_test.rb +15 -15
  76. data/test/prepare_test.rb +2 -2
  77. data/test/private_options_test.rb +2 -2
  78. data/test/reader_writer_test.rb +2 -2
  79. data/test/render_nil_test.rb +2 -2
  80. data/test/represent_test.rb +4 -4
  81. data/test/representable_test.rb +27 -27
  82. data/test/schema_test.rb +5 -5
  83. data/test/serialize_deserialize_test.rb +2 -2
  84. data/test/skip_test.rb +10 -10
  85. data/test/stringify_hash_test.rb +3 -3
  86. data/test/test_helper.rb +4 -2
  87. data/test/uncategorized_test.rb +10 -10
  88. data/test/user_options_test.rb +4 -4
  89. data/test/wrap_test.rb +11 -11
  90. data/test/xml_namespace_test.rb +1 -1
  91. data/test/xml_test.rb +6 -6
  92. data/test/yaml_test.rb +20 -20
  93. metadata +16 -11
  94. data/.travis.yml +0 -16
  95. data/lib/representable/autoload.rb +0 -14
  96. data/test/mongoid_test.rb +0 -31
@@ -9,8 +9,8 @@ class ConfigInheritTest < MiniTest::Spec
9
9
 
10
10
  child_def.merge!(:alias => property)
11
11
 
12
- child_def[:alias].wont_equal parent_def[:alias]
13
- child_def.object_id.wont_equal parent_def.object_id
12
+ _(child_def[:alias]).wont_equal parent_def[:alias]
13
+ _(child_def.object_id).wont_equal parent_def.object_id
14
14
  end
15
15
  # class Object
16
16
 
@@ -30,7 +30,7 @@ class ConfigInheritTest < MiniTest::Spec
30
30
  end
31
31
  end
32
32
 
33
- it { Decorator.definitions.keys.must_equal ["title", "artist"] }
33
+ it { _(Decorator.definitions.keys).must_equal ["title", "artist"] }
34
34
 
35
35
  # in inheriting Decorator
36
36
 
@@ -38,10 +38,10 @@ class ConfigInheritTest < MiniTest::Spec
38
38
  property :location
39
39
  end
40
40
 
41
- it { InheritingDecorator.definitions.keys.must_equal ["title", "artist", "location"] }
41
+ it { _(InheritingDecorator.definitions.keys).must_equal ["title", "artist", "location"] }
42
42
  it { assert_cloned(InheritingDecorator, Decorator, "title") }
43
43
  it do
44
- InheritingDecorator.representable_attrs.get(:artist).representer_module.object_id.wont_equal Decorator.representable_attrs.get(:artist).representer_module.object_id
44
+ _(InheritingDecorator.representable_attrs.get(:artist).representer_module.object_id).wont_equal Decorator.representable_attrs.get(:artist).representer_module.object_id
45
45
  end
46
46
 
47
47
  # in inheriting and including Decorator
@@ -51,7 +51,7 @@ class ConfigInheritTest < MiniTest::Spec
51
51
  property :location
52
52
  end
53
53
 
54
- it { InheritingAndIncludingDecorator.definitions.keys.must_equal ["title", "artist", "genre", "location"] }
54
+ it { _(InheritingAndIncludingDecorator.definitions.keys).must_equal ["title", "artist", "genre", "location"] }
55
55
  it { assert_cloned(InheritingAndIncludingDecorator, GenreModule, :genre) }
56
56
 
57
57
 
@@ -61,7 +61,7 @@ class ConfigInheritTest < MiniTest::Spec
61
61
  property :title
62
62
  end
63
63
 
64
- it { Module.definitions.keys.must_equal ["title"] }
64
+ it { _(Module.definitions.keys).must_equal ["title"] }
65
65
 
66
66
 
67
67
  # in module including module
@@ -72,7 +72,7 @@ class ConfigInheritTest < MiniTest::Spec
72
72
  property :location
73
73
  end
74
74
 
75
- it { SubModule.definitions.keys.must_equal ["title", "location"] }
75
+ it { _(SubModule.definitions.keys).must_equal ["title", "location"] }
76
76
  it { assert_cloned(SubModule, Module, :title) }
77
77
 
78
78
  # including preserves order
@@ -84,7 +84,7 @@ class ConfigInheritTest < MiniTest::Spec
84
84
  property :location
85
85
  end
86
86
 
87
- it { IncludingModule.definitions.keys.must_equal ["genre", "title", "location"] }
87
+ it { _(IncludingModule.definitions.keys).must_equal ["genre", "title", "location"] }
88
88
 
89
89
 
90
90
  # included in class -------------------------------------------
@@ -93,7 +93,7 @@ class ConfigInheritTest < MiniTest::Spec
93
93
  include IncludingModule
94
94
  end
95
95
 
96
- it { Class.definitions.keys.must_equal ["genre", "title", "location"] }
96
+ it { _(Class.definitions.keys).must_equal ["genre", "title", "location"] }
97
97
  it { assert_cloned(Class, IncludingModule, :title) }
98
98
  it { assert_cloned(Class, IncludingModule, :location) }
99
99
  it { assert_cloned(Class, IncludingModule, :genre) }
@@ -105,7 +105,7 @@ class ConfigInheritTest < MiniTest::Spec
105
105
  include IncludingModule
106
106
  end
107
107
 
108
- it { DefiningClass.definitions.keys.must_equal ["street_cred", "genre", "title", "location"] }
108
+ it { _(DefiningClass.definitions.keys).must_equal ["street_cred", "genre", "title", "location"] }
109
109
 
110
110
  # in class
111
111
  class RepresenterClass
@@ -113,7 +113,7 @@ class ConfigInheritTest < MiniTest::Spec
113
113
  property :title
114
114
  end
115
115
 
116
- it { RepresenterClass.definitions.keys.must_equal ["title"] }
116
+ it { _(RepresenterClass.definitions.keys).must_equal ["title"] }
117
117
 
118
118
 
119
119
  # in inheriting class
@@ -122,7 +122,7 @@ class ConfigInheritTest < MiniTest::Spec
122
122
  property :location
123
123
  end
124
124
 
125
- it { InheritingClass.definitions.keys.must_equal ["title", "location"] }
125
+ it { _(InheritingClass.definitions.keys).must_equal ["title", "location"] }
126
126
  it { assert_cloned(InheritingClass, RepresenterClass, :title) }
127
127
 
128
128
  # in inheriting class and including
@@ -131,5 +131,5 @@ class ConfigInheritTest < MiniTest::Spec
131
131
  include GenreModule
132
132
  end
133
133
 
134
- it { InheritingAndIncludingClass.definitions.keys.must_equal ["title", "location", "genre"] }
134
+ it { _(InheritingAndIncludingClass.definitions.keys).must_equal ["title", "location", "genre"] }
135
135
  end
data/test/config_test.rb CHANGED
@@ -23,7 +23,7 @@ class ConfigTest < MiniTest::Spec
23
23
 
24
24
  describe "#[]" do
25
25
  # does return nil for non-existent
26
- it { subject[:hello].must_be_nil }
26
+ it { _(subject[:hello]).must_be_nil }
27
27
  end
28
28
 
29
29
  # describe "#[]" do
@@ -44,23 +44,23 @@ class ConfigTest < MiniTest::Spec
44
44
  # #add returns Definition.`
45
45
  subject = Representable::Config.new(Representable::Definition).add(:title, {:me => true})
46
46
 
47
- subject.must_be_kind_of Representable::Definition
48
- subject[:me].must_equal true
47
+ _(subject).must_be_kind_of Representable::Definition
48
+ _(subject[:me]).must_equal true
49
49
  end
50
50
  end
51
51
 
52
52
  before { subject.add(:title, {:me => true}) }
53
53
 
54
54
  # must be kind of Definition
55
- it { subject.size.must_equal 1 }
56
- it { subject.get(:title).name.must_equal "title" }
57
- it { subject.get(:title)[:me].must_equal true }
55
+ it { _(subject.size).must_equal 1 }
56
+ it { _(subject.get(:title).name).must_equal "title" }
57
+ it { _(subject.get(:title)[:me]).must_equal true }
58
58
 
59
59
  # this is actually tested in context in inherit_test.
60
60
  it "overrides former definition" do
61
61
  subject.add(:title, {:peer => Module})
62
- subject.get(:title)[:me].must_be_nil
63
- subject.get(:title)[:peer].must_equal Module
62
+ _(subject.get(:title)[:me]).must_be_nil
63
+ _(subject.get(:title)[:peer]).must_equal Module
64
64
  end
65
65
 
66
66
  describe "inherit: true" do
@@ -69,8 +69,8 @@ class ConfigTest < MiniTest::Spec
69
69
  subject.add(:title, {:peer => Module, :inherit => true})
70
70
  }
71
71
 
72
- it { subject.get(:title)[:me].must_equal true }
73
- it { subject.get(:title)[:peer].must_equal Module }
72
+ it { _(subject.get(:title)[:me]).must_equal true }
73
+ it { _(subject.get(:title)[:peer]).must_equal Module }
74
74
  end
75
75
  end
76
76
 
@@ -81,10 +81,10 @@ class ConfigTest < MiniTest::Spec
81
81
  it do
82
82
  subject.add(:title, {:me => true})
83
83
  subject.add(:genre, {})
84
- subject.get(:genre).must_be_kind_of Representable::Definition
84
+ _(subject.get(:genre)).must_be_kind_of Representable::Definition
85
85
 
86
86
  subject.remove(:genre)
87
- subject.get(:genre).must_be_nil
87
+ _(subject.get(:genre)).must_be_nil
88
88
  end
89
89
  end
90
90
 
@@ -95,16 +95,16 @@ class ConfigTest < MiniTest::Spec
95
95
  it "what" do
96
96
  definitions = []
97
97
  subject.each { |dfn| definitions << dfn }
98
- definitions.size.must_equal 1
99
- definitions[0][:me].must_equal true
98
+ _(definitions.size).must_equal 1
99
+ _(definitions[0][:me]).must_equal true
100
100
  end
101
101
  end
102
102
 
103
103
  describe "#options" do
104
- it { subject.options.must_equal({}) }
104
+ it { _(subject.options).must_equal({}) }
105
105
  it do
106
106
  subject.options[:namespacing] = true
107
- subject.options[:namespacing].must_equal true
107
+ _(subject.options[:namespacing]).must_equal true
108
108
  end
109
109
  end
110
110
 
@@ -115,8 +115,8 @@ class ConfigTest < MiniTest::Spec
115
115
  title = subject.add(:title, {})
116
116
  length = subject.add(:length, {})
117
117
 
118
- subject.get(:title).must_equal title
119
- subject.get(:length).must_equal length
118
+ _(subject.get(:title)).must_equal title
119
+ _(subject.get(:length)).must_equal length
120
120
  end
121
121
  end
122
122
  end
@@ -15,14 +15,14 @@ class DecoratorScopeTest < MiniTest::Spec
15
15
  }
16
16
 
17
17
  it "executes lambdas in represented context" do
18
- Class.new do
18
+ _(Class.new do
19
19
  def title_from_representer
20
20
  "Sounds Of Silence"
21
21
  end
22
- end.new.extend(representer).to_hash.must_equal({"title"=>"Sounds Of Silence"})
22
+ end.new.extend(representer).to_hash).must_equal({"title"=>"Sounds Of Silence"})
23
23
  end
24
24
 
25
25
  it "executes method in represented context" do
26
- Object.new.extend(representer_with_method).to_hash.must_equal({"title"=>"Crystal Planet"})
26
+ _(Object.new.extend(representer_with_method).to_hash).must_equal({"title"=>"Crystal Planet"})
27
27
  end
28
28
  end
@@ -31,7 +31,7 @@ class DecoratorTest < MiniTest::Spec
31
31
  end.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) }
@@ -39,32 +39,32 @@ class DecoratorTest < MiniTest::Spec
39
39
  let(:rating_decorator) { RatingRepresentation.new(rating) }
40
40
 
41
41
  it "renders" do
42
- decorator.to_hash.must_equal({"songs"=>[{"name"=>"Mama, I'm Coming Home"}]})
43
- album.wont_respond_to :to_hash
44
- song.wont_respond_to :to_hash # DISCUSS: weak test, how to assert blank slate?
42
+ _(decorator.to_hash).must_equal({"songs"=>[{"name"=>"Mama, I'm Coming Home"}]})
43
+ _(album).wont_respond_to :to_hash
44
+ _(song).wont_respond_to :to_hash # DISCUSS: weak test, how to assert blank slate?
45
45
  # no @representable_attrs in decorated objects
46
- song.wont_be(:instance_variable_defined?, :@representable_attrs)
46
+ _(song).wont_be(:instance_variable_defined?, :@representable_attrs)
47
47
 
48
- rating_decorator.to_hash.must_equal({"system" => "MPAA", "value" => "R"})
48
+ _(rating_decorator.to_hash).must_equal({"system" => "MPAA", "value" => "R"})
49
49
  end
50
50
 
51
51
  describe "#from_hash" do
52
52
  it "returns represented" do
53
- decorator.from_hash({"songs"=>[{"name"=>"Mama, I'm Coming Home"}]}).must_equal album
53
+ _(decorator.from_hash({"songs"=>[{"name"=>"Mama, I'm Coming Home"}]})).must_equal album
54
54
  end
55
55
 
56
56
  it "parses" do
57
57
  decorator.from_hash({"songs"=>[{"name"=>"Atomic Garden"}]})
58
- album.songs.first.must_be_kind_of Song
59
- album.songs.must_equal [Song.new("Atomic Garden")]
60
- album.wont_respond_to :to_hash
61
- song.wont_respond_to :to_hash # DISCUSS: weak test, how to assert blank slate?
58
+ _(album.songs.first).must_be_kind_of Song
59
+ _(album.songs).must_equal [Song.new("Atomic Garden")]
60
+ _(album).wont_respond_to :to_hash
61
+ _(song).wont_respond_to :to_hash # DISCUSS: weak test, how to assert blank slate?
62
62
  end
63
63
  end
64
64
 
65
65
  describe "#decorated" do
66
66
  it "is aliased to #represented" do
67
- AlbumRepresentation.prepare(album).decorated.must_equal album
67
+ _(AlbumRepresentation.prepare(album).decorated).must_equal album
68
68
  end
69
69
  end
70
70
 
@@ -80,8 +80,8 @@ class DecoratorTest < MiniTest::Spec
80
80
  representer.new(album).from_hash({"songs"=>[{"name"=>"Atomic Garden"}]})
81
81
 
82
82
  # no @representable_attrs in decorated objects
83
- song.wont_be(:instance_variable_defined?, :@representable_attrs)
84
- album.wont_be(:instance_variable_defined?, :@representable_attrs)
83
+ _(song).wont_be(:instance_variable_defined?, :@representable_attrs)
84
+ _(album).wont_be(:instance_variable_defined?, :@representable_attrs)
85
85
  end
86
86
  end
87
87
  end
@@ -102,8 +102,8 @@ class InheritanceWithDecoratorTest < MiniTest::Spec
102
102
  end
103
103
 
104
104
  it do
105
- Twin.representer_class.definitions.size.must_equal 0
106
- Album.representer_class.definitions.size.must_equal 1
107
- Song.representer_class.definitions.size.must_equal 0
105
+ _(Twin.representer_class.definitions.size).must_equal 0
106
+ _(Album.representer_class.definitions.size).must_equal 1
107
+ _(Song.representer_class.definitions.size).must_equal 0
108
108
  end
109
109
  end
data/test/default_test.rb CHANGED
@@ -11,24 +11,24 @@ class DefaultTest < MiniTest::Spec
11
11
  describe "#from_hash" do
12
12
  let(:song) { Song.new.extend(representer) }
13
13
 
14
- it { song.from_hash({}).must_equal Song.new(nil, "Huber Breeze") }
14
+ it { _(song.from_hash({})).must_equal Song.new(nil, "Huber Breeze") }
15
15
  # default doesn't apply when empty string.
16
- it { song.from_hash({"title"=>""}).must_equal Song.new(nil, "") }
17
- it { song.from_hash({"title"=>nil}).must_equal Song.new(nil, nil) }
18
- it { song.from_hash({"title"=>"Blindfold"}).must_equal Song.new(nil, "Blindfold") }
16
+ it { _(song.from_hash({"title"=>""})).must_equal Song.new(nil, "") }
17
+ it { _(song.from_hash({"title"=>nil})).must_equal Song.new(nil, nil) }
18
+ it { _(song.from_hash({"title"=>"Blindfold"})).must_equal Song.new(nil, "Blindfold") }
19
19
  end
20
20
 
21
21
  describe "#to_json" do
22
22
  it "uses :default when not available from object" do
23
- Song.new.extend(representer).to_hash.must_equal({"title"=>"Huber Breeze"})
23
+ _(Song.new.extend(representer).to_hash).must_equal({"title"=>"Huber Breeze"})
24
24
  end
25
25
 
26
26
  it "uses value from represented object when present" do
27
- Song.new(nil, "After The War").extend(representer).to_hash.must_equal({"title"=>"After The War"})
27
+ _(Song.new(nil, "After The War").extend(representer).to_hash).must_equal({"title"=>"After The War"})
28
28
  end
29
29
 
30
30
  it "uses value from represented object when emtpy string" do
31
- Song.new(nil, "").extend(representer).to_hash.must_equal({"title"=>""})
31
+ _(Song.new(nil, "").extend(representer).to_hash).must_equal({"title"=>""})
32
32
  end
33
33
  end
34
34
  end
@@ -12,22 +12,22 @@ class DefinitionTest < MiniTest::Spec
12
12
  options[:parse_filter] << 1
13
13
 
14
14
  # default variables
15
- options[:as].must_be_nil
16
- options[:extend].must_equal Module
15
+ _(options[:as]).must_be_nil
16
+ _(options[:extend]).must_equal Module
17
17
  end
18
- definition.name.must_equal "song"
18
+ _(definition.name).must_equal "song"
19
19
 
20
20
  #
21
- definition[:awesome].must_equal true
22
- definition[:parse_filter].must_equal Representable::Pipeline[1]
23
- definition[:render_filter].must_equal Representable::Pipeline[]
21
+ _(definition[:awesome]).must_equal true
22
+ _(definition[:parse_filter]).must_equal Representable::Pipeline[1]
23
+ _(definition[:render_filter]).must_equal Representable::Pipeline[]
24
24
  end
25
25
  end
26
26
 
27
27
  describe "#[]" do
28
28
  let(:definition) { Definition.new(:song) }
29
29
  # default is nil.
30
- it { definition[:bla].must_be_nil }
30
+ it { _(definition[:bla]).must_be_nil }
31
31
  end
32
32
 
33
33
  # merge!
@@ -35,11 +35,11 @@ class DefinitionTest < MiniTest::Spec
35
35
  let(:definition) { Definition.new(:song, :whatever => true) }
36
36
 
37
37
  # merges new options.
38
- it { definition.merge!(:something => true)[:something].must_equal true }
38
+ it { _(definition.merge!(:something => true)[:something]).must_equal true }
39
39
  # doesn't override original options.
40
- it { definition.merge!({:something => true})[:whatever].must_equal true }
40
+ it { _(definition.merge!({:something => true})[:whatever]).must_equal true }
41
41
  # override original when passed in #merge!.
42
- it { definition.merge!({:whatever => false})[:whatever].must_equal false }
42
+ it { _(definition.merge!({:whatever => false})[:whatever]).must_equal false }
43
43
 
44
44
  # with block
45
45
  it do
@@ -52,10 +52,10 @@ class DefinitionTest < MiniTest::Spec
52
52
  # options[:extend].must_equal Module
53
53
  end
54
54
 
55
- definition[:awesome].must_equal true
56
- definition[:something].must_equal true
57
- definition[:render_filter].must_equal Representable::Pipeline[1]
58
- definition[:parse_filter].must_equal Representable::Pipeline[]
55
+ _(definition[:awesome]).must_equal true
56
+ _(definition[:something]).must_equal true
57
+ _(definition[:render_filter]).must_equal Representable::Pipeline[1]
58
+ _(definition[:parse_filter]).must_equal Representable::Pipeline[]
59
59
  end
60
60
 
61
61
  describe "with :parse_filter" do
@@ -65,18 +65,18 @@ class DefinitionTest < MiniTest::Spec
65
65
  it do
66
66
  merged = definition.merge!(:parse_filter => 2)[:parse_filter]
67
67
 
68
- merged.must_be_kind_of Representable::Pipeline
69
- merged.size.must_equal 2
68
+ _(merged).must_be_kind_of Representable::Pipeline
69
+ _(merged.size).must_equal 2
70
70
  end
71
71
 
72
72
  # :parse_filter can also be array.
73
- it { definition.merge!(:parse_filter => [2, 3])[:parse_filter].size.must_equal 3 }
73
+ it { _(definition.merge!(:parse_filter => [2, 3])[:parse_filter].size).must_equal 3 }
74
74
  end
75
75
 
76
76
  # does not change arguments
77
77
  it do
78
78
  Definition.new(:title).merge!(options = {:whatever => 1})
79
- options.must_equal(:whatever => 1)
79
+ _(options).must_equal(:whatever => 1)
80
80
  end
81
81
  end
82
82
 
@@ -85,14 +85,14 @@ class DefinitionTest < MiniTest::Spec
85
85
  describe "#delete!" do
86
86
  let(:definition) { Definition.new(:song, serialize: "remove me!") }
87
87
 
88
- before { definition[:serialize].(nil).must_equal "remove me!" }
88
+ before { _(definition[:serialize].(nil)).must_equal "remove me!" }
89
89
 
90
- it { definition.delete!(:serialize)[:serialize].must_be_nil }
90
+ it { _(definition.delete!(:serialize)[:serialize]).must_be_nil }
91
91
  end
92
92
 
93
93
  # #inspect
94
94
  describe "#inspect" do
95
- it { Definition.new(:songs).inspect.must_equal "#<Representable::Definition ==>songs @options={:name=>\"songs\", :parse_filter=>[], :render_filter=>[]}>" }
95
+ it { _(Definition.new(:songs).inspect).must_equal "#<Representable::Definition ==>songs @options={:name=>\"songs\", :parse_filter=>[], :render_filter=>[]}>" }
96
96
  end
97
97
 
98
98
 
@@ -108,7 +108,7 @@ class DefinitionTest < MiniTest::Spec
108
108
 
109
109
  describe "#typed?" do
110
110
  it "is false per default" do
111
- assert ! @def.typed?
111
+ refute @def.typed?
112
112
  end
113
113
 
114
114
  it "is true when :class is present" do
@@ -127,7 +127,7 @@ class DefinitionTest < MiniTest::Spec
127
127
 
128
128
  describe "#representable?" do
129
129
  it { assert Definition.new(:song, :representable => true).representable? }
130
- it { Definition.new(:song, :representable => true, :extend => Object).representable?.must_equal true }
130
+ it { _(Definition.new(:song, :representable => true, :extend => Object).representable?).must_equal true }
131
131
  it { refute Definition.new(:song, :representable => false, :extend => Object).representable? }
132
132
  it { assert Definition.new(:song, :extend => Object).representable? }
133
133
  it { refute Definition.new(:song).representable? }
@@ -150,16 +150,16 @@ class DefinitionTest < MiniTest::Spec
150
150
  it do
151
151
  dfn = Representable::Definition.new(:songs, nested: Module)
152
152
  assert dfn.typed?
153
- dfn[:extend].(nil).must_equal Module
153
+ _(dfn[:extend].(nil)).must_equal Module
154
154
  end
155
155
  end
156
156
 
157
157
 
158
158
  describe "#clone" do
159
- subject { Representable::Definition.new(:title, :volume => 9, :clonable => Declarative::Option(1)) }
159
+ subject { Representable::Definition.new(:title, :volume => 9, :clonable => ::Representable::Option(1)) }
160
160
 
161
- it { subject.clone.must_be_kind_of Representable::Definition }
162
- it { subject.clone[:clonable].(nil).must_equal 1 }
161
+ it { _(subject.clone).must_be_kind_of Representable::Definition }
162
+ it { _(subject.clone[:clonable].(nil)).must_equal 1 }
163
163
 
164
164
  it "clones @options" do
165
165
  @def.merge!(:volume => 9)
@@ -175,11 +175,11 @@ class DefinitionTest < MiniTest::Spec
175
175
 
176
176
  describe "#has_default?" do
177
177
  it "returns false if no :default set" do
178
- assert_equal false, Representable::Definition.new(:song).has_default?
178
+ refute Representable::Definition.new(:song).has_default?
179
179
  end
180
180
 
181
181
  it "returns true if :default set" do
182
- assert_equal true, Representable::Definition.new(:song, :default => nil).has_default?
182
+ assert Representable::Definition.new(:song, :default => nil).has_default?
183
183
  end
184
184
  end
185
185
 
@@ -190,14 +190,14 @@ class DefinitionTest < MiniTest::Spec
190
190
  end
191
191
 
192
192
  it "returns false when :binding is not set" do
193
- assert !Representable::Definition.new(:songs)[:binding]
193
+ refute Representable::Definition.new(:songs)[:binding]
194
194
  end
195
195
  end
196
196
 
197
197
  describe "#create_binding" do
198
198
  it "executes the block (without special context)" do
199
199
  definition = Representable::Definition.new(:title, :binding => lambda { |*args| @binding = Representable::Binding.new(*args) })
200
- definition.create_binding.must_equal @binding
200
+ _(definition.create_binding).must_equal @binding
201
201
  end
202
202
  end
203
203
 
@@ -231,7 +231,7 @@ class DefinitionTest < MiniTest::Spec
231
231
 
232
232
  it "responds to #hash?" do
233
233
  assert @def.hash?
234
- assert ! Representable::Definition.new(:songs).hash?
234
+ refute Representable::Definition.new(:songs).hash?
235
235
  end
236
236
  end
237
237
 
File without changes
@@ -17,7 +17,7 @@ class ExecContextTest < MiniTest::Spec
17
17
  end
18
18
 
19
19
  it { render(song).must_equal_document output }
20
- it { parse(song, input).name.must_equal "Rebel Fate" }
20
+ it { _(parse(song, input).name).must_equal "Rebel Fate" }
21
21
  end
22
22
 
23
23
 
@@ -27,7 +27,7 @@ class ExecContextTest < MiniTest::Spec
27
27
  end
28
28
 
29
29
  it { render(song).must_equal_document output }
30
- it { parse(song, input).name.must_equal "Rebel Fate" }
30
+ it { _(parse(song, input).name).must_equal "Rebel Fate" }
31
31
  end
32
32
 
33
33
 
@@ -41,7 +41,7 @@ class ExecContextTest < MiniTest::Spec
41
41
  end
42
42
 
43
43
  it { render(song).must_equal_document({Representable::Hash::Binding => "name"}) }
44
- it { parse(song, {Representable::Hash::Binding => "Rebel Fate"}).name.must_equal "Rebel Fate" }
44
+ it { _(parse(song, {Representable::Hash::Binding => "Rebel Fate"}).name).must_equal "Rebel Fate" }
45
45
  end
46
46
 
47
47
 
@@ -53,7 +53,7 @@ class ExecContextTest < MiniTest::Spec
53
53
  end
54
54
 
55
55
  it { render(song).must_equal_document output }
56
- it { parse(song, input).name.must_equal "Rebel Fate" }
56
+ it { _(parse(song, input).name).must_equal "Rebel Fate" }
57
57
  end
58
58
 
59
59
 
@@ -71,7 +71,7 @@ class ExecContextTest < MiniTest::Spec
71
71
  end
72
72
 
73
73
  it { render(song).must_equal_document({Representable::Decorator=>"Timebomb"}) }
74
- it { parse(song, {Representable::Decorator=>"Listless"}).name.must_equal "Listless" }
74
+ it { _(parse(song, {Representable::Decorator=>"Listless"}).name).must_equal "Listless" }
75
75
  end
76
76
 
77
77
 
@@ -86,7 +86,7 @@ class ExecContextTest < MiniTest::Spec
86
86
  end
87
87
 
88
88
  it { render(song).must_equal_document({Representable::Hash::Binding => "name"}) }
89
- it("xxx") { parse(song, {Representable::Hash::Binding => "Rebel Fate"}).name.must_equal "Rebel Fate" }
89
+ it("xxx") { _(parse(song, {Representable::Hash::Binding => "Rebel Fate"}).name).must_equal "Rebel Fate" }
90
90
  end
91
91
  end
92
92
  end
@@ -27,7 +27,7 @@ class FeaturesTest < MiniTest::Spec
27
27
  instance_exec(&definition)
28
28
  end
29
29
 
30
- it { song.extend(representer).to_hash.must_equal({"title"=>"Is It A Lie", "length"=>"2:31", "details"=>{"title"=>"Is It A Lie"}}) }
30
+ it { _(song.extend(representer).to_hash).must_equal({"title"=>"Is It A Lie", "length"=>"2:31", "details"=>{"title"=>"Is It A Lie"}}) }
31
31
  end
32
32
 
33
33
 
@@ -36,7 +36,7 @@ class FeaturesTest < MiniTest::Spec
36
36
  instance_exec(&definition)
37
37
  end
38
38
 
39
- it { representer.new(song).to_hash.must_equal({"title"=>"Is It A Lie", "length"=>"2:31", "details"=>{"title"=>"Is It A Lie"}}) }
39
+ it { _(representer.new(song).to_hash).must_equal({"title"=>"Is It A Lie", "length"=>"2:31", "details"=>{"title"=>"Is It A Lie"}}) }
40
40
  end
41
41
  end
42
42
 
@@ -65,6 +65,6 @@ class FeatureInclusionOrderTest < MiniTest::Spec
65
65
  end
66
66
 
67
67
  it do
68
- representer.new(OpenStruct.new(song: Object)).to_hash.must_equal({"title"=>"I am number two, I was first!", "song"=>{"title"=>"I am number two, I was first!"}})
68
+ _(representer.new(OpenStruct.new(song: Object)).to_hash).must_equal({"title"=>"I am number two, I was first!", "song"=>{"title"=>"I am number two, I was first!"}})
69
69
  end
70
70
  end
data/test/filter_test.rb CHANGED
@@ -6,7 +6,7 @@ class FilterPipelineTest < MiniTest::Spec
6
6
 
7
7
  subject { Representable::Pipeline[block1, block2] }
8
8
 
9
- it { subject.call("Horowitz", {}).must_equal "2: 1: Horowitz" }
9
+ it { _(subject.call("Horowitz", {})).must_equal "2: 1: Horowitz" }
10
10
  end
11
11
 
12
12
 
@@ -22,11 +22,11 @@ class FilterTest < MiniTest::Spec
22
22
  # gets doc and options.
23
23
  it {
24
24
  song = OpenStruct.new.extend(representer).from_hash("title" => "VULCAN EARS", "track" => "Nine")
25
- song.title.must_equal "VULCAN EARS"
26
- song.track.must_equal "nine,{\"title\"=>\"VULCAN EARS\", \"track\"=>\"Nine\"}"
25
+ _(song.title).must_equal "VULCAN EARS"
26
+ _(song.track).must_equal "nine,{\"title\"=>\"VULCAN EARS\", \"track\"=>\"Nine\"}"
27
27
  }
28
28
 
29
- it { OpenStruct.new("title" => "vulcan ears", "track" => "Nine").extend(representer).to_hash.must_equal( {"title"=>"vulcan ears", "track"=>"NINE,{\"title\"=>\"vulcan ears\"},{}"}) }
29
+ it { _(OpenStruct.new("title" => "vulcan ears", "track" => "Nine").extend(representer).to_hash).must_equal( {"title"=>"vulcan ears", "track"=>"NINE,{\"title\"=>\"vulcan ears\"},{}"}) }
30
30
 
31
31
 
32
32
  describe "#parse_filter" do
@@ -41,8 +41,8 @@ class FilterTest < MiniTest::Spec
41
41
  end
42
42
 
43
43
  # order matters.
44
- it { OpenStruct.new.extend(representer).from_hash("track" => "Nine").track.must_equal "Nine-1-2" }
45
- it { OpenStruct.new("track" => "Nine").extend(representer).to_hash.must_equal({"track"=>"Nine-1-2"}) }
44
+ it { _(OpenStruct.new.extend(representer).from_hash("track" => "Nine").track).must_equal "Nine-1-2" }
45
+ it { _(OpenStruct.new("track" => "Nine").extend(representer).to_hash).must_equal({"track"=>"Nine-1-2"}) }
46
46
  end
47
47
  end
48
48
 
@@ -36,7 +36,7 @@ class ForCollectionTest < MiniTest::Spec
36
36
  it { render(songs.extend(representer.for_collection)).must_equal_document output }
37
37
  it { render(representer.for_collection.prepare(songs)).must_equal_document output }
38
38
  # parsing needs the class set, at least
39
- it { parse([].extend(representer.for_collection), input).must_equal songs }
39
+ it { _(parse([].extend(representer.for_collection), input)).must_equal songs }
40
40
  end
41
41
 
42
42
  describe "Module::for_collection without configuration [#{format}]" do
@@ -66,7 +66,7 @@ class ForCollectionTest < MiniTest::Spec
66
66
  }
67
67
 
68
68
  it { render(representer.for_collection.new(songs)).must_equal_document output }
69
- it { parse(representer.for_collection.new([]), input).must_equal songs }
69
+ it { _(parse(representer.for_collection.new([]), input)).must_equal songs }
70
70
  end
71
71
  end
72
72