X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/ddd5b4cf19a92582fd114914be5bd5a04d3522a7..3f607d565bc0e2c7b1b738301c11c16d069913d5:/vendor/gems/rspec-1.1.2/spec/spec/mocks/at_most_spec.rb diff --git a/vendor/gems/rspec-1.1.2/spec/spec/mocks/at_most_spec.rb b/vendor/gems/rspec-1.1.2/spec/spec/mocks/at_most_spec.rb new file mode 100644 index 000000000..f3c5e2150 --- /dev/null +++ b/vendor/gems/rspec-1.1.2/spec/spec/mocks/at_most_spec.rb @@ -0,0 +1,93 @@ +require File.dirname(__FILE__) + '/../../spec_helper.rb' + +module Spec + module Mocks + describe "at_most" do + before(:each) do + @mock = Mock.new("test mock") + end + + it "should fail when at most n times method is called n plus 1 times" do + @mock.should_receive(:random_call).at_most(4).times + @mock.random_call + @mock.random_call + @mock.random_call + @mock.random_call + @mock.random_call + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "should fail when at most once method is called twice" do + @mock.should_receive(:random_call).at_most(:once) + @mock.random_call + @mock.random_call + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "should fail when at most twice method is called three times" do + @mock.should_receive(:random_call).at_most(:twice) + @mock.random_call + @mock.random_call + @mock.random_call + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "should pass when at most n times method is called exactly n times" do + @mock.should_receive(:random_call).at_most(4).times + @mock.random_call + @mock.random_call + @mock.random_call + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at most n times method is called less than n times" do + @mock.should_receive(:random_call).at_most(4).times + @mock.random_call + @mock.random_call + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at most n times method is never called" do + @mock.should_receive(:random_call).at_most(4).times + @mock.rspec_verify + end + + it "should pass when at most once method is called once" do + @mock.should_receive(:random_call).at_most(:once) + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at most once method is never called" do + @mock.should_receive(:random_call).at_most(:once) + @mock.rspec_verify + end + + it "should pass when at most twice method is called once" do + @mock.should_receive(:random_call).at_most(:twice) + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at most twice method is called twice" do + @mock.should_receive(:random_call).at_most(:twice) + @mock.random_call + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at most twice method is never called" do + @mock.should_receive(:random_call).at_most(:twice) + @mock.rspec_verify + end + end + end +end