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.5.8 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.11.2 spec/rspec/mocks/any_number_of_times_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/rspec-mocks-2.11.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.5.7 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.5.7 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.5.6 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.5.6 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.5.5 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.5.5 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.5.2 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.5.2 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.5.1 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.5.1 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.5.0 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.5.0 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.4.2 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.4.2 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.11.1 spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.11.0 spec/rspec/mocks/any_number_of_times_spec.rb
classiccms-0.4.1 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb