representable 3.0.4 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +17 -0
- data/CHANGES.md +10 -0
- data/Gemfile +4 -7
- data/LICENSE +1 -1
- data/README.md +4 -3
- data/Rakefile +1 -6
- data/lib/representable.rb +18 -25
- data/lib/representable/binding.rb +32 -12
- data/lib/representable/cached.rb +1 -1
- data/lib/representable/coercion.rb +8 -6
- data/lib/representable/config.rb +8 -3
- data/lib/representable/debug.rb +23 -15
- data/lib/representable/declarative.rb +8 -3
- data/lib/representable/decorator.rb +1 -1
- data/lib/representable/definition.rb +7 -2
- data/lib/representable/deserializer.rb +4 -3
- data/lib/representable/for_collection.rb +1 -1
- data/lib/representable/hash.rb +6 -2
- data/lib/representable/hash/allow_symbols.rb +9 -11
- data/lib/representable/hash/binding.rb +1 -0
- data/lib/representable/hash/collection.rb +4 -2
- data/lib/representable/hash_methods.rb +3 -2
- data/lib/representable/insert.rb +1 -1
- data/lib/representable/json.rb +5 -7
- data/lib/representable/json/collection.rb +3 -0
- data/lib/representable/json/hash.rb +1 -0
- data/lib/representable/object.rb +1 -1
- data/lib/representable/object/binding.rb +5 -1
- data/lib/representable/option.rb +19 -0
- data/lib/representable/pipeline.rb +3 -2
- data/lib/representable/pipeline_factories.rb +4 -2
- data/lib/representable/populator.rb +1 -1
- data/lib/representable/represent.rb +1 -0
- data/lib/representable/serializer.rb +2 -1
- data/lib/representable/version.rb +1 -1
- data/lib/representable/virtus_coercion.rb +38 -0
- data/lib/representable/xml.rb +7 -10
- data/lib/representable/xml/binding.rb +2 -3
- data/lib/representable/yaml.rb +3 -3
- data/lib/representable/yaml/binding.rb +1 -0
- data/representable.gemspec +3 -3
- data/test/as_test.rb +4 -4
- data/test/binding_test.rb +10 -10
- data/test/cached_test.rb +19 -19
- data/test/class_test.rb +7 -7
- data/test/coercion_test.rb +33 -22
- data/test/config/inherit_test.rb +14 -14
- data/test/config_test.rb +18 -18
- data/test/decorator_scope_test.rb +3 -3
- data/test/decorator_test.rb +17 -17
- data/test/default_test.rb +7 -7
- data/test/definition_test.rb +32 -32
- data/test/{example.rb → examples/example.rb} +0 -0
- data/test/exec_context_test.rb +6 -6
- data/test/features_test.rb +3 -3
- data/test/filter_test.rb +6 -6
- data/test/for_collection_test.rb +2 -2
- data/test/generic_test.rb +3 -3
- data/test/getter_setter_test.rb +5 -5
- data/test/hash_test.rb +19 -19
- data/test/heritage_test.rb +4 -4
- data/test/if_test.rb +6 -6
- data/test/include_exclude_test.rb +12 -12
- data/test/inherit_test.rb +15 -15
- data/test/inline_test.rb +11 -11
- data/test/instance_test.rb +29 -29
- data/test/is_representable_test.rb +10 -10
- data/test/json_test.rb +7 -7
- data/test/lonely_test.rb +16 -16
- data/test/nested_test.rb +7 -7
- data/test/object_test.rb +7 -7
- data/test/option_test.rb +36 -0
- data/test/parse_pipeline_test.rb +3 -3
- data/test/pipeline_test.rb +43 -43
- data/test/populator_test.rb +15 -15
- data/test/prepare_test.rb +2 -2
- data/test/private_options_test.rb +2 -2
- data/test/reader_writer_test.rb +2 -2
- data/test/render_nil_test.rb +2 -2
- data/test/represent_test.rb +4 -4
- data/test/representable_test.rb +27 -27
- data/test/schema_test.rb +5 -5
- data/test/serialize_deserialize_test.rb +2 -2
- data/test/skip_test.rb +10 -10
- data/test/stringify_hash_test.rb +3 -3
- data/test/test_helper.rb +4 -2
- data/test/uncategorized_test.rb +10 -10
- data/test/user_options_test.rb +4 -4
- data/test/virtus_coercion_test.rb +52 -0
- data/test/wrap_test.rb +11 -11
- data/test/xml_namespace_test.rb +1 -1
- data/test/xml_test.rb +6 -6
- data/test/yaml_test.rb +20 -20
- metadata +81 -15
- data/.travis.yml +0 -16
- data/lib/representable/autoload.rb +0 -14
- data/test/mongoid_test.rb +0 -31
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
|
data/test/decorator_test.rb
CHANGED
@@ -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
|
data/test/definition_test.rb
CHANGED
@@ -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
|
-
|
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
|
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 =>
|
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
|
-
|
178
|
+
refute Representable::Definition.new(:song).has_default?
|
179
179
|
end
|
180
180
|
|
181
181
|
it "returns true if :default set" do
|
182
|
-
|
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
|
-
|
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
|
-
|
234
|
+
refute Representable::Definition.new(:songs).hash?
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
File without changes
|
data/test/exec_context_test.rb
CHANGED
@@ -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
|