Duff OMelia  committed e56b5c6

Improve handling of properties we don't know about.

Allow the NoMethodError to happen rather than eating it with the

  • Participants
  • Parent commits f67d8d2

Comments (0)

Files changed (2)

File ripple/lib/ripple/document/finders.rb

           klass =['_type'].constantize rescue self
  do |doc|
             doc.key = robject.key
-  "_type").each {|k,v| doc.send("#{k}=", v) } rescue nil
+  "_type").each {|k,v| doc.send("#{k}=", v) } if
             doc.instance_variable_set(:@new, false)
             doc.instance_variable_set(:@robject, robject)

File ripple/spec/ripple/finders_spec.rb

       lambda { Box.find!("square") }.should_not raise_error(Ripple::DocumentNotFound)
+    it "should raise an exception when finding an existing document that has properties we don't know about" do
+      @http.should_receive(:get).with(200, "/riak/", "boxes", "square", {}, {}).and_return({:code => 200, :headers => {"content-type" => ["application/json"]}, :body => '{"non_existent_property":"whatever"}'})
+      lambda { Box.find("square") }.should raise_error
+    end
     it "should return the document when calling find!" do
       @http.should_receive(:get).with(200, "/riak/", "boxes", "square", {}, {}).and_return({:code => 200, :headers => {"content-type" => ["application/json"]}, :body => '{"shape":"square"}'})
       box = Box.find!("square")