spec/ripple/callbacks_spec.rb in ripple-0.8.3 vs spec/ripple/callbacks_spec.rb in ripple-0.9.0.beta
- old
+ new
@@ -33,12 +33,12 @@
describe "invoking callbacks" do
before :each do
response = {:headers => {"content-type" => ["application/json"]}, :body => "{}"}
@client = Ripple.client
- @http = mock("HTTP Backend", :get => response, :put => response, :post => response, :delete => response)
- @client.stub!(:http).and_return(@http)
+ @backend = mock("Backend", :store_object => true)
+ @client.stub!(:backend).and_return(@backend)
$pinger = mock("callback verifier")
end
it "should call save callbacks on save" do
Box.before_save { $pinger.ping }
@@ -74,20 +74,20 @@
Box.around_destroy(lambda { $pinger.ping })
$pinger.should_receive(:ping).exactly(3).times
@box = Box.new
@box.destroy
end
-
+
describe "validation callbacks" do
it "should call validation callbacks" do
Box.before_validation { $pinger.ping }
Box.after_validation { $pinger.ping }
$pinger.should_receive(:ping).twice
@box = Box.new
@box.valid?
end
-
+
it "should call validation callbacks only if the document is new" do
Box.before_validation(:on => :create) { $pinger.ping }
Box.after_validation(:on => :create) { $pinger.ping }
$pinger.should_receive(:ping).twice
@box = Box.new
@@ -99,10 +99,10 @@
Box.after_validation(:on => :update) { $pinger.ping }
$pinger.should_not_receive(:ping)
@box = Box.new
@box.valid?
end
-
+
it "should call validation callbacks only if the document is not new" do
Box.before_validation(:on => :update) { $pinger.ping }
Box.after_validation(:on => :update) { $pinger.ping }
$pinger.should_receive(:ping).twice
@box = Box.new