bamboo-client 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bamboo-client/http/json.rb +5 -0
- data/lib/bamboo-client/rest.rb +8 -2
- data/lib/bamboo-client/version.rb +1 -1
- data/spec/bamboo-client/http/json_spec.rb +8 -0
- data/spec/bamboo-client/http/xml_spec.rb +4 -4
- data/spec/bamboo-client/remote_spec.rb +5 -5
- data/spec/bamboo-client/rest_spec.rb +8 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38822888e09b2105e0e6142f35de3a5f4fa11fa6
|
4
|
+
data.tar.gz: 9567bc374446f4c83212ab531123a992fd09e21e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8ccba78195cb35cc858d321e55e1206e9ad615e44c65c551a3dce3af1d56946ee69a47b67f6a991b747af181fe9d4769f21a620803cd687dc62b7fdc3db2e8e
|
7
|
+
data.tar.gz: 0f8da5377be315763cfcdc6c15fc3bfaee098bebe97a3cb97013ec1e7be3f310554fbdaf3f2e26d12b79a3708622a57dc2afd3318018bcd1c5e3d95bf868e18e
|
@@ -46,6 +46,11 @@ module Bamboo
|
|
46
46
|
Doc.from(resp) unless resp.empty?
|
47
47
|
end
|
48
48
|
|
49
|
+
def post_with_query(uri_or_path, query = {}, cookies = nil)
|
50
|
+
resp = RestClient.post(uri_for(uri_or_path, query), '{}', :accept => :json, :content_type => :json, :cookies => cookies)
|
51
|
+
Doc.from(resp) unless resp.empty?
|
52
|
+
end
|
53
|
+
|
49
54
|
def get(uri_or_path, params = nil, cookies = nil)
|
50
55
|
uri = uri_for(uri_or_path, params)
|
51
56
|
Doc.from RestClient.get(uri, :accept => :json, :cookies => cookies)
|
data/lib/bamboo-client/rest.rb
CHANGED
@@ -89,8 +89,14 @@ module Bamboo
|
|
89
89
|
@data.fetch("link")['href']
|
90
90
|
end
|
91
91
|
|
92
|
-
def queue
|
93
|
-
|
92
|
+
def queue(params = nil)
|
93
|
+
path = File.join(SERVICE, "queue/#{URI.escape key}")
|
94
|
+
|
95
|
+
if params
|
96
|
+
@http.post_with_query path, params, @http.cookies
|
97
|
+
else
|
98
|
+
@http.post path, {}, @http.cookies
|
99
|
+
end
|
94
100
|
end
|
95
101
|
|
96
102
|
def results
|
@@ -24,6 +24,14 @@ module Bamboo
|
|
24
24
|
json.post("/", :some => "data").should be_nil
|
25
25
|
end
|
26
26
|
|
27
|
+
it 'does a POST with query instead of JSON data' do
|
28
|
+
RestClient.should_receive(:post).with(
|
29
|
+
"#{url}/?some=data", '{}', :accept => :json, :content_type => :json, :cookies => nil
|
30
|
+
).and_return('')
|
31
|
+
|
32
|
+
json.post_with_query("/", :some => "data").should be_nil
|
33
|
+
end
|
34
|
+
|
27
35
|
it "returns cookies from GET" do
|
28
36
|
net_http_resp = Net::HTTPResponse.new(1.0, 200, "OK")
|
29
37
|
net_http_resp.add_field 'Set-Cookie', 'Cookie=Value;'
|
@@ -20,8 +20,8 @@ module Bamboo
|
|
20
20
|
|
21
21
|
describe Xml::Doc do
|
22
22
|
let(:wrapped) {
|
23
|
-
m =
|
24
|
-
m.stub
|
23
|
+
m = double("nokogiri document")
|
24
|
+
m.stub(:css).with("errors error").and_return []
|
25
25
|
m
|
26
26
|
}
|
27
27
|
let(:doc) { Xml::Doc.new(wrapped)}
|
@@ -29,13 +29,13 @@ module Bamboo
|
|
29
29
|
it "returns the text of the given CSS selector" do
|
30
30
|
wrapped.should_receive(:css).
|
31
31
|
with("some selector").
|
32
|
-
and_return(
|
32
|
+
and_return(double("node", :text => "bar"))
|
33
33
|
|
34
34
|
doc.text_for("some selector").should == "bar"
|
35
35
|
end
|
36
36
|
|
37
37
|
it "checks for errors in the given document" do
|
38
|
-
wrapped.should_receive(:css).with("errors error").and_return [
|
38
|
+
wrapped.should_receive(:css).with("errors error").and_return [double(:text => "error!")]
|
39
39
|
lambda { doc.text_for "some selector" }.should raise_error(Bamboo::Client::Error)
|
40
40
|
end
|
41
41
|
|
@@ -4,10 +4,10 @@ module Bamboo
|
|
4
4
|
module Client
|
5
5
|
describe Remote do
|
6
6
|
let(:url) { "http://bamboo.example.com" }
|
7
|
-
let(:http) {
|
7
|
+
let(:http) { double(Http::Xml) }
|
8
8
|
let(:client) { Remote.new(http) }
|
9
9
|
let(:document) {
|
10
|
-
m =
|
10
|
+
m = double(Http::Xml::Doc)
|
11
11
|
m.stub(:css).with("errors error").and_return []
|
12
12
|
|
13
13
|
m
|
@@ -136,7 +136,7 @@ module Bamboo
|
|
136
136
|
end # API calls
|
137
137
|
|
138
138
|
describe Remote::Build do
|
139
|
-
let(:client) {
|
139
|
+
let(:client) { double(Remote) }
|
140
140
|
let(:doc) { xml_fixture("build").css("build").first }
|
141
141
|
let(:build) { Remote::Build.new(doc, client) }
|
142
142
|
|
@@ -214,12 +214,12 @@ module Bamboo
|
|
214
214
|
end
|
215
215
|
|
216
216
|
it "returns nil if start time can not be parsed" do
|
217
|
-
doc.stub(:css).and_return
|
217
|
+
doc.stub(:css).and_return double(:text => "Sun Sep 32")
|
218
218
|
result.start_time.should be_nil
|
219
219
|
end
|
220
220
|
|
221
221
|
it "returns nil if start time can not be parsed" do
|
222
|
-
doc.stub(:css).and_return
|
222
|
+
doc.stub(:css).and_return double(:text => "Sun Sep 32")
|
223
223
|
result.end_time.should be_nil
|
224
224
|
end
|
225
225
|
|
@@ -3,8 +3,8 @@ require File.expand_path("../../spec_helper", __FILE__)
|
|
3
3
|
module Bamboo
|
4
4
|
module Client
|
5
5
|
describe Rest do
|
6
|
-
let(:http) {
|
7
|
-
let(:document) {
|
6
|
+
let(:http) { double(Http::Json) }
|
7
|
+
let(:document) { double(Http::Json::Doc) }
|
8
8
|
let(:client) { Rest.new(http) }
|
9
9
|
|
10
10
|
it "logs in" do
|
@@ -115,6 +115,12 @@ module Bamboo
|
|
115
115
|
plan.queue
|
116
116
|
end
|
117
117
|
|
118
|
+
it "can be queued with parameters" do
|
119
|
+
http.should_receive(:cookies).and_return("some" => "cookie")
|
120
|
+
http.should_receive(:post_with_query).with("/rest/api/latest/queue/S2RB-REMWIN", {:customRevision => 'test123'}, {"some" => "cookie"})
|
121
|
+
plan.queue(:customRevision => 'test123')
|
122
|
+
end
|
123
|
+
|
118
124
|
it 'can fetch results' do
|
119
125
|
document.should_receive(:auto_expand).with(Rest::Result, http)
|
120
126
|
http.should_receive(:cookies).and_return("some" => "cookie")
|
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.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Bakken
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
176
|
version: '0'
|
177
177
|
requirements: []
|
178
178
|
rubyforge_project: bamboo-client
|
179
|
-
rubygems_version: 2.0.
|
179
|
+
rubygems_version: 2.0.3
|
180
180
|
signing_key:
|
181
181
|
specification_version: 4
|
182
182
|
summary: Ruby client for Atlassian Bamboo's REST APIs
|
@@ -203,4 +203,3 @@ test_files:
|
|
203
203
|
- spec/fixtures/result.json
|
204
204
|
- spec/fixtures/result_with_changes.json
|
205
205
|
- spec/spec_helper.rb
|
206
|
-
has_rdoc:
|