Sha256: ebb3a7c257def73577abe6b19657c1a90344ecb46c45b0167f3d648be02724bd

Contents?: true

Size: 883 Bytes

Versions: 5

Compression:

Stored size: 883 Bytes

Contents

Feature: Raising an error

  Use `and_raise` to make the test double raise an error when it receives the message. Any of the following forms are supported:

    * `and_raise(ExceptionClass)`
    * `and_raise("message")`
    * `and_raise(ExceptionClass, "message")`
    * `and_raise(instance_of_an_exception_class)`

  Scenario: Raising an error
    Given a file named "raises_an_error_spec.rb" with:
      """ruby
      RSpec.describe "Making it raise an error" do
        it "raises the provided exception" do
          dbl = double
          allow(dbl).to receive(:foo).and_raise("boom")
          dbl.foo
        end
      end
      """
     When I run `rspec raises_an_error_spec.rb`
     Then it should fail with:
      """
        1) Making it raise an error raises the provided exception
           Failure/Error: dbl.foo

           RuntimeError:
             boom
      """

Version data entries

5 entries across 5 versions & 1 rubygems

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