Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/matchers/pushed_licensed_features_matcher.rb')
-rw-r--r--spec/support/matchers/pushed_licensed_features_matcher.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/support/matchers/pushed_licensed_features_matcher.rb b/spec/support/matchers/pushed_licensed_features_matcher.rb
new file mode 100644
index 00000000000..b02863983bc
--- /dev/null
+++ b/spec/support/matchers/pushed_licensed_features_matcher.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+RSpec::Matchers.define :have_pushed_licensed_features do |expected|
+ def to_js(key, value)
+ "\"#{key}\":#{value}"
+ end
+
+ def html(actual)
+ actual.try(:html) || actual
+ end
+
+ match do |actual|
+ expected.all? do |licensed_feature_name, enabled|
+ html(actual).include?(to_js(licensed_feature_name, enabled))
+ end
+ end
+
+ failure_message do |actual|
+ missing = expected.select do |licensed_feature_name, enabled|
+ html(actual).exclude?(to_js(licensed_feature_name, enabled))
+ end
+
+ missing_licensed_features = missing.map do |licensed_feature_name, enabled|
+ to_js(licensed_feature_name, enabled)
+ end.join("\n")
+
+ "The following licensed feature(s) cannot be found in the frontend HTML source: #{missing_licensed_features}"
+ end
+end