Commit cdb0caaf authored by Grzegorz Bizon's avatar Grzegorz Bizon

Extract common badge metadata test examples

parent f0ff1bfd
require 'spec_helper'
require 'lib/gitlab/badge/shared/metadata'
describe Gitlab::Badge::Build::Metadata do
let(:badge) { double(project: create(:project), ref: 'feature') }
let(:metadata) { described_class.new(badge) }
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
it_behaves_like 'badge metadata'
describe '#image_url' do
it 'returns valid url' do
......
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment