roxml 2.5.3 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.gitmodules +3 -0
- data/History.txt +38 -1
- data/README.rdoc +8 -5
- data/Rakefile +35 -36
- data/TODO +12 -35
- data/VERSION +1 -0
- data/examples/amazon.rb +8 -6
- data/examples/posts.rb +1 -1
- data/examples/{active_record.rb → rails.rb} +2 -2
- data/examples/twitter.rb +1 -1
- data/lib/roxml.rb +86 -151
- data/lib/roxml/definition.rb +64 -152
- data/lib/roxml/hash_definition.rb +5 -40
- data/lib/roxml/xml.rb +12 -9
- data/lib/roxml/xml/parsers/libxml.rb +22 -17
- data/lib/roxml/xml/parsers/nokogiri.rb +77 -0
- data/lib/roxml/xml/references.rb +66 -57
- data/roxml.gemspec +170 -19
- data/spec/definition_spec.rb +121 -198
- data/spec/examples/active_record_spec.rb +2 -2
- data/spec/examples/amazon_spec.rb +3 -2
- data/spec/examples/current_weather_spec.rb +2 -2
- data/spec/examples/dashed_elements_spec.rb +2 -2
- data/spec/examples/library_spec.rb +11 -6
- data/spec/examples/post_spec.rb +3 -3
- data/spec/examples/twitter_spec.rb +2 -2
- data/spec/roxml_spec.rb +15 -15
- data/spec/shared_specs.rb +1 -1
- data/spec/spec_helper.rb +8 -27
- data/spec/support/libxml.rb +3 -0
- data/spec/support/nokogiri.rb +3 -0
- data/spec/xml/attributes_spec.rb +36 -0
- data/spec/xml/namespace_spec.rb +240 -0
- data/spec/xml/namespaces_spec.rb +32 -0
- data/spec/xml/parser_spec.rb +9 -30
- data/tasks/rdoc.rake +13 -0
- data/tasks/rspec.rake +21 -17
- data/tasks/test.rake +13 -20
- data/test/mocks/dictionaries.rb +8 -7
- data/test/mocks/mocks.rb +20 -20
- data/test/support/fixtures.rb +11 -0
- data/test/test_helper.rb +3 -14
- data/test/unit/definition_test.rb +21 -95
- data/test/unit/deprecations_test.rb +1 -74
- data/test/unit/to_xml_test.rb +3 -3
- data/test/unit/xml_attribute_test.rb +1 -1
- data/test/unit/xml_block_test.rb +3 -3
- data/test/unit/xml_bool_test.rb +4 -4
- data/test/unit/xml_convention_test.rb +3 -3
- data/test/unit/xml_hash_test.rb +5 -14
- data/test/unit/xml_initialize_test.rb +2 -6
- data/test/unit/xml_name_test.rb +5 -24
- data/test/unit/xml_namespace_test.rb +1 -46
- data/test/unit/xml_object_test.rb +6 -6
- data/test/unit/xml_required_test.rb +3 -2
- data/test/unit/xml_text_test.rb +2 -2
- data/website/index.html +1 -1
- metadata +68 -51
- data/Manifest.txt +0 -106
- data/lib/roxml/extensions.rb +0 -6
- data/lib/roxml/extensions/array.rb +0 -13
- data/lib/roxml/extensions/array/conversions.rb +0 -35
- data/lib/roxml/extensions/deprecation.rb +0 -33
- data/lib/roxml/extensions/string.rb +0 -21
- data/lib/roxml/extensions/string/conversions.rb +0 -43
- data/lib/roxml/extensions/string/iterators.rb +0 -12
- data/lib/roxml/xml/parsers/rexml.rb +0 -84
- data/spec/string_spec.rb +0 -15
- data/test/bugs/rexml_bugs.rb +0 -15
- data/test/release/dependencies_test.rb +0 -32
- data/test/unit/xml_construct_test.rb +0 -77
- data/vendor/override_rake_task/README +0 -30
- data/vendor/override_rake_task/init.rb +0 -1
- data/vendor/override_rake_task/install.rb +0 -46
- data/vendor/override_rake_task/lib/override_rake_task.rb +0 -16
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'test/test_helper'
|
2
2
|
|
3
3
|
class TestDefinition < ActiveSupport::TestCase
|
4
4
|
def assert_hash(opts, kvp)
|
@@ -8,36 +8,18 @@ class TestDefinition < ActiveSupport::TestCase
|
|
8
8
|
opts.hash.value.type => opts.hash.value.name}
|
9
9
|
end
|
10
10
|
|
11
|
-
def test_text_in_array_means_as_array_for_text
|
12
|
-
opts = ROXML::Definition.new(:authors, [:text])
|
13
|
-
assert opts.array?
|
14
|
-
assert_equal :text, opts.type
|
15
|
-
end
|
16
|
-
|
17
11
|
def test_empty_array_means_as_array_for_text
|
18
|
-
opts = ROXML::Definition.new(:authors, [])
|
12
|
+
opts = ROXML::Definition.new(:authors, :as => [])
|
19
13
|
assert opts.array?
|
20
14
|
assert_equal :text, opts.type
|
21
15
|
end
|
22
16
|
|
23
17
|
def test_attr_in_array_means_as_array_for_attr
|
24
|
-
opts = ROXML::Definition.new(:authors, [:attr
|
18
|
+
opts = ROXML::Definition.new(:authors, :as => [], :from => :attr)
|
25
19
|
assert opts.array?
|
26
20
|
assert_equal :attr, opts.type
|
27
21
|
end
|
28
22
|
|
29
|
-
def test_object_in_array_means_as_array_for_object
|
30
|
-
opts = ROXML::Definition.new(:authors, [Hash])
|
31
|
-
assert opts.array?
|
32
|
-
assert_equal Hash, opts.type
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_literal_as_array_is_deprecated
|
36
|
-
assert_deprecated do
|
37
|
-
assert ROXML::Definition.new(:authors, :as => :array).array?
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
23
|
def test_block_shorthand_in_array_means_array
|
42
24
|
opts = ROXML::Definition.new(:intarray, :as => [Integer])
|
43
25
|
assert opts.array?
|
@@ -61,30 +43,30 @@ class TestDefinition < ActiveSupport::TestCase
|
|
61
43
|
end
|
62
44
|
|
63
45
|
def test_hash_of_attrs
|
64
|
-
opts = ROXML::Definition.new(:attributes, {:
|
46
|
+
opts = ROXML::Definition.new(:attributes, :as => {:key => '@name', :value => '@value'})
|
65
47
|
assert_hash(opts, :attr => 'name', :attr => 'value')
|
66
48
|
end
|
67
49
|
|
68
50
|
def test_hash_with_attr_key_and_text_val
|
69
|
-
opts = ROXML::Definition.new(:attributes,
|
51
|
+
opts = ROXML::Definition.new(:attributes, :as => {:key => '@name',
|
70
52
|
:value => :value})
|
71
53
|
assert_hash(opts, :attr => 'name', :text => 'value')
|
72
54
|
end
|
73
55
|
|
74
56
|
def test_hash_with_string_class_for_type
|
75
|
-
opts = ROXML::Definition.new(:attributes,
|
76
|
-
:value =>
|
57
|
+
opts = ROXML::Definition.new(:attributes, :as => {:key => 'name',
|
58
|
+
:value => 'value'})
|
77
59
|
assert_hash(opts, :text => 'name', :text => 'value')
|
78
60
|
end
|
79
61
|
|
80
62
|
def test_hash_with_attr_key_and_content_val
|
81
|
-
opts = ROXML::Definition.new(:attributes,
|
63
|
+
opts = ROXML::Definition.new(:attributes, :as => {:key => '@name',
|
82
64
|
:value => :content})
|
83
65
|
assert_hash(opts, :attr => 'name', :text => '.')
|
84
66
|
end
|
85
67
|
|
86
68
|
def test_hash_with_options
|
87
|
-
opts = ROXML::Definition.new(:definitions, {:
|
69
|
+
opts = ROXML::Definition.new(:definitions, :as => {:key => '@dt', :value => '@dd'},
|
88
70
|
:in => :definitions, :from => 'definition')
|
89
71
|
assert_hash(opts, :attr => 'dt', :attr => 'dd')
|
90
72
|
assert_equal 'definition', opts.hash.wrapper
|
@@ -92,12 +74,6 @@ class TestDefinition < ActiveSupport::TestCase
|
|
92
74
|
|
93
75
|
def test_no_block_shorthand_means_no_block
|
94
76
|
assert ROXML::Definition.new(:count).blocks.empty?
|
95
|
-
assert_deprecated do
|
96
|
-
assert ROXML::Definition.new(:count, :as => :intager).blocks.empty?
|
97
|
-
end
|
98
|
-
assert_deprecated do
|
99
|
-
assert ROXML::Definition.new(:count, :as => :foat).blocks.empty?
|
100
|
-
end
|
101
77
|
end
|
102
78
|
|
103
79
|
def test_block_integer_shorthand
|
@@ -133,15 +109,6 @@ class TestDefinition < ActiveSupport::TestCase
|
|
133
109
|
assert_equal 2, ROXML::Definition.new(:count, :as => Float) {|val| val.object_id }.blocks.size
|
134
110
|
end
|
135
111
|
|
136
|
-
def test_symbol_shorthands_are_deprecated
|
137
|
-
assert_deprecated do
|
138
|
-
ROXML::Definition.new(:junk, :as => :integer)
|
139
|
-
end
|
140
|
-
assert_deprecated do
|
141
|
-
ROXML::Definition.new(:junk, :as => :float)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
112
|
def test_block_shorthand_supports_bool
|
146
113
|
assert_equal true, ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call("1")
|
147
114
|
assert_equal [true, false, nil], ROXML::Definition.new(:floatvalue, :as => :bool).blocks.first.call(["TrUe", "0", "328"])
|
@@ -196,27 +163,12 @@ class TestDefinition < ActiveSupport::TestCase
|
|
196
163
|
assert ROXML::Definition.new(:manufacturer, :cdata => true).cdata?
|
197
164
|
end
|
198
165
|
|
199
|
-
def test_as_cdata_is_deprecated
|
200
|
-
assert_deprecated do
|
201
|
-
assert ROXML::Definition.new(:manufacturer, :as => :cdata).cdata?
|
202
|
-
end
|
203
|
-
assert_deprecated do
|
204
|
-
assert ROXML::Definition.new(:manufacturer, :as => [Integer, :cdata]).cdata?
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
166
|
def test_as_supports_generic_roxml_types
|
209
167
|
assert_equal RoxmlObject, ROXML::Definition.new(:type, :as => RoxmlObject).type
|
210
|
-
assert_deprecated do
|
211
|
-
assert_equal RoxmlObject, ROXML::Definition.new(:type, RoxmlObject).type
|
212
|
-
end
|
213
168
|
end
|
214
169
|
|
215
170
|
def test_as_supports_generic_roxml_types_in_arrays
|
216
171
|
assert_equal RoxmlObject, ROXML::Definition.new(:types, :as => [RoxmlObject]).type
|
217
|
-
assert_deprecated do
|
218
|
-
assert_equal RoxmlObject, ROXML::Definition.new(:types, [RoxmlObject]).type
|
219
|
-
end
|
220
172
|
end
|
221
173
|
|
222
174
|
def test_default_works
|
@@ -227,14 +179,6 @@ class TestDefinition < ActiveSupport::TestCase
|
|
227
179
|
def test_default_works_for_arrays
|
228
180
|
opts = ROXML::Definition.new(:missing, :as => [])
|
229
181
|
assert_equal [], opts.to_ref(RoxmlObject.new).value_in(ROXML::XML::Parser.parse('<xml></xml>'))
|
230
|
-
assert_deprecated do
|
231
|
-
opts = ROXML::Definition.new(:missing, [])
|
232
|
-
assert_equal [], opts.to_ref(RoxmlObject.new).value_in(ROXML::XML::Parser.parse('<xml></xml>'))
|
233
|
-
end
|
234
|
-
assert_deprecated do
|
235
|
-
opts = ROXML::Definition.new(:missing, :as => :array)
|
236
|
-
assert_equal [], opts.to_ref(RoxmlObject.new).value_in(ROXML::XML::Parser.parse('<xml></xml>'))
|
237
|
-
end
|
238
182
|
end
|
239
183
|
|
240
184
|
def test_default_works_for_recursive_objects
|
@@ -248,20 +192,16 @@ class TestDefinition < ActiveSupport::TestCase
|
|
248
192
|
end
|
249
193
|
|
250
194
|
def test_content_is_a_recognized_type
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
assert_equal :text, opts.type
|
256
|
-
end
|
195
|
+
opts = ROXML::Definition.new(:author, :from => :content)
|
196
|
+
assert opts.content?
|
197
|
+
assert_equal '.', opts.name
|
198
|
+
assert_equal :text, opts.type
|
257
199
|
end
|
258
200
|
|
259
201
|
def test_content_symbol_as_target_is_translated_to_string
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
assert_equal :attr, opts.type
|
264
|
-
end
|
202
|
+
opts = ROXML::Definition.new(:content, :from => :attr)
|
203
|
+
assert_equal 'content', opts.name
|
204
|
+
assert_equal :attr, opts.type
|
265
205
|
end
|
266
206
|
|
267
207
|
def test_attr_is_accepted_as_from
|
@@ -270,30 +210,16 @@ class TestDefinition < ActiveSupport::TestCase
|
|
270
210
|
end
|
271
211
|
|
272
212
|
def test_attr_is_a_recognized_type
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
assert_equal :attr, opts.type
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
def test_name_ending_with_on_warns_of_coming_date_default
|
281
|
-
assert_deprecated do
|
282
|
-
assert_equal :text, ROXML::Definition.new(:created_at).type
|
283
|
-
end
|
284
|
-
end
|
285
|
-
|
286
|
-
def test_name_ending_with_at_warns_of_coming_datetime_default
|
287
|
-
assert_deprecated do
|
288
|
-
assert_equal :text, ROXML::Definition.new(:created_on).type
|
289
|
-
end
|
213
|
+
opts = ROXML::Definition.new(:author, :from => :attr)
|
214
|
+
assert_equal 'author', opts.name
|
215
|
+
assert_equal :attr, opts.type
|
290
216
|
end
|
291
217
|
end
|
292
218
|
|
293
219
|
class RecursiveObject
|
294
220
|
include ROXML
|
295
221
|
|
296
|
-
xml_reader :next, RecursiveObject, :else => true
|
222
|
+
xml_reader :next, :as => RecursiveObject, :else => true
|
297
223
|
end
|
298
224
|
|
299
225
|
class RoxmlObject
|
@@ -302,7 +228,7 @@ end
|
|
302
228
|
|
303
229
|
class HashDefinitionTest < ActiveSupport::TestCase
|
304
230
|
def test_content_detected_as_from
|
305
|
-
opts = ROXML::Definition.new(:hash, {:key => :content, :value => :name})
|
231
|
+
opts = ROXML::Definition.new(:hash, :as => {:key => :content, :value => :name})
|
306
232
|
assert_equal '.', opts.hash.key.name
|
307
233
|
assert_equal :text, opts.hash.key.type
|
308
234
|
end
|
@@ -1,72 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require 'test/test_helper'
|
2
2
|
|
3
3
|
class TestDeprecation < ActiveSupport::TestCase
|
4
|
-
def test_tag_refs_is_deprecated
|
5
|
-
assert_deprecated do
|
6
|
-
Class.new do
|
7
|
-
include ROXML
|
8
|
-
end.tag_refs
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_literal_as_array_is_deprecated
|
13
|
-
assert_deprecated do
|
14
|
-
assert ROXML::Definition.new(:authors, :as => :array).array?
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_no_block_shorthand_means_no_block
|
19
|
-
assert_deprecated do
|
20
|
-
assert ROXML::Definition.new(:count, :as => :intager).blocks.empty?
|
21
|
-
end
|
22
|
-
assert_deprecated do
|
23
|
-
assert ROXML::Definition.new(:count, :as => :foat).blocks.empty?
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_symbol_shorthands_are_deprecated
|
28
|
-
assert_deprecated do
|
29
|
-
ROXML::Definition.new(:junk, :as => :integer)
|
30
|
-
end
|
31
|
-
assert_deprecated do
|
32
|
-
ROXML::Definition.new(:junk, :as => :float)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_as_cdata_is_deprecated
|
37
|
-
assert_deprecated do
|
38
|
-
assert ROXML::Definition.new(:manufacturer, :as => :cdata).cdata?
|
39
|
-
end
|
40
|
-
assert_deprecated do
|
41
|
-
assert ROXML::Definition.new(:manufacturer, :as => [Integer, :cdata]).cdata?
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_content_is_a_recognized_type
|
46
|
-
assert_deprecated do
|
47
|
-
opts = ROXML::Definition.new(:author, :content)
|
48
|
-
assert opts.content?
|
49
|
-
assert_equal '.', opts.name
|
50
|
-
assert_equal :text, opts.type
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_content_symbol_as_target_is_translated_to_string
|
55
|
-
assert_deprecated do
|
56
|
-
opts = ROXML::Definition.new(:content, :attr => :content)
|
57
|
-
assert_equal 'content', opts.name
|
58
|
-
assert_equal :attr, opts.type
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_attr_is_a_recognized_type
|
63
|
-
assert_deprecated do
|
64
|
-
opts = ROXML::Definition.new(:author, :attr)
|
65
|
-
assert_equal 'author', opts.name
|
66
|
-
assert_equal :attr, opts.type
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
4
|
def test_as_array_not_deprecated
|
71
5
|
assert_not_deprecated do
|
72
6
|
opts = ROXML::Definition.new(:name, :as => [])
|
@@ -75,13 +9,6 @@ class TestDeprecation < ActiveSupport::TestCase
|
|
75
9
|
end
|
76
10
|
end
|
77
11
|
|
78
|
-
def test_as_hash_of_attrs_deprecated
|
79
|
-
assert_deprecated do
|
80
|
-
opts = ROXML::Definition.new(:name, :as => {:attrs => [:dt, :dd]})
|
81
|
-
assert opts.hash?
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
12
|
def test_as_hash_not_deprecated
|
86
13
|
assert_not_deprecated do
|
87
14
|
opts = ROXML::Definition.new(:name, :as => {:key => '@dt', :value => '@dd'})
|
data/test/unit/to_xml_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'test/test_helper'
|
2
2
|
|
3
3
|
class TestHashToXml < ActiveSupport::TestCase
|
4
4
|
to_xml_test :dictionary_of_attrs,
|
@@ -33,7 +33,7 @@ class TestToXmlWithDefaults < ActiveSupport::TestCase
|
|
33
33
|
dict = Person.from_xml(fixture(:nameless_ageless_youth))
|
34
34
|
|
35
35
|
xml = '<person age="21">Unknown</person>'
|
36
|
-
assert_equal ROXML::XML::Parser.parse(xml).root, dict.to_xml
|
36
|
+
assert_equal ROXML::XML::Parser.parse(xml).root.to_s, dict.to_xml.to_s
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -73,7 +73,7 @@ class BookWithOctalPages
|
|
73
73
|
include ROXML
|
74
74
|
|
75
75
|
xml_accessor :pages_with_to_xml_proc, :as => Integer, :to_xml => proc {|val| sprintf("%#o", val) }, :required => true
|
76
|
-
xml_accessor :pages_with_type, OctalInteger, :required => true
|
76
|
+
xml_accessor :pages_with_type, :as => OctalInteger, :required => true
|
77
77
|
end
|
78
78
|
|
79
79
|
class TestToXmlWithOverriddenOutput < ActiveSupport::TestCase
|
data/test/unit/xml_block_test.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require 'test/test_helper'
|
2
2
|
|
3
3
|
class ArrayWithBlockShorthand
|
4
4
|
include ROXML
|
5
5
|
|
6
|
-
xml_reader :array, [
|
6
|
+
xml_reader :array, :as => [Integer], :from => 'number'
|
7
7
|
end
|
8
8
|
|
9
9
|
class ArrayWithBlock
|
10
10
|
include ROXML
|
11
11
|
|
12
|
-
xml_reader :array, [
|
12
|
+
xml_reader :array, :as => [], :from => 'number' do |arr|
|
13
13
|
arr.map(&:to_i).reverse
|
14
14
|
end
|
15
15
|
end
|
data/test/unit/xml_bool_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'test/test_helper'
|
2
2
|
|
3
3
|
PROC_TRUE = proc {|val| val ? 'TRUE' : 'FALSE'}
|
4
4
|
PROC_True = proc {|val| val ? 'True' : 'False'}
|
@@ -10,11 +10,11 @@ class XmlBool
|
|
10
10
|
|
11
11
|
xml_name 'xml_bool'
|
12
12
|
xml_reader :true_from_TRUE?, :to_xml => PROC_TRUE
|
13
|
-
xml_reader :false_from_FALSE?, :
|
13
|
+
xml_reader :false_from_FALSE?, :from => 'text_for_FALSE', :to_xml => PROC_TRUE
|
14
14
|
xml_reader :true_from_one?, :from => '@attr_for_one', :to_xml => PROC_1
|
15
|
-
xml_reader :false_from_zero?, :
|
15
|
+
xml_reader :false_from_zero?, :from => 'text_for_zero', :in => 'container', :to_xml => PROC_1
|
16
16
|
xml_reader :true_from_True?, :from => '@attr_for_True', :in => 'container', :to_xml => PROC_True
|
17
|
-
xml_reader :false_from_False?, :
|
17
|
+
xml_reader :false_from_False?, :from => 'false_from_cdata_False', :cdata => true, :to_xml => PROC_True
|
18
18
|
xml_reader :true_from_true?, :to_xml => PROC_true
|
19
19
|
xml_reader :false_from_false?, :to_xml => PROC_true
|
20
20
|
xml_reader :missing?
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'test/test_helper'
|
2
2
|
|
3
3
|
XML_CAMELLOWER = %{
|
4
4
|
<bookCase name="Jonas' Books">
|
@@ -54,7 +54,7 @@ class BookCase
|
|
54
54
|
include ROXML
|
55
55
|
|
56
56
|
xml_reader :book_count, :as => Integer, :required => true
|
57
|
-
xml_reader :big_books, [
|
57
|
+
xml_reader :big_books, :as => [], :required => true
|
58
58
|
end
|
59
59
|
|
60
60
|
class BookCaseCamelCase < BookCase
|
@@ -88,7 +88,7 @@ class ParentBookCaseDefault
|
|
88
88
|
include ROXML
|
89
89
|
|
90
90
|
xml_reader :book_count, :as => Integer, :required => true
|
91
|
-
xml_reader :big_books, [
|
91
|
+
xml_reader :big_books, :as => [], :required => true
|
92
92
|
end
|
93
93
|
|
94
94
|
class InheritedBookCaseDefault < ParentBookCaseDefault
|
data/test/unit/xml_hash_test.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'test/test_helper'
|
2
2
|
|
3
3
|
class BookWithContributorHash
|
4
4
|
include ROXML
|
5
5
|
|
6
|
-
xml_reader :contributors,
|
6
|
+
xml_reader :contributors, :as => {:key => '@role',
|
7
7
|
:value => 'name'}
|
8
8
|
end
|
9
9
|
|
@@ -30,7 +30,7 @@ class TestXMLHash < ActiveSupport::TestCase
|
|
30
30
|
Class.new do
|
31
31
|
include ROXML
|
32
32
|
|
33
|
-
xml_reader :object_key_to_text, {:key => BookWithContributorHash,
|
33
|
+
xml_reader :object_key_to_text, :as => {:key => BookWithContributorHash,
|
34
34
|
:value => 'text_node'}
|
35
35
|
end
|
36
36
|
end
|
@@ -41,7 +41,7 @@ class TestXMLHash < ActiveSupport::TestCase
|
|
41
41
|
Class.new do
|
42
42
|
include ROXML
|
43
43
|
|
44
|
-
xml_reader :key_to_object_value,
|
44
|
+
xml_reader :key_to_object_value, :as => {:key => '@text_node',
|
45
45
|
:value => BookWithContributorHash}
|
46
46
|
end
|
47
47
|
end
|
@@ -93,7 +93,7 @@ class TestXMLHash < ActiveSupport::TestCase
|
|
93
93
|
dict = Class.new do
|
94
94
|
include ROXML
|
95
95
|
|
96
|
-
xml_reader :missing_hash, {:key => :name, :value => :content}, :in => 'EmptyDictionary'
|
96
|
+
xml_reader :missing_hash, :as => {:key => :name, :value => :content}, :in => 'EmptyDictionary'
|
97
97
|
end
|
98
98
|
|
99
99
|
assert_equal({}, dict.from_xml(%{
|
@@ -104,15 +104,6 @@ class TestXMLHash < ActiveSupport::TestCase
|
|
104
104
|
}).missing_hash)
|
105
105
|
end
|
106
106
|
|
107
|
-
def test_as_hash_of_type_keys_deprecated
|
108
|
-
assert_deprecated do
|
109
|
-
opts = ROXML::Definition.new(:name, :as => {:key => :name, :value => {OctalInteger => 'value'}})
|
110
|
-
assert opts.hash?
|
111
|
-
assert_equal OctalInteger, opts.hash.value.type
|
112
|
-
assert_equal 'value', opts.hash.value.name
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
107
|
def test_as_hash_of_as_type_not_deprecated
|
117
108
|
assert_not_deprecated do
|
118
109
|
opts = ROXML::Definition.new(:name, :as => {:key => :name, :value => {:from => 'value', :as => OctalInteger}})
|