summaryrefslogtreecommitdiff
path: root/qa/spec/support/matchers/have_matcher.rb
blob: 81288b97e6f6bf95c72bc18c5054d3f474b49189 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

module Matchers
  PREDICATE_TARGETS = %w[
    element
    file_content
    assignee
    child_pipeline
    content
    design
    file
    issue
    job
    package
    pipeline
    related_issue_item
    snippet_description
    tag
  ].each do |predicate|
    RSpec::Matchers.define "have_#{predicate}" do |*args, **kwargs|
      match do |page_object|
        page_object.public_send("has_#{predicate}?", *args, **kwargs) # rubocop:disable GitlabSecurity/PublicSend
      end

      match_when_negated do |page_object|
        page_object.public_send("has_no_#{predicate}?", *args, **kwargs) # rubocop:disable GitlabSecurity/PublicSend
      end
    end
  end
end