Sha256: 74077e81582317fe28d2593325943a995f77f064dcd06df76fc3c63bbb1752fc

Contents?: true

Size: 1022 Bytes

Versions: 30

Compression:

Stored size: 1022 Bytes

Contents

require 'spec_helper'

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

      it "passes 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 "passes if any number of times method is called once" do
        @mock.should_receive(:random_call).any_number_of_times
        @mock.random_call
      end
      
      it "passes if any number of times method is not called" do
        @mock.should_receive(:random_call).any_number_of_times
      end

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

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/any_number_of_times_spec.rb
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rspec-mocks-2.5.0/spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.5.0 spec/rspec/mocks/any_number_of_times_spec.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.4.0 spec/rspec/mocks/any_number_of_times_spec.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/any_number_of_times_spec.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/any_number_of_times_spec.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.3.0 spec/rspec/mocks/any_number_of_times_spec.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/any_number_of_times_spec.rb
vim-jar-0.0.2 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/any_number_of_times_spec.rb
vim-jar-0.0.1 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.2.0 spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.1.0 spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.0.1 spec/rspec/mocks/any_number_of_times_spec.rb
gemrage-1.0.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/spec/rspec/mocks/any_number_of_times_spec.rb
gemrage-0.4.1 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/spec/rspec/mocks/any_number_of_times_spec.rb
gemrage-0.4.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/spec/rspec/mocks/any_number_of_times_spec.rb
gemrage-0.3.2 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/spec/rspec/mocks/any_number_of_times_spec.rb
gemrage-0.3.1 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/spec/rspec/mocks/any_number_of_times_spec.rb