diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 19:00:14 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 19:00:14 +0000 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/support/matchers/exceed_query_limit.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) | |
download | gitlab-ce-05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2.tar.gz |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/support/matchers/exceed_query_limit.rb')
-rw-r--r-- | spec/support/matchers/exceed_query_limit.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/support/matchers/exceed_query_limit.rb b/spec/support/matchers/exceed_query_limit.rb index a5a017828b3..4b08c13945c 100644 --- a/spec/support/matchers/exceed_query_limit.rb +++ b/spec/support/matchers/exceed_query_limit.rb @@ -380,3 +380,32 @@ RSpec::Matchers.define :exceed_query_limit do |expected| failure_message end end + +RSpec::Matchers.define :match_query_count do |expected| + supports_block_expectations + + include ExceedQueryLimitHelpers + + def verify_count(&block) + @subject_block = block + actual_count == maximum + end + + def failure_message + threshold_message = threshold > 0 ? " (+#{threshold})" : '' + counts = "#{expected_count}#{threshold_message}" + "Expected exactly #{counts} queries, got #{actual_count}:\n\n#{log_message}" + end + + def skip_cached + false + end + + match do |block| + verify_count(&block) + end + + failure_message_when_negated do |actual| + failure_message + end +end |