summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/badge/shared/metadata.rb
blob: 0cf1851425136356186812cd0d2a703ac3ce7ff3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
shared_examples 'badge metadata' do
  describe '#to_html' do
    let(:html) { Nokogiri::HTML.parse(metadata.to_html) }
    let(:a_href) { html.at('a') }

    it 'points to link' do
      expect(a_href[:href]).to eq metadata.link_url
    end

    it 'contains clickable image' do
      expect(a_href.children.first.name).to eq 'img'
    end
  end

  describe '#to_markdown' do
    subject { metadata.to_markdown }

    it { is_expected.to include metadata.image_url }
    it { is_expected.to include metadata.link_url }
  end
end