require File.dirname(__FILE__) + '/persistable_helper.rb' describe CouchObject::Persistable, "behaviour related to cloning and copying:" do before(:each) do @db = mock("mock db") content = HTTPResponse.new(JSON.unparse({ "_id" => "123BAC", "_rev" => "946B7D1C", "class" => WithCallbacks, "created_at" => Time.new, "updated_at" => Time.new, "attributes" => {} })) @empty_response = {} @ok_response = {"ok" => true} @document_response = CouchObject::Response.new(content) end it "all callback should be called" do CouchObject::Database.should_receive(:open).exactly(3).and_return(@db) @db.should_receive(:post).and_return(@document_response) @db.should_receive(:put).and_return(@document_response) @db.should_receive(:delete).and_return(@document_response) wc = WithCallbacks.new wc.save wc.save wc.delete wc.calls.should == ["before_save", "before_create", "after_create", "after_save", "before_save", "before_update", "after_update", "after_save", "before_delete", "after_delete"] end end