load expects a Hash

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5008 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper 2006-09-05 00:02:17 +00:00
parent b445ab986a
commit 26b76ea4ce
2 changed files with 4 additions and 5 deletions

View File

@ -134,7 +134,7 @@ module ActiveResource
# 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

View File

@ -14,10 +14,9 @@ class BaseLoadTest < Test::Unit::TestCase
@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