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

Specify shared_context used with conditions in example group #2775

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions features/example_groups/shared_context.feature
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,28 @@ Feature: shared context
"""
When I run `rspec shared_context_example.rb`
Then the examples should all pass

Scenario: Declare a shared context under an example group and include it with metadata to child groups
Given a file named "shared_context_example.rb" with:
"""ruby
RSpec.describe "group that defines a local shared context" do

subject { 'this is the group subject' }

shared_context "local stuff" do
subject { 'this is the local context subject' }
end

include_context "local stuff", :include_local => true

it "does not have access to local shared methods normally" do
expect(subject).to eq('this is the group subject')
end

it "has access to local shared methods from examples with matching metadata", :include_local => true do
expect(subject).to eq('this is the local context subject')
end
end
"""
When I run `rspec shared_context_example.rb`
Then the examples should all pass