Skip to content
This repository was archived by the owner on Sep 27, 2018. It is now read-only.

Commit 8076653

Browse files
davealliemarkphelps
authored andcommitted
Support SVG status image (#14)
* Support SVG status image * Reword status test contexts and add svg status tests
1 parent 95afada commit 8076653

2 files changed

Lines changed: 35 additions & 5 deletions

File tree

lib/codeship/status.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def initialize(uuid, options = {})
1414
end
1515

1616
def status
17-
image.scan(/status_(.*).(png|gif)/).flatten.first.to_sym
17+
image.scan(/status_(.*).(png|gif|svg)/).flatten.first.to_sym
1818
end
1919

2020
private

spec/status_spec.rb

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RSpec.describe Codeship::Status do
44
context 'parsing the project status' do
5-
context 'of a project with completed build' do
5+
context 'which returns a png' do
66
Codeship::Status::STATES.each do |state|
77
it "should parse #{state}" do
88

@@ -16,7 +16,7 @@
1616
end
1717
end
1818

19-
context 'of a project with active build' do
19+
context 'which returns a gif' do
2020
Codeship::Status::STATES.each do |state|
2121
it "should parse #{state}" do
2222

@@ -29,12 +29,27 @@
2929
end
3030
end
3131
end
32+
33+
context 'which returns a svg' do
34+
Codeship::Status::STATES.each do |state|
35+
it "should parse #{state}" do
36+
37+
stub_request(:head, "https://app.codeship.com/projects/#{state}/status").
38+
with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
39+
to_return(status: 200, body: "", headers: {'Content-Disposition' => "inline; filename=\"status_#{state}.svg\""})
40+
41+
project_status = Codeship::Status.new(state)
42+
expect(project_status.status).to eq(state)
43+
end
44+
end
45+
end
3246
end
3347

3448
context 'parsing the project status on a certain branch' do
35-
context 'of a project with completed build' do
49+
context 'which returns a png' do
3650
Codeship::Status::STATES.each do |state|
3751
it "should parse #{state}" do
52+
3853
stub_request(:head, "https://app.codeship.com/projects/#{state}/status?branch=master").
3954
with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
4055
to_return(status: 200, body: "", headers: {'Content-Disposition' => "inline; filename=\"status_#{state}.png\""})
@@ -45,9 +60,10 @@
4560
end
4661
end
4762

48-
context 'of a project with active build' do
63+
context 'which returns a gif' do
4964
Codeship::Status::STATES.each do |state|
5065
it "should parse #{state}" do
66+
5167
stub_request(:head, "https://app.codeship.com/projects/#{state}/status?branch=master").
5268
with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
5369
to_return(status: 200, body: "", headers: {'Content-Disposition' => "inline; filename=\"status_#{state}.gif\""})
@@ -57,5 +73,19 @@
5773
end
5874
end
5975
end
76+
77+
context 'which returns a svg' do
78+
Codeship::Status::STATES.each do |state|
79+
it "should parse #{state}" do
80+
81+
stub_request(:head, "https://app.codeship.com/projects/#{state}/status?branch=master").
82+
with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
83+
to_return(status: 200, body: "", headers: {'Content-Disposition' => "inline; filename=\"status_#{state}.svg\""})
84+
85+
project_status = Codeship::Status.new(state, branch: 'master')
86+
expect(project_status.status).to eq(state)
87+
end
88+
end
89+
end
6090
end
6191
end

0 commit comments

Comments
 (0)