Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

shared_context of type feature executes even when include_context is never called #2276

Closed
@Pistos

Description

@Pistos

To me, this is unexpected behaviour. It is causing test pollution in my case. Consider a shared_context which creates a record in the DB, and some specs expecting no record to exist. It will always exist due to this "bug".

I am not certain this is an issue with rspec-core, as opposed to some other rspec-* library.

Reproducible proof at https://github.com/Pistos/rspec-shared-context-executed .


% bundle exec rspec
requiring "./spec/support/shared-context-with-type-feature.rb"
requiring "./spec/support/shared-context-without-type-feature.rb"
executing with feature

rspec
  does not execute the shared_context without feature
  does not execute the shared_context with feature (FAILED - 1)

Failures:

  1) rspec does not execute the shared_context with feature
     Failure/Error: expect($shared_context_with_feature_executed).to be_falsy

       expected: falsey value
            got: true
     # ./spec/rspec-shared-context-spec.rb:7:in `block (2 levels) in <top (required)>'

Finished in 0.01397 seconds (files took 0.45565 seconds to load)
2 examples, 1 failure

Failed examples:

rspec ./spec/rspec-shared-context-spec.rb:6 # rspec does not execute the shared_context with feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions