Sha256: 97d49711fa67c56fa7bc07d6839e62a4173b235b0d48ab1c2fab6b1a30a0156a

Contents?: true

Size: 1.41 KB

Versions: 12

Compression:

Stored size: 1.41 KB

Contents

Feature: access running example

  In the context of a custom matcher, you can call helper methods that are available from the
  current example's example group. This is used, for example, by rspec-rails in order to wrap
  rails' built-in assertions (which depend on helper methods available in the test context).

  Scenario: call method defined on example from matcher
    Given a file named "example_spec.rb" with:
      """ruby
      RSpec::Matchers.define :bar do
        match do |_|
          foo == "foo"
        end
      end

      RSpec.describe "something" do
        def foo
          "foo"
        end

        it "does something" do
          expect("foo").to bar
        end
      end
      """
    When I run `rspec ./example_spec.rb`
    Then the output should contain "1 example, 0 failures"

  Scenario: call method _not_ defined on example from matcher
    Given a file named "example_spec.rb" with:
      """ruby
      RSpec::Matchers.define :bar do
        match do |_|
          foo == "foo"
        end
      end

      RSpec.describe "something" do
        it "does something" do
          expect("foo").to bar
        end
      end
      """
    When I run `rspec ./example_spec.rb`
    Then the output should contain "1 example, 1 failure"
    And the output should match /undefined.*method/
    And the output should contain "RSpec::Matchers::DSL::Matcher"
    And the output should not contain "ExampleGroup"

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
opal-rspec-1.1.0.alpha3 rspec-expectations/upstream/features/custom_matchers/access_running_example.feature
opal-rspec-1.1.0.alpha2 rspec-expectations/upstream/features/custom_matchers/access_running_example.feature
opal-rspec-1.1.0.alpha1 rspec-expectations/upstream/features/custom_matchers/access_running_example.feature
opal-rspec-1.0.0 rspec-expectations/upstream/features/custom_matchers/access_running_example.feature
opal-rspec-1.0.0.alpha1 rspec-expectations/upstream/features/custom_matchers/access_running_example.feature
opal-rspec-0.8.0 rspec-expectations/upstream/features/custom_matchers/access_running_example.feature
opal-rspec-0.8.0.alpha3 rspec-expectations/upstream/features/custom_matchers/access_running_example.feature
opal-rspec-0.8.0.alpha2 rspec-expectations/upstream/features/custom_matchers/access_running_example.feature
opal-rspec-0.8.0.alpha1 rspec-expectations/upstream/features/custom_matchers/access_running_example.feature
opal-rspec-0.7.1 rspec-expectations/upstream/features/custom_matchers/access_running_example.feature
opal-rspec-0.7.0 rspec-expectations/upstream/features/custom_matchers/access_running_example.feature
opal-rspec-0.7.0.rc.2 rspec-expectations/upstream/features/custom_matchers/access_running_example.feature