Sha256: ee7890ef0be55d1f24764048014a82c9e01e8db530aa9c37cf586f56185126c0

Contents?: true

Size: 793 Bytes

Versions: 4

Compression:

Stored size: 793 Bytes

Contents

Feature: stub on any instance of a class

  Use `any_instance.stub` on a class to tell any instance of that class to
  return a value (or values) in response to a given message.  If no instance
  receives the message, nothing happens.

  Messages can be stubbed on any class, including those in Ruby's core library.

  Scenario: simple any_instance stub with a single return value
    Given a file named "example_spec.rb" with:
      """
      describe "any_instance.stub" do
        it "returns the specified value on any instance of the class" do
          Object.any_instance.stub(:foo).and_return(:return_value)

          o = Object.new
          o.foo.should eq(:return_value)
        end
      end
      """
    When I run `rspec example_spec.rb`
    Then the examples should all pass

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-mocks-2.6.0 features/method_stubs/any_instance.feature
rspec-mocks-2.6.0.rc6 features/method_stubs/any_instance.feature
rspec-mocks-2.6.0.rc4 features/method_stubs/any_instance.feature
rspec-mocks-2.6.0.rc2 features/method_stubs/any_instance.feature