1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
7 @mock = Mock.new("test mock")
10 it "should fail when at most n times method is called n plus 1 times" do
11 @mock.should_receive(:random_call).at_most(4).times
19 end.should raise_error(MockExpectationError)
22 it "should fail when at most once method is called twice" do
23 @mock.should_receive(:random_call).at_most(:once)
28 end.should raise_error(MockExpectationError)
31 it "should fail when at most twice method is called three times" do
32 @mock.should_receive(:random_call).at_most(:twice)
38 end.should raise_error(MockExpectationError)
41 it "should pass when at most n times method is called exactly n times" do
42 @mock.should_receive(:random_call).at_most(4).times
50 it "should pass when at most n times method is called less than n times" do
51 @mock.should_receive(:random_call).at_most(4).times
58 it "should pass when at most n times method is never called" do
59 @mock.should_receive(:random_call).at_most(4).times
63 it "should pass when at most once method is called once" do
64 @mock.should_receive(:random_call).at_most(:once)
69 it "should pass when at most once method is never called" do
70 @mock.should_receive(:random_call).at_most(:once)
74 it "should pass when at most twice method is called once" do
75 @mock.should_receive(:random_call).at_most(:twice)
80 it "should pass when at most twice method is called twice" do
81 @mock.should_receive(:random_call).at_most(:twice)
87 it "should pass when at most twice method is never called" do
88 @mock.should_receive(:random_call).at_most(:twice)