class DescribeBowlerMock(Spec): def before(self): self.m = Mock() def it_should_accept_specific_kwarg(self): self.m.should_access.bowl(score=8).and_return(80) Value(self.m).invoking.bowl(score=8).should == 80 def it_should_allow_property_reads(self): self.m.should_access.score.and_return(0) Value(self.m).get.score.should == 0 @fails_verification def it_should_require_it_to_be_called(self): self.m.should_access.set_scores(ANYTHING) def it_should_success_with_any_args(self): self.m.should_access.set_scores(ANYTHING) self.m.set_scores(5, 5, 7, 7, 10) @fails_verification def it_should_fail_when_requiring_bowl_to_be_called_10_times(self): self.m.should_access.bowl(ANY_ARG).and_return(70).exactly(10).times self.m.bowl(5) def it_should_require_bowl_to_be_called_10_times(self): self.m.should_access.bowl(ANY_ARG).and_return(70).exactly(10).times for i in range(10): self.m.bowl(i) def it_should_require_bowl_to_be_called_at_least_5_times(self): self.m.should_access.bowl(ANY_ARG).and_return(70).at_least(10).times for i in range(10): self.m.bowl(i) @fails_verification def it_should_fail_when_requiring_bowl_to_be_called_at_least_5_times(self): self.m.should_access.bowl(ANY_ARG).and_return(70).at_least(10).times for i in range(3): self.m.bowl(i) def it_should_require_bowl_to_be_called_at_most_8_times(self): self.m.should_access.bowl(ANY_ARG).and_return(70).at_most(8).times for i in range(7): self.m.bowl(i) @fails_verification def it_should_fail_when_requiring_bowl_to_be_called_at_most_8_times(self): self.m.should_access.bowl(ANY_ARG).and_return(70).at_most(8).times for i in range(10): self.m.bowl(i)