Sha256: 33015f859202229fa52d20f91f4812772270df1daaf41aa342ffde99805e222f

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

module Rspec
  module Mocks
    
    describe "AnyNumberOfTimes" do
      before(:each) do
        @mock = Mock.new("test mock")
      end

      it "should pass if any number of times method is called many times" do
        @mock.should_receive(:random_call).any_number_of_times
        (1..10).each do
          @mock.random_call
        end
      end

      it "should pass if any number of times method is called once" do
        @mock.should_receive(:random_call).any_number_of_times
        @mock.random_call
      end
      
      it "should pass if any number of times method is not called" do
        @mock.should_receive(:random_call).any_number_of_times
      end

      it "should return the mocked value when called after a similar stub" do
        @mock.stub!(:message).and_return :stub_value
        @mock.should_receive(:message).any_number_of_times.and_return(:mock_value)
        @mock.message.should == :mock_value
        @mock.message.should == :mock_value
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rspec-mocks-2.0.0.beta.1 spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.0.0.a10 spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.0.0.a9 spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.0.0.a8 spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.0.0.a7 spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.0.0.a6 spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.0.0.a5 spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.0.0.a4 spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.0.0.a3 spec/rspec/mocks/any_number_of_times_spec.rb