This repository was archived by the owner on Nov 30, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 753
This repository was archived by the owner on Nov 30, 2024. It is now read-only.
Filters on include_context
are ignored #2941
Copy link
Copy link
Closed
Description
Subject of the issue
Filters on include_context
are ignored if passed in the wrong order
Your environment
- Ruby version: 3.1.1
- rspec-core version: 3.11.0
Steps to reproduce
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rspec", "3.11.0" # Activate the gem and version you are reporting the issue against.
end
puts "Ruby version is: #{RUBY_VERSION}"
require 'rspec/autorun'
RSpec.shared_context 'default context' do
let(:value) { 1 }
end
RSpec.shared_context 'my context' do
let(:value) { 2 }
end
RSpec.configure do |config|
config.include_context 'default context', type: :bug_report
config.include_context 'my context', :filter_me, type: :bug_report
end
RSpec.describe 'include filters', type: :bug_report do
it 'should have value == 1' do
expect(value).to eq 1
end
it 'should have value == 2', :filter_me do
expect(value).to eq 2
end
end
Expected behavior
The context should only be included on examples matching the filters
Actual behavior
The context is always included
Workaround
Inverting the filters order fixes the issue:
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rspec", "3.11.0" # Activate the gem and version you are reporting the issue against.
end
puts "Ruby version is: #{RUBY_VERSION}"
require 'rspec/autorun'
RSpec.shared_context 'default context' do
let(:value) { 1 }
end
RSpec.shared_context 'my context' do
let(:value) { 2 }
end
RSpec.configure do |config|
config.include_context 'default context', type: :bug_report
config.include_context 'my context', { type: :bug_report }, :filter_me
end
RSpec.describe 'include filters', type: :bug_report do
it 'should have value == 1' do
expect(value).to eq 1
end
it 'should have value == 2', :filter_me do
expect(value).to eq 2
end
end
Metadata
Metadata
Assignees
Labels
No labels