Sha256: e0319924efbcdb6b49292390c4c418d14d8fd1004066deb8eaa5ae4be104bc7d

Contents?: true

Size: 1.54 KB

Versions: 102

Compression:

Stored size: 1.54 KB

Contents

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

module Spec
  module Mocks
    describe "PreciseCounts" do
      before(:each) do
        @mock = mock("test mock")
      end

      it "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.rspec_verify
        end.should raise_error(MockExpectationError)
      end

      it "should fail when exactly n times method is never called" do
        @mock.should_receive(:random_call).exactly(3).times
        lambda do
          @mock.rspec_verify
        end.should raise_error(MockExpectationError)
      end

      it "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.rspec_verify
      end

      it "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.rspec_verify
      end

      it "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.rspec_verify
      end
    end
  end
end

Version data entries

102 entries across 102 versions & 14 rubygems

Version Path
dchelimsky-rspec-1.1.10 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.11.1 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.11.2 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.11.3 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.11.4 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.11.5 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.11.6 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.11.7 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.11 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.12 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.99.1 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.99.13 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.99.2 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.99.3 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.99.4 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.99.5 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.99.6 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.99.7 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.99.8 spec/spec/mocks/precise_counts_spec.rb
dchelimsky-rspec-1.1.99.9 spec/spec/mocks/precise_counts_spec.rb