diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 40a50201a71636fff70971c8208f60590b57732e..56c6dc172b0043671226c0c3608965ac3edcf95e 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -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 diff --git a/activeresource/test/base/load_test.rb b/activeresource/test/base/load_test.rb index 726e7100b7044c219d1acbf4bc9ca1dc3d5964b4..97faebc1435b1186512810d4615a6131c8fcf95f 100644 --- a/activeresource/test/base/load_test.rb +++ b/activeresource/test/base/load_test.rb @@ -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 '' } end def test_load_simple_hash