Sha256: 3226d55b329efc75309808f8bbbd8cf21224859e8de8245f64546f877a194631

Contents?: true

Size: 1.59 KB

Versions: 38

Compression:

Stored size: 1.59 KB

Contents

Feature: configure any test framework to use rspec-mocks

  Test frameworks that want to use rspec-mocks can use
  RSpec::Mocks::setup(self) to hook into rspec-mocks. Doing so adds the
  following:

    To the object passed to setup:

      double # creates a test double
      mock   # creates a test double
      stub   # creates a test double

    To every object in the system:

      should_receive
      should_not_receive
      stub

  NOTICE: the stub() method that is added to the object passed to setup is not
  the same stub() method that is added to every other object.

  Scenario: RSpec::Mocks::setup(object) adds double, mock, and stub methods to the submitted object
    Given a file named "foo.rb" with:
      """ruby
      require 'rspec/mocks'

      class CodeExample
        def init
          RSpec::Mocks::setup(self)
        end
      end

      example = CodeExample.new
      example.init

      puts example.respond_to?(:double)
      puts example.respond_to?(:mock)
      puts example.respond_to?(:stub)
      """

    When I run `ruby foo.rb`
    Then the output should contain "true"
    But  the output should not contain "false"

  Scenario: RSpec::Mocks::setup(anything) adds methods to Object
    Given a file named "foo.rb" with:
      """ruby
      require 'rspec/mocks'

      RSpec::Mocks::setup(Object.new)

      obj = Object.new

      puts obj.respond_to?(:should_receive)
      puts obj.respond_to?(:should_not_receive)
      puts obj.respond_to?(:stub)
      """

    When I run `ruby foo.rb`
    Then the output should contain "true"
    But  the output should not contain "false"

Version data entries

38 entries across 38 versions & 8 rubygems

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