1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
5 describe "OnceCounts" do
7 @mock = mock("test mock")
10 it "once should fail when called once with wrong args" do
11 @mock.should_receive(:random_call).once.with("a", "b", "c")
13 @mock.random_call("d", "e", "f")
14 end.should raise_error(MockExpectationError)
18 it "once should fail when called twice" do
19 @mock.should_receive(:random_call).once
24 end.should raise_error(MockExpectationError)
27 it "once should fail when not called" do
28 @mock.should_receive(:random_call).once
31 end.should raise_error(MockExpectationError)
34 it "once should pass when called once" do
35 @mock.should_receive(:random_call).once
40 it "once should pass when called once with specified args" do
41 @mock.should_receive(:random_call).once.with("a", "b", "c")
42 @mock.random_call("a", "b", "c")
46 it "once should pass when called once with unspecified args" do
47 @mock.should_receive(:random_call).once
48 @mock.random_call("a", "b", "c")