You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.
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
The text was updated successfully, but these errors were encountered:
This seems to be a duplicate of #1821, that is fixed in #2878, and will be released in RSpec 4.
I encourage you to use the 4-0-dev branch if you want to use it before the release.
Can you please confirm that 4-0-dev fixes the issue?
Subject of the issue
Filters on
include_context
are ignored if passed in the wrong orderYour environment
Steps to reproduce
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:
The text was updated successfully, but these errors were encountered: