Skip to content

Extract `where` into shared context for project policy spec

Peter Leitzen requested to merge pl-spec-with-them-project-policy into master

What does this MR do and why?

Defining where in a different scope/example group as with_them won't run any examples.

Contributes to #430870.

How to set up and validate locally

  1. Apply the following patch and bundle:
diff --git a/Gemfile b/Gemfile
index 1536fa6bafec..c3bd4ce91b30 100644
--- a/Gemfile
+++ b/Gemfile
@@ -475,6 +475,8 @@ group :test do
   gem 'rspec_profiling', '~> 0.0.6', feature_category: :tooling
   gem 'rspec-benchmark', '~> 0.6.0', feature_category: :tooling
   gem 'rspec-parameterized', '~> 1.0', require: false, feature_category: :tooling
+  gem 'rspec-parameterized-core', '~> 1.0', require: false, feature_category: :tooling,
+    git: 'https://github.com/splattael/rspec-parameterized-core', ref: 'warnings'
 
   gem 'capybara', '~> 3.39', '>= 3.39.2' # rubocop:todo Gemfile/MissingFeatureCategory
   gem 'capybara-screenshot', '~> 1.0.26' # rubocop:todo Gemfile/MissingFeatureCategory
  1. bin/rspec --dry-run spec/policies/project_policy_spec.rb -e "infrastructure feature"
  2. Verify that related examples are present/printed
  3. Verify the absence of All examples were filtered out; ignoring {:full_description=>/search_service/}
  4. Verify the absence of spec/policies/project_policy_spec.rb:2457: "where" not defined. warnings.

Before

bin/rspec -f p --dry-run spec/policies/project_policy_spec.rb  -e "infrastructure feature"
....................................

Finished in 0.01965 seconds (files took 14.84 seconds to load)
36 examples, 0 failures

Randomized with seed 50402

After

bin/rspec -f p --dry-run spec/policies/project_policy_spec.rb  -e "infrastructure feature"
........................................................................

Finished in 0.02419 seconds (files took 12.36 seconds to load)
72 examples, 0 failures

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports