summaryrefslogtreecommitdiff
path: root/qa/qa/support/formatters/feature_flag_formatter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/support/formatters/feature_flag_formatter.rb')
-rw-r--r--qa/qa/support/formatters/feature_flag_formatter.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/qa/qa/support/formatters/feature_flag_formatter.rb b/qa/qa/support/formatters/feature_flag_formatter.rb
new file mode 100644
index 00000000000..94c039586f9
--- /dev/null
+++ b/qa/qa/support/formatters/feature_flag_formatter.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+module QA
+ module Support
+ module Formatters
+ class FeatureFlagFormatter < ::RSpec::Core::Formatters::BaseFormatter
+ include Specs::Helpers::FeatureFlag
+
+ ::RSpec::Core::Formatters.register(
+ self,
+ :example_group_started,
+ :example_started
+ )
+
+ # Starts example group
+ # @param [RSpec::Core::Notifications::GroupNotification] example_group_notification
+ # @return [void]
+ def example_group_started(example_group_notification)
+ group = example_group_notification.group
+
+ skip_or_run_feature_flag_tests_or_contexts(group)
+ end
+
+ # Starts example
+ # @param [RSpec::Core::Notifications::ExampleNotification] example_notification
+ # @return [void]
+ def example_started(example_notification)
+ example = example_notification.example
+
+ # if skip propagated from example_group, do not reset skip metadata
+ skip_or_run_feature_flag_tests_or_contexts(example) unless example.metadata[:skip]
+ end
+ end
+ end
+ end
+end