roxml 3.2.2 → 4.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 +7 -0
- data/.travis.yml +13 -0
- data/Gemfile +9 -6
- data/Gemfile.lock +98 -40
- data/History.txt +15 -0
- data/README.rdoc +3 -2
- data/Rakefile +9 -21
- data/VERSION +1 -1
- data/examples/search_query.rb +17 -0
- data/lib/roxml.rb +9 -3
- data/lib/roxml/definition.rb +4 -9
- data/lib/roxml/xml/parsers/libxml.rb +11 -27
- data/lib/roxml/xml/parsers/nokogiri.rb +13 -26
- data/lib/roxml/xml/references.rb +33 -21
- data/roxml.gemspec +40 -40
- data/spec/definition_spec.rb +85 -104
- data/spec/examples/active_record_spec.rb +13 -13
- data/spec/examples/amazon_spec.rb +13 -13
- data/spec/examples/current_weather_spec.rb +6 -6
- data/spec/examples/dashed_elements_spec.rb +3 -3
- data/spec/examples/library_spec.rb +3 -3
- data/spec/examples/library_with_fines_spec.rb +7 -7
- data/spec/examples/person_spec.rb +27 -27
- data/spec/examples/post_spec.rb +4 -4
- data/spec/examples/search_query_spec.rb +26 -0
- data/spec/examples/twitter_spec.rb +4 -4
- data/spec/reference_spec.rb +2 -2
- data/spec/regression_spec.rb +13 -8
- data/spec/roxml_spec.rb +56 -61
- data/spec/shared_specs.rb +2 -2
- data/spec/spec_helper.rb +2 -0
- data/spec/xml/array_spec.rb +2 -2
- data/spec/xml/attributes_spec.rb +7 -7
- data/spec/xml/encoding_spec.rb +9 -9
- data/spec/xml/namespace_spec.rb +40 -21
- data/spec/xml/namespaces_spec.rb +3 -3
- data/spec/xml/object_spec.rb +7 -7
- data/spec/xml/parser_spec.rb +2 -8
- data/spec/xml/text_spec.rb +6 -6
- data/test/fixtures/book_with_octal_pages.xml +2 -3
- data/test/test_helper.rb +1 -2
- data/test/unit/definition_test.rb +26 -27
- data/test/unit/deprecations_test.rb +23 -2
- data/test/unit/to_xml_test.rb +9 -9
- data/test/unit/xml_attribute_test.rb +3 -2
- data/test/unit/xml_block_test.rb +3 -2
- data/test/unit/xml_bool_test.rb +7 -8
- data/test/unit/xml_convention_test.rb +4 -3
- data/test/unit/xml_hash_test.rb +5 -13
- data/test/unit/xml_initialize_test.rb +4 -3
- data/test/unit/xml_name_test.rb +3 -2
- data/test/unit/xml_namespace_test.rb +4 -3
- data/test/unit/xml_object_test.rb +8 -7
- data/test/unit/xml_required_test.rb +7 -6
- data/test/unit/xml_text_test.rb +3 -2
- data/website/index.html +11 -11
- metadata +114 -61
- data/test/load_test.rb +0 -6
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative './../test_helper'
|
2
|
+
require 'minitest/autorun'
|
2
3
|
|
3
|
-
class TestDefinition <
|
4
|
+
class TestDefinition < Minitest::Test
|
4
5
|
def assert_hash(opts, kvp)
|
5
6
|
assert opts.hash?
|
6
7
|
assert !opts.array?
|
@@ -34,17 +35,15 @@ class TestDefinition < ActiveSupport::TestCase
|
|
34
35
|
end
|
35
36
|
|
36
37
|
def test_required_conflicts_with_else
|
37
|
-
|
38
|
+
assert_raises ArgumentError do
|
38
39
|
ROXML::Definition.new(:author, :required => true, :else => 'Johnny')
|
39
40
|
end
|
40
|
-
|
41
|
-
ROXML::Definition.new(:author, :required => false, :else => 'Johnny')
|
42
|
-
end
|
41
|
+
ROXML::Definition.new(:author, :required => false, :else => 'Johnny')
|
43
42
|
end
|
44
43
|
|
45
44
|
def test_hash_of_attrs
|
46
45
|
opts = ROXML::Definition.new(:attributes, :as => {:key => '@name', :value => '@value'})
|
47
|
-
assert_hash(opts, :attr => '
|
46
|
+
assert_hash(opts, :attr => 'value')
|
48
47
|
end
|
49
48
|
|
50
49
|
def test_hash_with_attr_key_and_text_val
|
@@ -56,7 +55,7 @@ class TestDefinition < ActiveSupport::TestCase
|
|
56
55
|
def test_hash_with_string_class_for_type
|
57
56
|
opts = ROXML::Definition.new(:attributes, :as => {:key => 'name',
|
58
57
|
:value => 'value'})
|
59
|
-
assert_hash(opts, :text => '
|
58
|
+
assert_hash(opts, :text => 'value')
|
60
59
|
end
|
61
60
|
|
62
61
|
def test_hash_with_attr_key_and_content_val
|
@@ -68,7 +67,7 @@ class TestDefinition < ActiveSupport::TestCase
|
|
68
67
|
def test_hash_with_options
|
69
68
|
opts = ROXML::Definition.new(:definitions, :as => {:key => '@dt', :value => '@dd'},
|
70
69
|
:in => :definitions, :from => 'definition')
|
71
|
-
assert_hash(opts, :attr => '
|
70
|
+
assert_hash(opts, :attr => 'dd')
|
72
71
|
assert_equal 'definition', opts.hash.wrapper
|
73
72
|
end
|
74
73
|
|
@@ -96,14 +95,6 @@ class TestDefinition < ActiveSupport::TestCase
|
|
96
95
|
assert_equal :attr, opts.sought_type
|
97
96
|
end
|
98
97
|
|
99
|
-
def test_multiple_shorthands_raises
|
100
|
-
assert_raise ArgumentError do
|
101
|
-
assert_deprecated do
|
102
|
-
ROXML::Definition.new(:count, :as => [Float, Integer])
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
98
|
def test_stacked_blocks
|
108
99
|
assert_equal 2, ROXML::Definition.new(:count, :as => Integer) {|val| val.to_i }.blocks.size
|
109
100
|
assert_equal 2, ROXML::Definition.new(:count, :as => Float) {|val| val.object_id }.blocks.size
|
@@ -115,35 +106,33 @@ class TestDefinition < ActiveSupport::TestCase
|
|
115
106
|
end
|
116
107
|
|
117
108
|
def test_block_shorthand_supports_integer
|
118
|
-
|
109
|
+
assert_nil ROXML::Definition.new(:floatvalue, :as => Integer).blocks.first.call(" ")
|
119
110
|
assert_equal 792, ROXML::Definition.new(:floatvalue, :as => Integer).blocks.first.call("792")
|
120
|
-
|
121
|
-
ROXML::Definition.new(:floatvalue, :as => Integer).blocks.first.call("792.13")
|
122
|
-
end
|
111
|
+
assert_equal 792, ROXML::Definition.new(:floatvalue, :as => Integer).blocks.first.call("792.13")
|
123
112
|
assert_equal [792, 12, 328], ROXML::Definition.new(:floatvalue, :as => Integer).blocks.first.call(["792", "12", "328"])
|
124
113
|
end
|
125
114
|
|
126
115
|
def test_block_shorthand_supports_float
|
127
|
-
|
116
|
+
assert_nil ROXML::Definition.new(:floatvalue, :as => Float).blocks.first.call(" ")
|
128
117
|
assert_equal 792.13, ROXML::Definition.new(:floatvalue, :as => Float).blocks.first.call("792.13")
|
129
118
|
assert_equal 240.0, ROXML::Definition.new(:floatvalue, :as => Float).blocks.first.call("240")
|
130
119
|
assert_equal [792.13, 240.0, 3.14], ROXML::Definition.new(:floatvalue, :as => Float).blocks.first.call(["792.13", "240", "3.14"])
|
131
120
|
end
|
132
121
|
|
133
122
|
def test_block_shorthand_supports_time
|
134
|
-
|
123
|
+
assert_nil ROXML::Definition.new(:floatvalue, :as => Time).blocks.first.call(" ")
|
135
124
|
assert_equal 31, ROXML::Definition.new(:datevalue, :as => Time).blocks.first.call("12:31am").min
|
136
125
|
assert_equal [31, 0, 59], ROXML::Definition.new(:datevalue, :as => Time).blocks.first.call(["12:31am", "3:00pm", "11:59pm"]).map(&:min)
|
137
126
|
end
|
138
127
|
|
139
128
|
def test_block_shorthand_supports_date
|
140
|
-
|
129
|
+
assert_nil ROXML::Definition.new(:floatvalue, :as => Date).blocks.first.call(" ")
|
141
130
|
assert_equal "1970-09-03", ROXML::Definition.new(:datevalue, :as => Date).blocks.first.call("September 3rd, 1970").to_s
|
142
131
|
assert_equal ["1970-09-03", "1776-07-04"], ROXML::Definition.new(:datevalue, :as => Date).blocks.first.call(["September 3rd, 1970", "1776-07-04"]).map(&:to_s)
|
143
132
|
end
|
144
133
|
|
145
134
|
def test_block_shorthand_supports_datetime
|
146
|
-
|
135
|
+
assert_nil ROXML::Definition.new(:floatvalue, :as => DateTime).blocks.first.call(" ")
|
147
136
|
assert_equal "1970-09-03T12:05:00+00:00", ROXML::Definition.new(:datevalue, :as => DateTime).blocks.first.call("12:05pm, September 3rd, 1970").to_s
|
148
137
|
assert_equal ["1970-09-03T12:05:00+00:00", "1700-05-22T15:00:00+00:00"], ROXML::Definition.new(:datevalue, :as => DateTime).blocks.first.call(["12:05pm, September 3rd, 1970", "3:00pm, May 22, 1700"]).map(&:to_s)
|
149
138
|
end
|
@@ -171,11 +160,21 @@ class TestDefinition < ActiveSupport::TestCase
|
|
171
160
|
assert_equal RoxmlObject, ROXML::Definition.new(:types, :as => [RoxmlObject]).sought_type
|
172
161
|
end
|
173
162
|
|
174
|
-
def
|
163
|
+
def test_default_for_missing_element_works
|
175
164
|
opts = ROXML::Definition.new(:missing, :else => true)
|
176
165
|
assert_equal true, opts.to_ref(RoxmlObject.new).value_in(ROXML::XML.parse_string('<xml></xml>'))
|
177
166
|
end
|
178
167
|
|
168
|
+
def test_default_for_empty_element_works
|
169
|
+
opts = ROXML::Definition.new(:age, :else => 25)
|
170
|
+
assert_equal 25, opts.to_ref(RoxmlObject.new).value_in(ROXML::XML.parse_string('<xml><age /></xml>'))
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_empty_element_works_without_default
|
174
|
+
opts = ROXML::Definition.new(:age)
|
175
|
+
assert_equal '', opts.to_ref(RoxmlObject.new).value_in(ROXML::XML.parse_string('<xml><age /></xml>'))
|
176
|
+
end
|
177
|
+
|
179
178
|
def test_default_works_for_arrays
|
180
179
|
opts = ROXML::Definition.new(:missing, :as => [])
|
181
180
|
assert_equal [], opts.to_ref(RoxmlObject.new).value_in(ROXML::XML.parse_string('<xml></xml>'))
|
@@ -226,10 +225,10 @@ class RoxmlObject
|
|
226
225
|
include ROXML
|
227
226
|
end
|
228
227
|
|
229
|
-
class HashDefinitionTest <
|
228
|
+
class HashDefinitionTest < Minitest::Test
|
230
229
|
def test_content_detected_as_from
|
231
230
|
opts = ROXML::Definition.new(:hash, :as => {:key => :content, :value => :name})
|
232
231
|
assert_equal '.', opts.hash.key.name
|
233
232
|
assert_equal :text, opts.hash.key.sought_type
|
234
233
|
end
|
235
|
-
end
|
234
|
+
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require_relative './../test_helper'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'active_support/testing/deprecation'
|
4
|
+
|
5
|
+
class TestDeprecation < Minitest::Test
|
6
|
+
include ActiveSupport::Testing::Deprecation
|
2
7
|
|
3
|
-
class TestDeprecation < ActiveSupport::TestCase
|
4
8
|
def test_as_array_not_deprecated
|
5
9
|
assert_not_deprecated do
|
6
10
|
opts = ROXML::Definition.new(:name, :as => [])
|
@@ -21,4 +25,21 @@ class TestDeprecation < ActiveSupport::TestCase
|
|
21
25
|
ROXML::Definition.new(:name, :as => OctalInteger)
|
22
26
|
end
|
23
27
|
end
|
24
|
-
|
28
|
+
|
29
|
+
def test_as_hash_of_as_type_not_deprecated
|
30
|
+
assert_not_deprecated do
|
31
|
+
opts = ROXML::Definition.new(:name, :as => {:key => :name, :value => {:from => 'value', :as => OctalInteger}})
|
32
|
+
assert opts.hash?
|
33
|
+
assert_equal OctalInteger, opts.hash.value.sought_type
|
34
|
+
assert_equal 'value', opts.hash.value.name
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_multiple_shorthands_raises
|
39
|
+
assert_raises ArgumentError do
|
40
|
+
assert_deprecated do
|
41
|
+
ROXML::Definition.new(:count, :as => [Float, Integer])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/test/unit/to_xml_test.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative './../test_helper'
|
2
|
+
require 'minitest/autorun'
|
2
3
|
|
3
|
-
class TestHashToXml <
|
4
|
+
class TestHashToXml < Minitest::Test
|
4
5
|
to_xml_test :dictionary_of_attrs,
|
5
6
|
:dictionary_of_mixeds,
|
6
7
|
:dictionary_of_texts,
|
@@ -10,7 +11,7 @@ class TestHashToXml < ActiveSupport::TestCase
|
|
10
11
|
:dictionary_of_attr_name_clashes
|
11
12
|
end
|
12
13
|
|
13
|
-
class TestOtherToXml <
|
14
|
+
class TestOtherToXml < Minitest::Test
|
14
15
|
to_xml_test :book => :book_valid,
|
15
16
|
:book_with_author_text_attribute => :book_text_with_attribute,
|
16
17
|
:uppercase_library => :library_uppercase
|
@@ -28,7 +29,7 @@ class TestOtherToXml < ActiveSupport::TestCase
|
|
28
29
|
to_xml_test :book_with_wrapped_attr
|
29
30
|
end
|
30
31
|
|
31
|
-
class TestToXmlWithDefaults <
|
32
|
+
class TestToXmlWithDefaults < Minitest::Test
|
32
33
|
def test_content_and_attr_defaults_are_represented_in_output
|
33
34
|
dict = Person.from_xml(fixture(:nameless_ageless_youth))
|
34
35
|
|
@@ -37,17 +38,17 @@ class TestToXmlWithDefaults < ActiveSupport::TestCase
|
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
class TestToXmlWithBlocks <
|
41
|
+
class TestToXmlWithBlocks < Minitest::Test
|
41
42
|
def test_pagecount_serialized_properly_after_modification
|
42
43
|
b = Book.from_xml(fixture(:book_valid))
|
43
44
|
xml = xml_fixture(:book_valid)
|
44
|
-
assert_equal '357',
|
45
|
+
assert_equal '357', ROXML::XML.search(xml, 'pagecount').first.content
|
45
46
|
assert_equal 357, b.pages
|
46
47
|
|
47
48
|
b.pages = 500
|
48
49
|
doc = ROXML::XML::Document.new()
|
49
50
|
doc.root = b.to_xml
|
50
|
-
assert_equal '500',
|
51
|
+
assert_equal '500', ROXML::XML.search(doc, 'pagecount').first.content
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
@@ -72,10 +73,9 @@ end
|
|
72
73
|
class BookWithOctalPages
|
73
74
|
include ROXML
|
74
75
|
|
75
|
-
xml_accessor :
|
76
|
-
xml_accessor :pages_with_type, :as => OctalInteger, :required => true
|
76
|
+
xml_accessor :pages, :as => OctalInteger, :required => true
|
77
77
|
end
|
78
78
|
|
79
|
-
class TestToXmlWithOverriddenOutput <
|
79
|
+
class TestToXmlWithOverriddenOutput < Minitest::Test
|
80
80
|
to_xml_test :book_with_octal_pages
|
81
81
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative './../test_helper'
|
2
|
+
require 'minitest/autorun'
|
2
3
|
|
3
|
-
class TestXMLAttribute <
|
4
|
+
class TestXMLAttribute < Minitest::Test
|
4
5
|
def test_attr_from
|
5
6
|
# :attr => *
|
6
7
|
book = Book.from_xml(fixture(:book_text_with_attribute))
|
@@ -36,4 +37,4 @@ class TestXMLAttribute < ActiveSupport::TestCase
|
|
36
37
|
b = BookWithWrappedAttr.from_xml(fixture(:book_with_wrapped_attr))
|
37
38
|
assert_equal "0974514055", b.isbn
|
38
39
|
end
|
39
|
-
end
|
40
|
+
end
|
data/test/unit/xml_block_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative './../test_helper'
|
2
|
+
require 'minitest/autorun'
|
2
3
|
|
3
4
|
class ArrayWithBlockShorthand
|
4
5
|
include ROXML
|
@@ -14,7 +15,7 @@ class ArrayWithBlock
|
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
17
|
-
class TestXMLBlocks <
|
18
|
+
class TestXMLBlocks < Minitest::Test
|
18
19
|
def test_block_is_applied
|
19
20
|
muffins = Muffins.from_xml(fixture(:muffins))
|
20
21
|
|
@@ -78,4 +79,4 @@ class TestXMLBlocks < ActiveSupport::TestCase
|
|
78
79
|
|
79
80
|
assert_equal [], obj.array
|
80
81
|
end
|
81
|
-
end
|
82
|
+
end
|
data/test/unit/xml_bool_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative './../test_helper'
|
2
|
+
require 'minitest/autorun'
|
2
3
|
|
3
4
|
PROC_TRUE = proc {|val| val ? 'TRUE' : 'FALSE'}
|
4
5
|
PROC_True = proc {|val| val ? 'True' : 'False'}
|
@@ -68,7 +69,7 @@ UNEXPECTED_VALUE_XML = %{
|
|
68
69
|
}
|
69
70
|
|
70
71
|
|
71
|
-
class TestXMLBool <
|
72
|
+
class TestXMLBool < Minitest::Test
|
72
73
|
def test_bool_results_for_various_inputs
|
73
74
|
x = XmlBool.from_xml(BOOL_XML)
|
74
75
|
assert_equal true, x.true_from_TRUE?
|
@@ -83,12 +84,12 @@ class TestXMLBool < ActiveSupport::TestCase
|
|
83
84
|
|
84
85
|
def test_missing_results_in_nil
|
85
86
|
x = XmlBool.from_xml(BOOL_XML)
|
86
|
-
|
87
|
+
assert_nil x.missing?
|
87
88
|
end
|
88
89
|
|
89
90
|
def test_unexpected_value_results_in_nil
|
90
91
|
x = XmlBoolUnexpected.from_xml(UNEXPECTED_VALUE_XML)
|
91
|
-
|
92
|
+
assert_nil x.unexpected?
|
92
93
|
end
|
93
94
|
|
94
95
|
def test_block_recieves_unexpected_value_rather_than_nil
|
@@ -97,11 +98,9 @@ class TestXMLBool < ActiveSupport::TestCase
|
|
97
98
|
end
|
98
99
|
|
99
100
|
def test_required_raises_on_missing
|
100
|
-
|
101
|
-
XmlBoolRequired.from_xml(PRESENT)
|
102
|
-
end
|
101
|
+
XmlBoolRequired.from_xml(PRESENT)
|
103
102
|
|
104
|
-
|
103
|
+
assert_raises ROXML::RequiredElementMissing do
|
105
104
|
XmlBoolRequired.from_xml(ABSENT)
|
106
105
|
end
|
107
106
|
end
|
@@ -119,4 +118,4 @@ class TestXMLBool < ActiveSupport::TestCase
|
|
119
118
|
end
|
120
119
|
|
121
120
|
to_xml_test XmlBool => BOOL_XML
|
122
|
-
end
|
121
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative './../test_helper'
|
2
|
+
require 'minitest/autorun'
|
2
3
|
|
3
4
|
XML_CAMELLOWER = %{
|
4
5
|
<bookCase name="Jonas' Books">
|
@@ -94,7 +95,7 @@ end
|
|
94
95
|
class InheritedBookCaseDefault < ParentBookCaseDefault
|
95
96
|
end
|
96
97
|
|
97
|
-
class TestXMLConvention <
|
98
|
+
class TestXMLConvention < Minitest::Test
|
98
99
|
# TODO: Test convention applies to xml_name as well...
|
99
100
|
|
100
101
|
def test_default_convention_is_underscore
|
@@ -132,7 +133,7 @@ class TestXMLConvention < ActiveSupport::TestCase
|
|
132
133
|
|
133
134
|
bc = InheritedBookCaseDefault.from_xml(XML_DASHES)
|
134
135
|
assert_has_book_case_info(bc)
|
135
|
-
|
136
|
+
assert_raises ROXML::RequiredElementMissing do
|
136
137
|
InheritedBookCaseDefault.from_xml(XML_UNDERSCORE)
|
137
138
|
end
|
138
139
|
end
|
@@ -147,4 +148,4 @@ class TestXMLConvention < ActiveSupport::TestCase
|
|
147
148
|
assert_equal 12, bc.book_count
|
148
149
|
assert_equal ['GED', 'House of Leaves'], bc.big_books
|
149
150
|
end
|
150
|
-
end
|
151
|
+
end
|
data/test/unit/xml_hash_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative './../test_helper'
|
2
|
+
require 'minitest/autorun'
|
2
3
|
|
3
4
|
class BookWithContributorHash
|
4
5
|
include ROXML
|
@@ -7,7 +8,7 @@ class BookWithContributorHash
|
|
7
8
|
:value => 'name'}
|
8
9
|
end
|
9
10
|
|
10
|
-
class TestXMLHash <
|
11
|
+
class TestXMLHash < Minitest::Test
|
11
12
|
def setup
|
12
13
|
@contents = {'quaquaversally' => 'adjective: (of a geological formation) sloping downward from the center in all directions.',
|
13
14
|
'tergiversate' => 'To use evasions or ambiguities; equivocate.'}
|
@@ -26,7 +27,7 @@ class TestXMLHash < ActiveSupport::TestCase
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def test_hash_with_object_key_fails
|
29
|
-
|
30
|
+
assert_raises ArgumentError do
|
30
31
|
Class.new do
|
31
32
|
include ROXML
|
32
33
|
|
@@ -37,7 +38,7 @@ class TestXMLHash < ActiveSupport::TestCase
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def test_hash_with_object_value_fails
|
40
|
-
|
41
|
+
assert_raises ArgumentError do
|
41
42
|
Class.new do
|
42
43
|
include ROXML
|
43
44
|
|
@@ -103,13 +104,4 @@ class TestXMLHash < ActiveSupport::TestCase
|
|
103
104
|
</dict>
|
104
105
|
}).missing_hash)
|
105
106
|
end
|
106
|
-
|
107
|
-
def test_as_hash_of_as_type_not_deprecated
|
108
|
-
assert_not_deprecated do
|
109
|
-
opts = ROXML::Definition.new(:name, :as => {:key => :name, :value => {:from => 'value', :as => OctalInteger}})
|
110
|
-
assert opts.hash?
|
111
|
-
assert_equal OctalInteger, opts.hash.value.sought_type
|
112
|
-
assert_equal 'value', opts.hash.value.name
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
107
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative './../test_helper'
|
2
|
+
require 'minitest/autorun'
|
2
3
|
|
3
4
|
class InheritedBookWithDepth < Book
|
4
5
|
xml_reader :depth, :as => Measurement
|
@@ -13,7 +14,7 @@ class BookWithXmlInitialize < BookWithDepth
|
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
|
-
class TestXMLInitialize <
|
17
|
+
class TestXMLInitialize < Minitest::Test
|
17
18
|
def test_initialize_is_run
|
18
19
|
m = Measurement.from_xml('<measurement units="hundredths-meters">1130</measurement>')
|
19
20
|
assert_equal 11.3, m.value
|
@@ -31,7 +32,7 @@ class TestXMLInitialize < ActiveSupport::TestCase
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def test_initialize_fails_on_missing_required_arg
|
34
|
-
|
35
|
+
assert_raises ArgumentError do
|
35
36
|
BookWithXmlInitialize.from_xml(fixture(:book_with_depth))
|
36
37
|
end
|
37
38
|
end
|
@@ -46,4 +47,4 @@ class TestXMLInitialize < ActiveSupport::TestCase
|
|
46
47
|
assert now < b.created_at
|
47
48
|
assert_equal "Joe Librarian", b.creator
|
48
49
|
end
|
49
|
-
end
|
50
|
+
end
|
data/test/unit/xml_name_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative './../test_helper'
|
2
|
+
require 'minitest/autorun'
|
2
3
|
|
3
4
|
# Parent | Child
|
4
5
|
# :from | no :from |
|
@@ -48,7 +49,7 @@ class ParentOfUnnamedChildWithFrom
|
|
48
49
|
xml_accessor :child_accessor_name,:as => Child, :from => 'child_from_name'
|
49
50
|
end
|
50
51
|
|
51
|
-
class TestXMLName <
|
52
|
+
class TestXMLName < Minitest::Test
|
52
53
|
def test_from_always_dominates_attribute_name_xml_name_or_not
|
53
54
|
parent = ParentOfNamedChildWithFrom.new
|
54
55
|
parent.child_accessor_name = Child.new
|
@@ -138,4 +139,4 @@ module WrapModule
|
|
138
139
|
class InstanceStandin < BaseClass
|
139
140
|
xml_reader :name, :in => './'
|
140
141
|
end
|
141
|
-
end
|
142
|
+
end
|