Sha256: 37dd7e27cc9c2f7432bd582cd49d45f848e70504cbee5232f89b6d8d109c5eb0

Contents?: true

Size: 975 Bytes

Versions: 12

Compression:

Stored size: 975 Bytes

Contents

Feature: Throwing

  Use `and_throw` to make the test double throw the provided symbol, optionally with the provided argument.

    * `and_throw(:symbol)`
    * `and_throw(:symbol, argument)`

  Scenario: Throw a symbol
    Given a file named "and_throw_spec.rb" with:
      """ruby
      RSpec.describe "Making it throw a symbol" do
        it "throws the provided symbol" do
          dbl = double
          allow(dbl).to receive(:foo).and_throw(:hello)

          catch :hello do
            dbl.foo
            fail "should not get here"
          end
        end

        it "includes the provided argument when throwing" do
          dbl = double
          allow(dbl).to receive(:foo).and_throw(:hello, "world")

          arg = catch :hello do
            dbl.foo
            fail "should not get here"
          end

          expect(arg).to eq("world")
        end
      end
      """
     When I run `rspec and_throw_spec.rb`
     Then the examples should all pass

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
opal-rspec-1.1.0.alpha3 rspec-mocks/upstream/features/configuring_responses/throwing.feature
opal-rspec-1.1.0.alpha2 rspec-mocks/upstream/features/configuring_responses/throwing.feature
opal-rspec-1.1.0.alpha1 rspec-mocks/upstream/features/configuring_responses/throwing.feature
opal-rspec-1.0.0 rspec-mocks/upstream/features/configuring_responses/throwing.feature
opal-rspec-1.0.0.alpha1 rspec-mocks/upstream/features/configuring_responses/throwing.feature
opal-rspec-0.8.0 rspec-mocks/upstream/features/configuring_responses/throwing.feature
opal-rspec-0.8.0.alpha3 rspec-mocks/upstream/features/configuring_responses/throwing.feature
opal-rspec-0.8.0.alpha2 rspec-mocks/upstream/features/configuring_responses/throwing.feature
opal-rspec-0.8.0.alpha1 rspec-mocks/upstream/features/configuring_responses/throwing.feature
opal-rspec-0.7.1 rspec-mocks/upstream/features/configuring_responses/throwing.feature
opal-rspec-0.7.0 rspec-mocks/upstream/features/configuring_responses/throwing.feature
opal-rspec-0.7.0.rc.2 rspec-mocks/upstream/features/configuring_responses/throwing.feature