update_status 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
4
  gem "multi_json", ">= 1.0.3"
5
- gem "rest-client", ">= 1.6.7"
5
+ gem "rest-client", ">= 1.6.2"
6
6
 
7
7
  # Add dependencies to develop your gem here.
8
8
  # Include everything needed to run rake, tests, features, etc.
@@ -35,5 +35,5 @@ DEPENDENCIES
35
35
  multi_json (>= 1.0.3)
36
36
  rcov
37
37
  rdoc (~> 3.12)
38
- rest-client (>= 1.6.7)
38
+ rest-client (>= 1.6.2)
39
39
  rspec (>= 2.11.0)
@@ -15,7 +15,7 @@ eg
15
15
 
16
16
  :repo => "status",
17
17
 
18
- :ci_url => "http://jenkins-ci.org/",
18
+ :ci_url => "http://jenkins-ci.org",
19
19
 
20
20
  :token => "your github token http://developer.github.com/v3/oauth/",
21
21
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -30,7 +30,11 @@ module Status
30
30
  end
31
31
 
32
32
  def state
33
- (Jenkins.pass? && @qa_status == "pass") ? states[3] : states[2]
33
+ (Jenkins.pass? && @qa_status == "pass") ? states[3] : git_state
34
+ end
35
+
36
+ def git_state
37
+ states.include?(Jenkins.state) ? states[states.index(Jenkins.state)] : "error"
34
38
  end
35
39
 
36
40
  def states
@@ -5,24 +5,28 @@ module Status
5
5
  extend self
6
6
 
7
7
  def state
8
- return "Green" if pass?
9
- "building"
8
+ return "success" if pass?
9
+ @status
10
10
  end
11
11
 
12
12
  def pass?
13
13
  @status ||= get_ci_status
14
- return false if @status == "building" || @status == "not found"
14
+ return false unless @status == "success"
15
15
  true
16
16
  end
17
17
 
18
18
  def get_ci_status
19
19
  response = Request.new(:ci).get(path)
20
- return response if response == "not found"
21
- response["building"] == true ? "building" : response["result"]
20
+ return "pending" if response == "not found"
21
+ return "pending" if response["building"] == true
22
+ return "failure" unless response["result"].downcase == "success"
23
+ "success"
22
24
  end
23
25
 
24
26
  def path
25
27
  "/job/#{Status.branch}/lastBuild/api/json"
26
28
  end
27
29
  end
28
- end
30
+ end
31
+
32
+
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Status::Github::Statuses do
4
4
  before do
5
- stub_const("Jenkins", stub)
5
+ stub_const("Status::Jenkins", stub)
6
6
  end
7
7
 
8
8
  subject { Status::Github::Statuses }
@@ -12,20 +12,25 @@ describe Status::Github::Statuses do
12
12
  end
13
13
 
14
14
  it "has a payload description of the ci state and qa status" do
15
- Jenkins.stub(:state => "Green")
16
- subject.new.send(:description).should == "Build status: Green, QA pending"
15
+ Status::Jenkins.stub(:state => "success")
16
+ subject.new.send(:description).should == "Build status: success, QA pending"
17
17
  end
18
18
 
19
19
  it "has a payload pending state when ci is passing but qa hasn't passed" do
20
- Jenkins.stub(:pass? => true)
20
+ Status::Jenkins.stub(:pass? => true, :state => "pending")
21
21
  subject.new.send(:state).should == "pending"
22
22
  end
23
23
 
24
24
  it "has a payload success state when ci is passing and qa has passed" do
25
- Jenkins.stub(:pass? => true)
25
+ Status::Jenkins.stub(:pass? => true, :state => "success")
26
26
  subject.new("pass").send(:state).should == "success"
27
27
  end
28
28
 
29
+ it "has a payload error state when ci has an error" do
30
+ Status::Jenkins.stub(:pass? => false, :state => "nothing")
31
+ subject.new("pass").send(:state).should == "error"
32
+ end
33
+
29
34
  it "goes to the correct status api" do
30
35
  Status.stub(:owner => "owner", :repo => "status", :sha => "99efgd", :token => "123")
31
36
  subject.new.send(:status_api).should == "/repos/owner/status/statuses/99efgd?access_token=123"
@@ -15,19 +15,24 @@ describe Status::Jenkins do
15
15
  end
16
16
 
17
17
  context "#state" do
18
- it "is Green when ci result is success" do
18
+ it "is success when ci result is success" do
19
19
  Status::Request.stub(:new => stub(:get => {"building" => false, "result" => "success"}))
20
- subject.state.should == "Green"
20
+ subject.state.should == "success"
21
21
  end
22
22
 
23
23
  it "is Building when ci result is building" do
24
24
  Status::Request.stub(:new => stub(:get => {"building" => true, "result" => "success"}))
25
- subject.state.should == "building"
25
+ subject.state.should == "pending"
26
+ end
27
+
28
+ it "is Building when ci result is in any other state" do
29
+ Status::Request.stub(:new => stub(:get => {"building" => true, "result" => "failed"}))
30
+ subject.state.should == "pending"
26
31
  end
27
32
 
28
33
  it "is Building when ci result is not found" do
29
34
  Status::Request.stub(:new => stub(:get => "not found"))
30
- subject.state.should == "building"
35
+ subject.state.should == "pending"
31
36
  end
32
37
  end
33
38
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "update_status"
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Douglas Roper"]
12
- s.date = "2012-10-26"
12
+ s.date = "2012-12-11"
13
13
  s.description = "Updates pull requests on github, with latest build from Jenkins and QA status"
14
14
  s.email = "douglasroper@notonthehighstreet.com"
15
15
  s.executables = ["status"]
@@ -51,7 +51,7 @@ Gem::Specification.new do |s|
51
51
 
52
52
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
53
  s.add_runtime_dependency(%q<multi_json>, [">= 1.0.3"])
54
- s.add_runtime_dependency(%q<rest-client>, [">= 1.6.7"])
54
+ s.add_runtime_dependency(%q<rest-client>, [">= 1.6.2"])
55
55
  s.add_development_dependency(%q<rspec>, [">= 2.11.0"])
56
56
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
57
57
  s.add_development_dependency(%q<bundler>, [">= 1.2.1"])
@@ -59,7 +59,7 @@ Gem::Specification.new do |s|
59
59
  s.add_development_dependency(%q<rcov>, [">= 0"])
60
60
  else
61
61
  s.add_dependency(%q<multi_json>, [">= 1.0.3"])
62
- s.add_dependency(%q<rest-client>, [">= 1.6.7"])
62
+ s.add_dependency(%q<rest-client>, [">= 1.6.2"])
63
63
  s.add_dependency(%q<rspec>, [">= 2.11.0"])
64
64
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
65
65
  s.add_dependency(%q<bundler>, [">= 1.2.1"])
@@ -68,7 +68,7 @@ Gem::Specification.new do |s|
68
68
  end
69
69
  else
70
70
  s.add_dependency(%q<multi_json>, [">= 1.0.3"])
71
- s.add_dependency(%q<rest-client>, [">= 1.6.7"])
71
+ s.add_dependency(%q<rest-client>, [">= 1.6.2"])
72
72
  s.add_dependency(%q<rspec>, [">= 2.11.0"])
73
73
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
74
74
  s.add_dependency(%q<bundler>, [">= 1.2.1"])
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: update_status
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Douglas Roper
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-10-26 00:00:00 Z
18
+ date: 2012-12-11 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: multi_json
@@ -40,12 +40,12 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- hash: 1
43
+ hash: 11
44
44
  segments:
45
45
  - 1
46
46
  - 6
47
- - 7
48
- version: 1.6.7
47
+ - 2
48
+ version: 1.6.2
49
49
  type: :runtime
50
50
  requirement: *id002
51
51
  prerelease: false