Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 5008

Show
Ignore:
Timestamp:
09/05/06 00:02:17 (2 years ago)
Author:
bitsweat
Message:

load expects a Hash

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activeresource/lib/active_resource/base.rb

    r5006 r5008  
    135135    # resources. 
    136136    def load(attributes) 
    137       return self if attributes.nil? 
     137      raise ArgumentError, "expected an attributes Hash, got #{attributes.inspect}" unless attributes.is_a?(Hash) 
    138138      attributes.each do |key, value| 
    139139        @attributes[key.to_s] = 
  • trunk/activeresource/test/base/load_test.rb

    r5006 r5008  
    1515  end 
    1616 
    17   def test_load_nil 
    18     assert_nothing_raised do 
    19       assert_equal @person, @person.load(nil) 
    20     end 
     17  def test_load_expects_hash 
     18    assert_raise(ArgumentError) { @person.load nil } 
     19    assert_raise(ArgumentError) { @person.load '<person id="1"/>' } 
    2120  end 
    2221