Sha256: 2df092279dd20b251f3b5d7ad7d7976dff0e8cabab32cbb5d168eac65f1f8683

Contents?: true

Size: 888 Bytes

Versions: 37

Compression:

Stored size: 888 Bytes

Contents

Feature: allow a message on any instance of a class

  Use `allow_any_instance_of(Class).to receive` when you want to configure how
  instances of the given class respond to a message without setting an
  expectation that the message will be received.

  Scenario: allowing a message on any instance of a class
    Given a file named "example_spec.rb" with:
      """ruby
      describe "any_instance.should_receive" do
        before do
          allow_any_instance_of(Object).to receive(:foo).and_return(:return_value)
        end

        it "allows any instance of the class to receive the message" do
          o = Object.new
          expect(o.foo).to eq(:return_value)
        end

        it "passes even if no instances receive that message" do
          o = Object.new
        end
      end
      """
    When I run `rspec example_spec.rb`
    Then the examples should all pass

Version data entries

37 entries across 37 versions & 8 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/message_expectations/allow_any_instance_of.feature
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/message_expectations/allow_any_instance_of.feature
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/message_expectations/allow_any_instance_of.feature
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/message_expectations/allow_any_instance_of.feature
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/message_expectations/allow_any_instance_of.feature
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/message_expectations/allow_any_instance_of.feature
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/message_expectations/allow_any_instance_of.feature
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/message_expectations/allow_any_instance_of.feature
rspec-mocks-2.99.4 features/message_expectations/allow_any_instance_of.feature
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-mocks-2.14.6/features/message_expectations/allow_any_instance_of.feature
rspec-mocks-2.99.3 features/message_expectations/allow_any_instance_of.feature
rspec-mocks-2.99.2 features/message_expectations/allow_any_instance_of.feature
dxruby_rp5-0.0.4 spec/vendor/rspec-mocks-2.14.4/features/message_expectations/allow_any_instance_of.feature
rspec-mocks-2.99.1 features/message_expectations/allow_any_instance_of.feature
rspec-mocks-2.99.0 features/message_expectations/allow_any_instance_of.feature
rspec-mocks-2.99.0.rc1 features/message_expectations/allow_any_instance_of.feature
rspec-mocks-2.14.6 features/message_expectations/allow_any_instance_of.feature
rspec-mocks-2.99.0.beta2 features/message_expectations/allow_any_instance_of.feature
rspec-mocks-2.14.5 features/message_expectations/allow_any_instance_of.feature
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-mocks-2.14.4/features/message_expectations/allow_any_instance_of.feature