bamboo-client 0.0.8 → 0.0.9
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.
- data/features/rest.feature +6 -7
- data/features/step_definitions/rest_steps.rb +10 -5
- data/lib/bamboo-client/http/xml.rb +9 -1
- data/lib/bamboo-client/rest.rb +4 -4
- data/lib/bamboo-client/version.rb +1 -1
- data/spec/bamboo-client/rest_spec.rb +15 -15
- data/spec/fixtures/{build.json → result.json} +0 -0
- data/spec/fixtures/{build_with_changes.json → result_with_changes.json} +0 -0
- metadata +7 -9
- data/features/step_definitions/rest_steps.rb~ +0 -38
data/features/rest.feature
CHANGED
@@ -16,14 +16,13 @@ Feature: Bamboo REST client
|
|
16
16
|
Then I should get a list of projects
|
17
17
|
And all projects should have a key
|
18
18
|
|
19
|
-
Scenario: Fetch all
|
20
|
-
When I fetch all
|
21
|
-
Then I should get a list of
|
22
|
-
And all
|
19
|
+
Scenario: Fetch all results
|
20
|
+
When I fetch all results
|
21
|
+
Then I should get a list of results
|
22
|
+
And all results should have a state
|
23
23
|
|
24
24
|
Scenario: Authenticated API
|
25
25
|
When I log in
|
26
26
|
Then I should get a session ID
|
27
|
-
When I fetch all
|
28
|
-
Then
|
29
|
-
And all plans should have a key
|
27
|
+
When I fetch all results
|
28
|
+
Then all results should have a state
|
@@ -24,12 +24,17 @@ Then /^all projects should have a key$/ do
|
|
24
24
|
@projects.each { |e| e.key.should be_kind_of(String) }
|
25
25
|
end
|
26
26
|
|
27
|
-
When /^I fetch all
|
28
|
-
@
|
27
|
+
When /^I fetch all results$/ do
|
28
|
+
@results = client.results
|
29
29
|
end
|
30
30
|
|
31
|
-
Then /^
|
32
|
-
@
|
31
|
+
Then /^I should get a list of results$/ do
|
32
|
+
@results.should_not be_empty
|
33
|
+
@results.each { |result| result.should be_kind_of(Bamboo::Client::Rest::Result) }
|
34
|
+
end
|
35
|
+
|
36
|
+
Then /^all results should have a state$/ do
|
37
|
+
@results.each { |r| [:successful, :failed].should include(r.state) }
|
33
38
|
end
|
34
39
|
|
35
40
|
When /^I log in$/ do
|
@@ -38,4 +43,4 @@ end
|
|
38
43
|
|
39
44
|
Then /^I should get a session ID$/ do
|
40
45
|
client.cookies.has_key? :JSESSIONID
|
41
|
-
end
|
46
|
+
end
|
@@ -41,7 +41,15 @@ module Bamboo
|
|
41
41
|
end # Doc
|
42
42
|
|
43
43
|
def post(path, data = {})
|
44
|
-
|
44
|
+
resp = RestClient.post(uri_for(path), data) do |response, request, result, &block|
|
45
|
+
if [301, 302, 307].include? response.code
|
46
|
+
response.follow_redirection(request, result, &block)
|
47
|
+
else
|
48
|
+
response.return!(request, result, &block)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
Doc.from resp
|
45
53
|
end
|
46
54
|
|
47
55
|
end # Xml
|
data/lib/bamboo-client/rest.rb
CHANGED
@@ -37,8 +37,8 @@ module Bamboo
|
|
37
37
|
get("project/").auto_expand Project, @http
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
41
|
-
get("
|
40
|
+
def results
|
41
|
+
get("result/").auto_expand Result, @http
|
42
42
|
end
|
43
43
|
|
44
44
|
private
|
@@ -97,7 +97,7 @@ module Bamboo
|
|
97
97
|
end
|
98
98
|
end # Project
|
99
99
|
|
100
|
-
class
|
100
|
+
class Result
|
101
101
|
def initialize(data, http)
|
102
102
|
@data = data
|
103
103
|
@http = http
|
@@ -145,7 +145,7 @@ module Bamboo
|
|
145
145
|
def fetch_details(expand)
|
146
146
|
@http.get(uri, :expand => expand)
|
147
147
|
end
|
148
|
-
end #
|
148
|
+
end # Result
|
149
149
|
|
150
150
|
class Change
|
151
151
|
def initialize(data, http)
|
@@ -39,13 +39,13 @@ module Bamboo
|
|
39
39
|
client.projects.should == %w[foo bar]
|
40
40
|
end
|
41
41
|
|
42
|
-
it "should be able to fetch
|
43
|
-
document.should_receive(:auto_expand).with(Rest::
|
42
|
+
it "should be able to fetch results" do
|
43
|
+
document.should_receive(:auto_expand).with(Rest::Result, http).and_return %w[foo bar]
|
44
44
|
|
45
|
-
http.should_receive(:get).with("/rest/api/latest/
|
45
|
+
http.should_receive(:get).with("/rest/api/latest/result/", nil, nil).
|
46
46
|
and_return(document)
|
47
47
|
|
48
|
-
client.
|
48
|
+
client.results.should == %w[foo bar]
|
49
49
|
end
|
50
50
|
|
51
51
|
describe Rest::Plan do
|
@@ -95,38 +95,38 @@ module Bamboo
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
describe Rest::
|
99
|
-
let(:data) { json_fixture("
|
100
|
-
let(:
|
98
|
+
describe Rest::Result do
|
99
|
+
let(:data) { json_fixture("result") }
|
100
|
+
let(:result) { Rest::Result.new data, http }
|
101
101
|
|
102
102
|
it "has a key" do
|
103
|
-
|
103
|
+
result.key.should == "IAD-DEFAULT-5388"
|
104
104
|
end
|
105
105
|
|
106
106
|
it "has a state" do
|
107
|
-
|
107
|
+
result.state.should == :successful
|
108
108
|
end
|
109
109
|
|
110
110
|
it "has an id" do
|
111
|
-
|
111
|
+
result.id.should == 8487295
|
112
112
|
end
|
113
113
|
|
114
114
|
it "has a number" do
|
115
|
-
|
115
|
+
result.number.should == 5388
|
116
116
|
end
|
117
117
|
|
118
118
|
it "has a life cycle state" do
|
119
|
-
|
119
|
+
result.life_cycle_state.should == :finished
|
120
120
|
end
|
121
121
|
|
122
122
|
it "has a URL" do
|
123
|
-
|
123
|
+
result.url.should == "http://localhost:8085/rest/api/latest/result/IAD-DEFAULT-5388"
|
124
124
|
end
|
125
125
|
|
126
126
|
it "has a list of changes" do
|
127
127
|
# TODO: arg expectation
|
128
|
-
http.should_receive(:get).and_return Http::Json::Doc.new(json_fixture("
|
129
|
-
|
128
|
+
http.should_receive(:get).and_return Http::Json::Doc.new(json_fixture("result_with_changes"))
|
129
|
+
result.changes.first.should be_kind_of(Rest::Change)
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bamboo-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 9
|
10
|
+
version: 0.0.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jari Bakken
|
@@ -144,7 +144,6 @@ files:
|
|
144
144
|
- features/rest.feature
|
145
145
|
- features/step_definitions/remote_steps.rb
|
146
146
|
- features/step_definitions/rest_steps.rb
|
147
|
-
- features/step_definitions/rest_steps.rb~
|
148
147
|
- features/support/env.rb
|
149
148
|
- lib/bamboo-client.rb
|
150
149
|
- lib/bamboo-client/abstract.rb
|
@@ -160,13 +159,13 @@ files:
|
|
160
159
|
- spec/bamboo-client/http/xml_spec.rb
|
161
160
|
- spec/bamboo-client/remote_spec.rb
|
162
161
|
- spec/bamboo-client/rest_spec.rb
|
163
|
-
- spec/fixtures/build.json
|
164
162
|
- spec/fixtures/build.xml
|
165
163
|
- spec/fixtures/build_result.xml
|
166
|
-
- spec/fixtures/build_with_changes.json
|
167
164
|
- spec/fixtures/change.json
|
168
165
|
- spec/fixtures/plan.json
|
169
166
|
- spec/fixtures/project.json
|
167
|
+
- spec/fixtures/result.json
|
168
|
+
- spec/fixtures/result_with_changes.json
|
170
169
|
- spec/spec_helper.rb
|
171
170
|
homepage: ""
|
172
171
|
licenses: []
|
@@ -206,19 +205,18 @@ test_files:
|
|
206
205
|
- features/rest.feature
|
207
206
|
- features/step_definitions/remote_steps.rb
|
208
207
|
- features/step_definitions/rest_steps.rb
|
209
|
-
- features/step_definitions/rest_steps.rb~
|
210
208
|
- features/support/env.rb
|
211
209
|
- spec/bamboo-client/client_spec.rb
|
212
210
|
- spec/bamboo-client/http/json_spec.rb
|
213
211
|
- spec/bamboo-client/http/xml_spec.rb
|
214
212
|
- spec/bamboo-client/remote_spec.rb
|
215
213
|
- spec/bamboo-client/rest_spec.rb
|
216
|
-
- spec/fixtures/build.json
|
217
214
|
- spec/fixtures/build.xml
|
218
215
|
- spec/fixtures/build_result.xml
|
219
|
-
- spec/fixtures/build_with_changes.json
|
220
216
|
- spec/fixtures/change.json
|
221
217
|
- spec/fixtures/plan.json
|
222
218
|
- spec/fixtures/project.json
|
219
|
+
- spec/fixtures/result.json
|
220
|
+
- spec/fixtures/result_with_changes.json
|
223
221
|
- spec/spec_helper.rb
|
224
222
|
has_rdoc:
|
@@ -1,38 +0,0 @@
|
|
1
|
-
When /^I fetch all the plans$/ do
|
2
|
-
@plans = client.plans
|
3
|
-
end
|
4
|
-
|
5
|
-
Then /^I should get a list of plans$/ do
|
6
|
-
@plans.should_not be_empty
|
7
|
-
@plans.each { |plan| plan.should be_kind_of(Bamboo::Client::Rest::Plan) }
|
8
|
-
end
|
9
|
-
|
10
|
-
When /^I fetch all projects$/ do
|
11
|
-
@projects = client.projects
|
12
|
-
end
|
13
|
-
|
14
|
-
Then /^I should get a list of projects$/ do
|
15
|
-
@projects.should_not be_empty
|
16
|
-
@projects.each { |pro| pro.should be_kind_of(Bamboo::Client::Rest::Project) }
|
17
|
-
end
|
18
|
-
|
19
|
-
Then /^all plans should have a key$/ do
|
20
|
-
@plans.each { |e| e.key.should be_kind_of(String) }
|
21
|
-
end
|
22
|
-
|
23
|
-
Then /^all projects should have a key$/ do
|
24
|
-
@projects.each { |e| e.key.should be_kind_of(String) }
|
25
|
-
end
|
26
|
-
|
27
|
-
When /^I fetch all builds$/ do
|
28
|
-
@builds = client.builds
|
29
|
-
end
|
30
|
-
|
31
|
-
Then /^all builds should have a state$/ do
|
32
|
-
@builds.each { |b| [:successful, :failed].should include(b.state) }
|
33
|
-
end
|
34
|
-
|
35
|
-
When /^I login to in with my credentials, (.*) and (.*)$/ do |username, password|
|
36
|
-
client.login(username, password)
|
37
|
-
client.cookies != nil
|
38
|
-
end
|