Sha256: ea2cdcab73325e475886e210fb57e9417c4449c44948604e29e2d588d518dca5

Contents?: true

Size: 876 Bytes

Versions: 152

Compression:

Stored size: 876 Bytes

Contents

require 'spec_helper'

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 eq :mock_value
    @mock.message.should eq :mock_value
  end
end

Version data entries

152 entries across 98 versions & 14 rubygems

Version Path
classiccms-0.3.5 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.3.5 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.3.4 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.3.4 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.3.3 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.3.3 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.3.2 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.3.2 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.3.1 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.3.1 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.3.0 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.3.0 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
rails-uploader-0.0.1 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.8.0/spec/rspec/mocks/any_number_of_times_spec.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
ftl-0.2.0 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.2.4.pre vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.2.4.pre vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb