提交 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
# Manually load attributes from a hash. Recursively loads collections of
# resources.
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[key.to_s] =
case value
......
......@@ -14,10 +14,9 @@ def setup
@person = Person.new
end
def test_load_nil
assert_nothing_raised do
assert_equal @person, @person.load(nil)
end
def test_load_expects_hash
assert_raise(ArgumentError) { @person.load nil }
assert_raise(ArgumentError) { @person.load '<person id="1"/>' }
end
def test_load_simple_hash
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册