blob: b49d4da8cda836761db23eb41ef2dc04c43e9eaf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# frozen_string_literal: true
RSpec::Matchers.define :have_pushed_frontend_feature_flags do |expected|
def to_js(key, value)
"\"#{key}\":#{value}"
end
match do |actual|
expected.all? do |feature_flag_name, enabled|
page.html.include?(to_js(feature_flag_name, enabled))
end
end
failure_message do |actual|
missing = expected.select do |feature_flag_name, enabled|
!page.html.include?(to_js(feature_flag_name, enabled))
end
formatted_missing_flags = missing.map { |feature_flag_name, enabled| to_js(feature_flag_name, enabled) }.join("\n")
"The following feature flag(s) cannot be found in the frontend HTML source: #{formatted_missing_flags}"
end
end
|