提交 26b76ea4 编写于 作者: J Jeremy Kemper

load expects a Hash

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5008 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 b445ab98
...@@ -134,7 +134,7 @@ def reload ...@@ -134,7 +134,7 @@ def reload
# Manually load attributes from a hash. Recursively loads collections of # Manually load attributes from a hash. Recursively loads collections of
# resources. # resources.
def load(attributes) def load(attributes)
return self if attributes.nil? raise ArgumentError, "expected an attributes Hash, got #{attributes.inspect}" unless attributes.is_a?(Hash)
attributes.each do |key, value| attributes.each do |key, value|
@attributes[key.to_s] = @attributes[key.to_s] =
case value case value
......
...@@ -14,10 +14,9 @@ def setup ...@@ -14,10 +14,9 @@ def setup
@person = Person.new @person = Person.new
end end
def test_load_nil def test_load_expects_hash
assert_nothing_raised do assert_raise(ArgumentError) { @person.load nil }
assert_equal @person, @person.load(nil) assert_raise(ArgumentError) { @person.load '<person id="1"/>' }
end
end end
def test_load_simple_hash def test_load_simple_hash
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册