From 6f3bee708ccfef28e5de0faaee12d04c54e7f91a Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 17 Nov 2023 11:39:10 +1100 Subject: [PATCH] Check feature name in specs There was one case where a typo meant that the desired feature wasn't active and tests were not testing the right code path. Using this new syntax should prevent that. * https://github.com/openfoodfoundation/openfoodnetwork/pull/11705 --- spec/base_spec_helper.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/base_spec_helper.rb b/spec/base_spec_helper.rb index 1e2ea1defc..924b981ae7 100644 --- a/spec/base_spec_helper.rb +++ b/spec/base_spec_helper.rb @@ -92,7 +92,13 @@ RSpec.configure do |config| end config.before(:each, :feature) do |example| - Flipper.enable(example.metadata[:feature]) + feature = example.metadata[:feature].to_s + + unless OpenFoodNetwork::FeatureToggle::CURRENT_FEATURES.key?(feature) + raise "Unkown feature: #{feature}" + end + + Flipper.enable(feature) end # Enable caching in any specs tagged with `caching: true`.