Sha256: 9f863c43923a860f1f2d3e4464b1bc9ecc3f8f963c1ea8a3cfaed1a9201fe48b

Contents?: true

Size: 1.58 KB

Versions: 4

Compression:

Stored size: 1.58 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

module Spec
module Mocks
context "PreciseCounts" do
    setup do
        @mock = Mock.new("test mock", {
          :auto_verify => false
        })
      
    end
    specify "should fail when exactly n times method is called less than n times" do
        @mock.should_receive(:random_call).exactly(3).times
        @mock.random_call
        @mock.random_call
        lambda do
          @mock.__verify
        end.should_raise(MockExpectationError)
      
    end
    specify "should fail when exactly n times method is never called" do
        @mock.should_receive(:random_call).exactly(3).times
        lambda do
          @mock.__verify
        end.should_raise(MockExpectationError)
      
    end
    specify "should pass if exactly n times method is called exactly n times" do
        @mock.should_receive(:random_call).exactly(3).times
        @mock.random_call
        @mock.random_call
        @mock.random_call
        @mock.__verify
      
    end
    specify "should pass multiple calls with different args and counts" do
        @mock.should_receive(:random_call).twice.with(1)
        @mock.should_receive(:random_call).once.with(2)
        @mock.random_call(1)
        @mock.random_call(2)
        @mock.random_call(1)
        @mock.__verify
      
    end
    specify "should pass mutiple calls with different args" do
        @mock.should_receive(:random_call).once.with(1)
        @mock.should_receive(:random_call).once.with(2)
        @mock.random_call(1)
        @mock.random_call(2)
        @mock.__verify
      
    end
  
end
end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
riess-0.0.8 vendor/rspec-0.8.2/spec/spec/mocks/precise_counts_spec.rb
rspec-0.8.0 spec/spec/mocks/precise_counts_spec.rb
rspec-0.8.1 spec/spec/mocks/precise_counts_spec.rb
rspec-0.8.2 spec/spec/mocks/precise_counts_spec.rb