diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-08-11 11:16:14 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-08-15 14:39:46 +0200 |
commit | f3de46e6b0d4cc61e00c884753a8c9eec66f66c4 (patch) | |
tree | c94491b355df3a161a7a805f2d7794ece07384e6 /spec/lib/gitlab/badge/build/metadata_spec.rb | |
parent | 9f0b46c05aef9d0352bfaa5e42e34143227de8ff (diff) | |
download | gitlab-ce-f3de46e6b0d4cc61e00c884753a8c9eec66f66c4.tar.gz |
Refactor badge template and metadata classes
Diffstat (limited to 'spec/lib/gitlab/badge/build/metadata_spec.rb')
-rw-r--r-- | spec/lib/gitlab/badge/build/metadata_spec.rb | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/spec/lib/gitlab/badge/build/metadata_spec.rb b/spec/lib/gitlab/badge/build/metadata_spec.rb index ad5388215c2..4044a82d16c 100644 --- a/spec/lib/gitlab/badge/build/metadata_spec.rb +++ b/spec/lib/gitlab/badge/build/metadata_spec.rb @@ -1,16 +1,15 @@ require 'spec_helper' describe Gitlab::Badge::Build::Metadata do - let(:project) { create(:project) } - let(:branch) { 'master' } - let(:badge) { described_class.new(project, branch) } + let(:badge) { double(project: create(:project), ref: 'feature') } + let(:metadata) { described_class.new(badge) } describe '#to_html' do - let(:html) { Nokogiri::HTML.parse(badge.to_html) } + 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 badge.link_url + expect(a_href[:href]).to eq metadata.link_url end it 'contains clickable image' do @@ -19,19 +18,21 @@ describe Gitlab::Badge::Build::Metadata do end describe '#to_markdown' do - subject { badge.to_markdown } + subject { metadata.to_markdown } - it { is_expected.to include badge.image_url } - it { is_expected.to include badge.link_url } + it { is_expected.to include metadata.image_url } + it { is_expected.to include metadata.link_url } end describe '#image_url' do - subject { badge.image_url } - it { is_expected.to include "badges/#{branch}/build.svg" } + it 'returns valid url' do + expect(metadata.image_url).to include 'badges/feature/build.svg' + end end describe '#link_url' do - subject { badge.link_url } - it { is_expected.to include "commits/#{branch}" } + it 'returns valid link' do + expect(metadata.link_url).to include 'commits/feature' + end end end |