Sha256: 1a6eb577e3f4f0caa91cdac80cfbdd40e07e0c16a316ecfd975586bbf04bddc6

Contents?: true

Size: 1.51 KB

Versions: 32

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

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

32 entries across 32 versions & 11 rubygems

Version Path
rspec-instructure-1.3.3 spec/spec/mocks/precise_counts_spec.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-1.3.2/spec/spec/mocks/precise_counts_spec.rb
rspec-1.3.2 spec/spec/mocks/precise_counts_spec.rb
rspec-1.3.1 spec/spec/mocks/precise_counts_spec.rb
rspec-1.3.1.rc spec/spec/mocks/precise_counts_spec.rb
rspec-1.3.0 spec/spec/mocks/precise_counts_spec.rb
hubbub-0.0.11 lib/vendor/plugins/rspec/spec/spec/mocks/precise_counts_spec.rb
hubbub-0.0.10 lib/vendor/plugins/rspec/spec/spec/mocks/precise_counts_spec.rb
hubbub-0.0.9 lib/vendor/plugins/rspec/spec/spec/mocks/precise_counts_spec.rb
hubbub-0.0.8 lib/vendor/plugins/rspec/spec/spec/mocks/precise_counts_spec.rb
hubbub-0.0.6 lib/vendor/plugins/rspec/spec/spec/mocks/precise_counts_spec.rb
simple-templater-0.0.1.4 gems/gems/rspec-1.2.9/spec/spec/mocks/precise_counts_spec.rb
media-path-0.1.2 vendor/rspec/spec/spec/mocks/precise_counts_spec.rb
simple-templater-0.0.1.3 vendor/rspec/spec/spec/mocks/precise_counts_spec.rb
pupu-0.0.2.pre vendor/rspec/spec/spec/mocks/precise_counts_spec.rb
media-path-0.1.1.pre vendor/rspec/spec/spec/mocks/precise_counts_spec.rb
simple-templater-0.0.1.2 vendor/rspec/spec/spec/mocks/precise_counts_spec.rb
media-path-0.1.1 vendor/rspec/spec/spec/mocks/precise_counts_spec.rb
simple-templater-0.0.1.1 vendor/rspec/spec/spec/mocks/precise_counts_spec.rb
pupu-0.0.2 vendor/rspec/spec/spec/mocks/precise_counts_spec.rb