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
rspec-mocks-2.10.1 spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.10.0 spec/rspec/mocks/any_number_of_times_spec.rb
horseman-0.0.5 vendor/ruby/1.9.1/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classicCMS-0.2.3 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classicCMS-0.2.2 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classicCMS-0.2.1 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classicCMS-0.2.0 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
classicCMS-0.1.2 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_number_of_times_spec.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.8.0/spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.9.0 spec/rspec/mocks/any_number_of_times_spec.rb
rspec-mocks-2.9.0.rc2 spec/rspec/mocks/any_number_of_times_spec.rb
horseman-0.0.4 vendor/ruby/1.9.1/gems/rspec-mocks-2.7.0/spec/rspec/mocks/any_number_of_times_spec.rb
horseman-0.0.4 vendor/ruby/1.9.1/gems/rspec-mocks-2.8.0/spec/rspec/mocks/any_number_of_times_spec.rb
horseman-0.0.3 vendor/ruby/1.9.1/gems/rspec-mocks-2.8.0/spec/rspec/mocks/any_number_of_times_spec.rb
horseman-0.0.3 vendor/ruby/1.9.1/gems/rspec-mocks-2.7.0/spec/rspec/mocks/any_number_of_times_spec.rb