|
3 | 3 |
|
4 | 4 | module PactBroker
|
5 | 5 | module Badges
|
6 |
| - module Service |
7 |
| - describe "#pact_verification_badge" do |
8 |
| - let(:pacticipant_name) { "Foo-Bar_Thing Service" } |
9 |
| - let(:pact) { double("pact", consumer_name: "Foo-Bar", provider_name: "Thing_Blah") } |
10 |
| - let(:label) { nil } |
11 |
| - let(:initials) { false } |
12 |
| - let(:pseudo_branch_verification_status) { :success } |
13 |
| - let(:logger) { double('logger').as_null_object } |
14 |
| - let(:expected_url) { "https://img.shields.io/badge/#{expected_left_text}-#{expected_right_text}-#{expected_color}.svg" } |
15 |
| - let(:expected_color) { "brightgreen" } |
16 |
| - let(:expected_right_text) { "verified" } |
17 |
| - let(:expected_left_text) { "foo--bar%2fthing__blah%20pact" } |
18 |
| - let(:response_status) { 200 } |
19 |
| - let!(:http_request) do |
20 |
| - stub_request(:get, expected_url).to_return(:status => response_status, :body => "svg") |
21 |
| - end |
| 6 | + describe Service do |
| 7 | + let(:pacticipant_name) { "Foo-Bar_Thing Service" } |
| 8 | + let(:pact) { double("pact", consumer_name: "Foo-Bar", provider_name: "Thing_Blah") } |
| 9 | + let(:label) { nil } |
| 10 | + let(:initials) { false } |
| 11 | + let(:pseudo_branch_verification_status) { :success } |
| 12 | + let(:logger) { double('logger').as_null_object } |
| 13 | + let(:expected_url) { "https://img.shields.io/badge/#{expected_left_text}-#{expected_right_text}-#{expected_color}.svg" } |
| 14 | + let(:expected_color) { "brightgreen" } |
| 15 | + let(:expected_right_text) { "verified" } |
| 16 | + let(:expected_left_text) { "foo--bar%2fthing__blah%20pact" } |
| 17 | + let(:response_status) { 200 } |
| 18 | + let!(:http_request) do |
| 19 | + stub_request(:get, expected_url).to_return(:status => response_status, :body => "svg") |
| 20 | + end |
| 21 | + |
| 22 | + subject { PactBroker::Badges::Service.pact_verification_badge pact, label, initials, pseudo_branch_verification_status } |
22 | 23 |
|
23 |
| - subject { PactBroker::Badges::Service.pact_verification_badge pact, label, initials, pseudo_branch_verification_status } |
| 24 | + let(:pact_verification_badge_url) { PactBroker::Badges::Service.pact_verification_badge_url(pact, label, initials, pseudo_branch_verification_status) } |
24 | 25 |
|
25 |
| - let(:pact_verification_badge_url) { PactBroker::Badges::Service.pact_verification_badge_url(pact, label, initials, pseudo_branch_verification_status) } |
| 26 | + before do |
| 27 | + Service.clear_cache |
| 28 | + allow(Service).to receive(:logger).and_return(logger) |
| 29 | + end |
26 | 30 |
|
27 |
| - before do |
28 |
| - Service.clear_cache |
29 |
| - allow(Service).to receive(:logger).and_return(logger) |
| 31 | + describe "pact_verification_badge_url" do |
| 32 | + context "with the pact is nil" do |
| 33 | + let(:pact) { nil } |
| 34 | + let(:expected_left_text) { "pact%20not%20found" } |
| 35 | + let(:expected_right_text) { "unknown" } |
| 36 | + let(:expected_color) { "lightgrey" } |
| 37 | + let(:pseudo_branch_verification_status) { :never } |
| 38 | + |
| 39 | + it "returns a link to a 'pact not found' badge" do |
| 40 | + expect(pact_verification_badge_url).to eq URI(expected_url) |
| 41 | + end |
30 | 42 | end
|
| 43 | + end |
| 44 | + |
| 45 | + describe "#pact_verification_badge" do |
31 | 46 |
|
32 | 47 | it "returns the svg file" do
|
33 | 48 | expect(subject).to eq "svg"
|
|
0 commit comments