Sha256: 9e2dda1c4933c4e476692e48b8f0d00fb0d2ad7622c3d391a07afe8829f37037

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

Feature: Standalone

  `require "rspec/mocks/standalone"` to expose the API at the top level (e.g. `main`) outside
  the RSpec environment in a REPL like IRB or in a one-off script.

  Scenario: Allow a message outside RSpec
    Given a file named "example.rb" with:
      """ruby
      require "rspec/mocks/standalone"

      greeter = double("greeter")
      allow(greeter).to receive(:say_hi) { "Hello!" }
      puts greeter.say_hi
      """
    When I run `ruby example.rb`
    Then the output should contain "Hello!"

  Scenario: Expect a message outside RSpec
    Given a file named "example.rb" with:
      """ruby
      require "rspec/mocks/standalone"

      greeter = double("greeter")
      expect(greeter).to receive(:say_hi)

      RSpec::Mocks.verify
      """
    When I run `ruby example.rb`
    Then it should fail with the following output:
      | (Double "greeter").say_hi(*(any args)) |
      | RSpec::Mocks::MockExpectationError     |
      | expected: 1 time with any arguments    |
      | received: 0 times with any arguments   |

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opal-rspec-1.1.0.alpha3 rspec-mocks/upstream/features/outside_rspec/standalone.feature
opal-rspec-1.1.0.alpha2 rspec-mocks/upstream/features/outside_rspec/standalone.feature
opal-rspec-1.1.0.alpha1 rspec-mocks/upstream/features/outside_rspec/standalone.feature
opal-rspec-1.0.0 rspec-mocks/upstream/features/outside_rspec/standalone.feature
opal-rspec-1.0.0.alpha1 rspec-mocks/upstream/features/outside_rspec/standalone.feature