Sha256: 3bbb94da95486c96a557979af2e2d4e881eb82333ca4fc49b04aeb0156de90b6

Contents?: true

Size: 1.51 KB

Versions: 30

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

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

      it "fails 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(RSpec::Mocks::MockExpectationError)
      end

      it "fails 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(RSpec::Mocks::MockExpectationError)
      end

      it "passes 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 "passes 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 "passes 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

30 entries across 30 versions & 4 rubygems

Version Path
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/rspec-mocks-2.5.0/spec/rspec/mocks/precise_counts_spec.rb
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rspec-mocks-2.5.0/spec/rspec/mocks/precise_counts_spec.rb
rspec-mocks-2.5.0 spec/rspec/mocks/precise_counts_spec.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/precise_counts_spec.rb
rspec-mocks-2.4.0 spec/rspec/mocks/precise_counts_spec.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/precise_counts_spec.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/precise_counts_spec.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/precise_counts_spec.rb
rspec-mocks-2.3.0 spec/rspec/mocks/precise_counts_spec.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/precise_counts_spec.rb
vim-jar-0.0.2 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/precise_counts_spec.rb
vim-jar-0.0.1 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/precise_counts_spec.rb
rspec-mocks-2.2.0 spec/rspec/mocks/precise_counts_spec.rb
rspec-mocks-2.1.0 spec/rspec/mocks/precise_counts_spec.rb
rspec-mocks-2.0.1 spec/rspec/mocks/precise_counts_spec.rb
gemrage-1.0.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/spec/rspec/mocks/precise_counts_spec.rb
gemrage-0.4.1 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/spec/rspec/mocks/precise_counts_spec.rb
gemrage-0.4.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/spec/rspec/mocks/precise_counts_spec.rb
gemrage-0.3.2 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/spec/rspec/mocks/precise_counts_spec.rb
gemrage-0.3.1 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/spec/rspec/mocks/precise_counts_spec.rb