diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-23 13:24:18 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-29 10:01:19 +0300 |
commit | 4cd1b9f4d82efe3ffe810dabf6929a749c36c1bf (patch) | |
tree | 907813709b26f17c94b8a8e9234bea07e0935e4d /spec/lib/gitlab | |
parent | 63c8a05bf7f18ac4093ece1f08b4b5fd8dba5fac (diff) |
Refactor builds badge, encapsulate inside a class
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r-- | spec/lib/gitlab/badge/build_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/lib/gitlab/badge/build_spec.rb b/spec/lib/gitlab/badge/build_spec.rb new file mode 100644 index 00000000000..e835de5e07d --- /dev/null +++ b/spec/lib/gitlab/badge/build_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe Gitlab::Badge::Build do + let(:project) { create(:project) } + let(:sha) { project.commit.sha } + let(:ci_commit) { create(:ci_commit, project: project, sha: sha) } + let(:badge) { described_class.new(project, 'master') } + + let!(:build) { create(:ci_build, commit: ci_commit) } + + describe '#type' do + subject { badge.type } + it { is_expected.to eq 'image/svg+xml' } + end + + context 'build success' do + before { build.success! } + + describe '#to_s' do + subject { badge.to_s } + it { is_expected.to eq 'build-success' } + end + + describe '#data' do + let(:data) { badge.data } + let(:xml) { Nokogiri::XML.parse(data) } + + it 'contains infromation about success' do + expect(xml.at(%Q{text:contains("success")})).to be_truthy + end + end + end +end |