test/unit/xml_hash_test.rb in roxml-2.5.3 vs test/unit/xml_hash_test.rb in roxml-3.1.0
- old
+ new
@@ -1,11 +1,11 @@
-require File.join(File.dirname(__FILE__), '..', 'test_helper')
+require 'test/test_helper'
class BookWithContributorHash
include ROXML
- xml_reader :contributors, {:key => {:attr => 'role'},
+ xml_reader :contributors, :as => {:key => '@role',
:value => 'name'}
end
class TestXMLHash < ActiveSupport::TestCase
def setup
@@ -28,22 +28,22 @@
def test_hash_with_object_key_fails
assert_raise ArgumentError do
Class.new do
include ROXML
- xml_reader :object_key_to_text, {:key => BookWithContributorHash,
+ xml_reader :object_key_to_text, :as => {:key => BookWithContributorHash,
:value => 'text_node'}
end
end
end
def test_hash_with_object_value_fails
assert_raise ArgumentError do
Class.new do
include ROXML
- xml_reader :key_to_object_value, {:key => {:attr => 'text_node'},
+ xml_reader :key_to_object_value, :as => {:key => '@text_node',
:value => BookWithContributorHash}
end
end
end
@@ -91,27 +91,18 @@
def test_it_should_gracefully_handle_empty_hash
dict = Class.new do
include ROXML
- xml_reader :missing_hash, {:key => :name, :value => :content}, :in => 'EmptyDictionary'
+ xml_reader :missing_hash, :as => {:key => :name, :value => :content}, :in => 'EmptyDictionary'
end
assert_equal({}, dict.from_xml(%{
<dict>
<EmptyDictionary>
</EmptyDictionary>
</dict>
}).missing_hash)
- end
-
- def test_as_hash_of_type_keys_deprecated
- assert_deprecated do
- opts = ROXML::Definition.new(:name, :as => {:key => :name, :value => {OctalInteger => 'value'}})
- assert opts.hash?
- assert_equal OctalInteger, opts.hash.value.type
- assert_equal 'value', opts.hash.value.name
- end
end
def test_as_hash_of_as_type_not_deprecated
assert_not_deprecated do
opts = ROXML::Definition.new(:name, :as => {:key => :name, :value => {:from => 'value', :as => OctalInteger}})
\ No newline at end of file