bamboo-client 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,6 +37,10 @@ module Bamboo
37
37
  get("project/").auto_expand Project, @http
38
38
  end
39
39
 
40
+ def project_for(key)
41
+ Project.new get("project/#{URI.escape key}").data, @http
42
+ end
43
+
40
44
  def results
41
45
  get("result/").auto_expand Result, @http
42
46
  end
@@ -82,7 +86,12 @@ module Bamboo
82
86
  end
83
87
 
84
88
  def queue
85
- @http.post File.join(SERVICE, "queue/#{key}"), {}, @http.cookies
89
+ @http.post File.join(SERVICE, "queue/#{URI.escape key}"), {}, @http.cookies
90
+ end
91
+
92
+ def results
93
+ doc = @http.get File.join(SERVICE, "result/#{URI.escape key}"), {}, @http.cookies
94
+ doc.auto_expand Result, @http
86
95
  end
87
96
  end # Plan
88
97
 
@@ -103,6 +112,16 @@ module Bamboo
103
112
  def url
104
113
  @data.fetch("link")['href']
105
114
  end
115
+
116
+ def plans
117
+ @plans ||= (
118
+ unless @data['plans'] && @data['plans']['plan']
119
+ @data = @http.get(URI.parse(url), {:expand => 'plans'}, @http.cookies).data
120
+ end
121
+
122
+ @data.fetch('plans').fetch('plan').map { |e| Plan.new(e, @http) }
123
+ )
124
+ end
106
125
  end # Project
107
126
 
108
127
  class Result
@@ -146,6 +165,10 @@ module Bamboo
146
165
  Time.parse details.fetch('buildStartedTime')
147
166
  end
148
167
 
168
+ def completed_time
169
+ Time.parse details.fetch('buildCompletedTime')
170
+ end
171
+
149
172
  def number
150
173
  @data['number']
151
174
  end
@@ -1,5 +1,5 @@
1
1
  module Bamboo
2
2
  module Client
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -66,6 +66,16 @@ module Bamboo
66
66
  client.plan_for("SOME-KEY").should be_kind_of(Rest::Plan)
67
67
  end
68
68
 
69
+
70
+ it "should be able to fetch a project for a specific key" do
71
+ document.should_receive(:data).and_return('some' => 'data')
72
+
73
+ http.should_receive(:get).with("/rest/api/latest/project/SOME-KEY", nil, nil).
74
+ and_return(document)
75
+
76
+ client.project_for("SOME-KEY").should be_kind_of(Rest::Project)
77
+ end
78
+
69
79
  describe Rest::Plan do
70
80
  let(:data) { json_fixture("plan") }
71
81
  let(:plan) { Rest::Plan.new data, http }
@@ -95,23 +105,40 @@ module Bamboo
95
105
  http.should_receive(:post).with("/rest/api/latest/queue/S2RB-REMWIN", {}, {"some" => "cookie"})
96
106
  plan.queue
97
107
  end
108
+
109
+ it 'can fetch results' do
110
+ document.should_receive(:auto_expand).with(Rest::Result, http)
111
+ http.should_receive(:cookies).and_return("some" => "cookie")
112
+ http.should_receive(:get).with("/rest/api/latest/result/S2RB-REMWIN", {}, {"some" => "cookie"}).and_return(document)
113
+
114
+ plan.results
115
+ end
98
116
  end # Plan
99
117
 
100
118
  describe Rest::Project do
101
119
  let(:data) { json_fixture("project") }
102
- let(:plan) { Rest::Project.new data, http }
120
+ let(:project) { Rest::Project.new data, http }
103
121
 
104
122
  it "has a name" do
105
- plan.name.should == "Selenium 2 Java"
123
+ project.name.should == "Selenium 2 Java"
106
124
  end
107
125
 
108
126
  it "has a key" do
109
- plan.key.should == "S2J"
127
+ project.key.should == "S2J"
110
128
  end
111
129
 
112
130
  it "has a URL" do
113
- plan.url.should == "http://xserve.openqa.org:8085/rest/api/latest/project/S2J"
131
+ project.url.should == "http://xserve.openqa.org:8085/rest/api/latest/project/S2J"
132
+ end
133
+
134
+ it 'can fetch plans' do
135
+ document.should_receive(:data).and_return('plans' => {'plan' => []})
136
+ http.should_receive(:cookies).and_return("some" => "cookie")
137
+ http.should_receive(:get).with(URI.parse(project.url), {:expand => 'plans'}, {"some" => "cookie"}).and_return(document)
138
+
139
+ project.plans.should == []
114
140
  end
141
+
115
142
  end
116
143
 
117
144
  describe Rest::Result do
@@ -167,6 +194,11 @@ module Bamboo
167
194
  it "has a start time" do
168
195
  result.start_time.should == Time.parse("2011-01-20T10:08:41.000+01:00")
169
196
  end
197
+
198
+ it "has a completed time" do
199
+ result.completed_time.should == Time.parse("2011-01-20T10:09:32.000+01:00")
200
+ end
201
+
170
202
  it "has a relative date" do
171
203
  result.relative_date.should == "4 weeks ago"
172
204
  result.relative_time.should == "4 weeks ago"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bamboo-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-09-06 00:00:00.000000000 Z
13
+ date: 2012-09-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec