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.7.5 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.7.5 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.11.3/spec/rspec/mocks/any_number_of_times_spec.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.11.3/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.6.9 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.6.9 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.12.1 spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.12.0 spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.6.8 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb