1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
5 describe "PreciseCounts" do
7 @mock = mock("test mock")
10 it "should fail when exactly n times method is called less than n times" do
11 @mock.should_receive(:random_call).exactly(3).times
16 end.should raise_error(MockExpectationError)
19 it "should fail when exactly n times method is never called" do
20 @mock.should_receive(:random_call).exactly(3).times
23 end.should raise_error(MockExpectationError)
26 it "should pass if exactly n times method is called exactly n times" do
27 @mock.should_receive(:random_call).exactly(3).times
34 it "should pass multiple calls with different args and counts" do
35 @mock.should_receive(:random_call).twice.with(1)
36 @mock.should_receive(:random_call).once.with(2)
43 it "should pass mutiple calls with different args" do
44 @mock.should_receive(:random_call).once.with(1)
45 @mock.should_receive(:random_call).once.with(2)