bamboo-client 0.0.1 → 0.0.2
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/remote.feature +1 -0
- data/features/step_definitions/remote_steps.rb +3 -1
- data/lib/bamboo-client/http/xml.rb +4 -4
- data/lib/bamboo-client/remote.rb +21 -4
- data/lib/bamboo-client/version.rb +1 -1
- data/spec/bamboo-client/http/xml_spec.rb +18 -0
- data/spec/bamboo-client/remote_spec.rb +25 -3
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
data/features/remote.feature
CHANGED
@@ -15,7 +15,6 @@ Then /^I should get a list of builds$/ do
|
|
15
15
|
@builds.each { |e| e.should be_kind_of(Bamboo::Client::Remote::Build) }
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
18
|
When /^I fetch a build result$/ do
|
20
19
|
builds = client.builds
|
21
20
|
build_key = builds.first.key
|
@@ -31,3 +30,6 @@ Then /^the build result should have a state$/ do
|
|
31
30
|
@build_result.state.should be_kind_of(Symbol)
|
32
31
|
end
|
33
32
|
|
33
|
+
Then /^I should be able to get the latest result$/ do
|
34
|
+
@builds.first.latest_results.should be_kind_of(Bamboo::Client::Remote::BuildResult)
|
35
|
+
end
|
@@ -18,15 +18,15 @@ module Bamboo
|
|
18
18
|
@doc.css(css).text
|
19
19
|
end
|
20
20
|
|
21
|
-
def objects_for(selector, klass)
|
22
|
-
@doc.css(selector).map { |e| klass.new(e) }
|
21
|
+
def objects_for(selector, klass, *extra_args)
|
22
|
+
@doc.css(selector).map { |e| klass.new(e, *extra_args) }
|
23
23
|
end
|
24
24
|
|
25
|
-
def object_for(selector, klass)
|
25
|
+
def object_for(selector, klass, *extra_args)
|
26
26
|
node = @doc.css(selector).first
|
27
27
|
node or raise Error, "no node matches selector #{selector.inspect}"
|
28
28
|
|
29
|
-
klass.new node
|
29
|
+
klass.new node, *extra_args
|
30
30
|
end
|
31
31
|
end # Doc
|
32
32
|
|
data/lib/bamboo-client/remote.rb
CHANGED
@@ -20,7 +20,7 @@ module Bamboo
|
|
20
20
|
:username => user,
|
21
21
|
:password => pass
|
22
22
|
|
23
|
-
@token = doc.text_for
|
23
|
+
@token = doc.text_for "response auth"
|
24
24
|
end
|
25
25
|
|
26
26
|
def logout
|
@@ -45,7 +45,7 @@ module Bamboo
|
|
45
45
|
def builds
|
46
46
|
doc = post :listBuildNames, :auth => token
|
47
47
|
|
48
|
-
doc.objects_for "build", Remote::Build
|
48
|
+
doc.objects_for "build", Remote::Build, self
|
49
49
|
end
|
50
50
|
|
51
51
|
def latest_builds_for(user)
|
@@ -53,7 +53,7 @@ module Bamboo
|
|
53
53
|
:auth => token,
|
54
54
|
:user => user
|
55
55
|
|
56
|
-
doc.objects_for "build", Remote::Build
|
56
|
+
doc.objects_for "build", Remote::Build, self
|
57
57
|
end
|
58
58
|
|
59
59
|
def latest_build_results(build_key)
|
@@ -91,8 +91,9 @@ module Bamboo
|
|
91
91
|
#
|
92
92
|
|
93
93
|
class Build
|
94
|
-
def initialize(doc)
|
94
|
+
def initialize(doc, client)
|
95
95
|
@doc = doc
|
96
|
+
@client = client
|
96
97
|
end
|
97
98
|
|
98
99
|
def enabled?
|
@@ -106,6 +107,22 @@ module Bamboo
|
|
106
107
|
def key
|
107
108
|
@doc.css("key").text
|
108
109
|
end
|
110
|
+
|
111
|
+
def latest_results
|
112
|
+
@client.latest_build_results key
|
113
|
+
end
|
114
|
+
|
115
|
+
def execute
|
116
|
+
@client.execute_build(key)
|
117
|
+
end
|
118
|
+
|
119
|
+
def update_and_build
|
120
|
+
@client.update_and_build(key)
|
121
|
+
end
|
122
|
+
|
123
|
+
def recently_completed_results
|
124
|
+
@client.recently_completed_results_for_build(key)
|
125
|
+
end
|
109
126
|
end
|
110
127
|
|
111
128
|
class BuildResult
|
@@ -42,10 +42,28 @@ module Bamboo
|
|
42
42
|
|
43
43
|
it "returns an instance of the given class for the first node matching the selector" do
|
44
44
|
wrapped.should_receive(:css).with("selector").and_return(['node1', 'node2'])
|
45
|
+
|
45
46
|
obj = doc.object_for("selector", SpecHelper::Wrapper)
|
47
|
+
|
46
48
|
obj.should be_instance_of(SpecHelper::Wrapper)
|
47
49
|
obj.obj.should == "node1"
|
48
50
|
end
|
51
|
+
|
52
|
+
it "#object_for passes extra args to the given class' constructor" do
|
53
|
+
wrapped.should_receive(:css).with("selector").and_return(['node1', 'node2'])
|
54
|
+
|
55
|
+
SpecHelper::Wrapper.should_receive(:new).with('node1', "foo")
|
56
|
+
doc.object_for("selector", SpecHelper::Wrapper, "foo")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "#objects_for passes extra args to the given class' constructor" do
|
60
|
+
wrapped.should_receive(:css).with("selector").and_return(['node1', 'node2'])
|
61
|
+
|
62
|
+
SpecHelper::Wrapper.should_receive(:new).with('node1', "foo")
|
63
|
+
SpecHelper::Wrapper.should_receive(:new).with('node2', "foo")
|
64
|
+
|
65
|
+
doc.objects_for("selector", SpecHelper::Wrapper, "foo")
|
66
|
+
end
|
49
67
|
end
|
50
68
|
end
|
51
69
|
end
|
@@ -64,7 +64,7 @@ module Bamboo
|
|
64
64
|
end
|
65
65
|
|
66
66
|
it "fetches a list of builds" do
|
67
|
-
document.should_receive(:objects_for).with("build", Remote::Build).
|
67
|
+
document.should_receive(:objects_for).with("build", Remote::Build, client).
|
68
68
|
and_return(["some", "objects"])
|
69
69
|
|
70
70
|
http.should_receive(:post).with(
|
@@ -76,7 +76,7 @@ module Bamboo
|
|
76
76
|
end
|
77
77
|
|
78
78
|
it "fetches a list of the latest builds for the given user" do
|
79
|
-
document.should_receive(:objects_for).with("build", Remote::Build).
|
79
|
+
document.should_receive(:objects_for).with("build", Remote::Build, client).
|
80
80
|
and_return(["some", "objects"])
|
81
81
|
|
82
82
|
user = "fake-user"
|
@@ -131,7 +131,9 @@ module Bamboo
|
|
131
131
|
end # API calls
|
132
132
|
|
133
133
|
describe Remote::Build do
|
134
|
-
let(:
|
134
|
+
let(:client) { mock(Remote) }
|
135
|
+
let(:doc) { xml_fixture("build").css("build").first }
|
136
|
+
let(:build) { Remote::Build.new(doc, client) }
|
135
137
|
|
136
138
|
it "should know if the build is enabled" do
|
137
139
|
build.should be_enabled
|
@@ -144,6 +146,26 @@ module Bamboo
|
|
144
146
|
it "should know the key of the build" do
|
145
147
|
build.key.should == "THRIFT-DEFAULT"
|
146
148
|
end
|
149
|
+
|
150
|
+
it "should be able to fetch the latest results" do
|
151
|
+
client.should_receive(:latest_build_results).with build.key
|
152
|
+
build.latest_results
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should be able to execute the build" do
|
156
|
+
client.should_receive(:execute_build).with build.key
|
157
|
+
build.execute
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should be able to update and build" do
|
161
|
+
client.should_receive(:update_and_build).with build.key
|
162
|
+
build.update_and_build
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should be able to fetch recentyl completed results" do
|
166
|
+
client.should_receive(:recently_completed_results_for_build).with build.key
|
167
|
+
build.recently_completed_results
|
168
|
+
end
|
147
169
|
end # Remote::Build
|
148
170
|
|
149
171
|
describe Remote::BuildResult do
|
data/spec/spec_helper.rb
CHANGED