Skip to content

Error if spec stubs flag that does not exist

What does this MR do and why?

This MR changes #stub_feature_flags to fail a test if it stubs a feature flag that does not exist.

It fixes all places where we were stubbing non-existent feature flags.

Specs that use mock feature flags can still call the existing #stub_feature_flag_definition method first to continue using the mock flag.

An example of the error is https://gitlab.com/gitlab-org/gitlab/-/jobs/3171672000:

4) ConfirmationsController#create when reCAPTCHA is enabled when the reCAPTCHA is not solved sets gon variables
    Failure/Error:
      RSpec::Expectations.fail_with "`#stub_feature_flags` called with `#{feature_name}` flag that does not exist. " \
                          'Has the flag been removed? ' \
                          'Mock feature flag definitions can be stubbed first with `#stub_feature_flag_definition`.'
      `#stub_feature_flags` called with `identity_verification` flag that does not exist. Has the flag been removed? Mock feature flag definitions can be stubbed first with `#stub_feature_flag_definition`.

#375656 (closed)

MR acceptance checklist

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

Related to #375656 (closed)

Edited by Luke Duncalfe

Merge request reports