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

issuable_matchers.rb « matchers « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ab15a80bf60bdd5dfcc081a885615c98a74039cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# frozen_string_literal: true

RSpec::Matchers.define :have_header_with_correct_id_and_link do |level, text, id, parent = ".md"|
  match do |actual|
    # anchors may be invisible
    node = find("#{parent} h#{level} a#user-content-#{id}", visible: false)

    expect(node[:href]).to end_with("##{id}")

    # Work around a weird Capybara behavior where calling `parent` on a node
    # returns the whole document, not the node's actual parent element
    expect(find(:xpath, "#{node.path}/..").text).to eq(text)
  end
end