debian-mirror-gitlab/spec/support/matchers/issuable_matchers.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

14 lines
476 B
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2019-07-07 11:18:12 +05:30
RSpec::Matchers.define :have_header_with_correct_id_and_link do |level, text, id, parent = ".md"|
2018-05-09 12:01:36 +05:30
match do |actual|
node = find("#{parent} h#{level} a#user-content-#{id}")
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