teamcity-rest-client 0.2.0 → 0.2.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.2
@@ -73,19 +73,21 @@ module TeamcityRestClient
73
73
  end
74
74
 
75
75
  def latest_builds filter = {}
76
- build_types(filter).collect(&:latest_build)
76
+ build_types(filter).collect(&:latest_build).reject(&:nil?)
77
77
  end
78
78
 
79
- def builds
79
+ def builds options = {}
80
80
  bt_ids = Set.new(build_types.collect(&:id))
81
- teamcity.builds.find_all { |b| bt_ids.include? b.build_type_id }
81
+ teamcity.builds(options).find_all { |b| bt_ids.include? b.build_type_id }
82
82
  end
83
83
  end
84
84
 
85
85
  BuildType = Struct.new(:teamcity, :id, :name, :href, :project_name, :project_id, :web_url) do
86
- # httpAuth/app/rest/builds?buildType=id:bt107&count=1
86
+ def builds options = {}
87
+ teamcity.builds({:buildType => "id:#{id}"}.merge(options))
88
+ end
87
89
  def latest_build
88
- teamcity.builds(:buildType => "id:#{id}", :count => 1)[0]
90
+ builds(:count => 1)[0]
89
91
  end
90
92
  end
91
93
 
@@ -119,6 +119,7 @@ module TeamcityRestClient
119
119
  @bt11 = stub('bt11', :id => "bt11", :name => "project1-build1", :project_id => "project1")
120
120
  @bt12 = stub('bt12', :id => "bt12", :name => "project1-build2", :project_id => "project1")
121
121
  @bt13 = stub('bt13', :id => "bt13", :name => "project1-build3", :project_id => "project1")
122
+ @bt14 = stub('bt14', :id => "bt14", :name => "project1-build4-never-been-built", :project_id => "project1")
122
123
  @bt21 = stub('bt21', :id => "bt21", :name => "project2-build1", :project_id => "project2")
123
124
 
124
125
  @bt11_1 = stub('bt11_1', :id => "1", :build_type_id => "bt11")
@@ -127,7 +128,7 @@ module TeamcityRestClient
127
128
  @bt13_44 = stub('bt13_44', :id => "44", :build_type_id => "bt13")
128
129
  @bt21_666 = stub('bt21_666', :id => "666", :build_type_id => "bt21")
129
130
 
130
- @tc = stub('teamcity', :build_types => [@bt11, @bt12, @bt13, @bt21], :builds => [@bt11_1, @bt11_2, @bt12_33, @bt13_44, @bt21_666])
131
+ @tc = mock('teamcity', :build_types => [@bt11, @bt12, @bt13, @bt14, @bt21], :builds => [@bt11_1, @bt11_2, @bt12_33, @bt13_44, @bt21_666])
131
132
  @project1 = Project.new @tc, "Project 1", "project1", "http://www.example.com"
132
133
  end
133
134
 
@@ -137,7 +138,7 @@ module TeamcityRestClient
137
138
  end
138
139
 
139
140
  it "should have only those for project 1" do
140
- @build_types.should == [@bt11, @bt12, @bt13]
141
+ @build_types.should == [@bt11, @bt12, @bt13, @bt14]
141
142
  end
142
143
  end
143
144
 
@@ -156,13 +157,13 @@ module TeamcityRestClient
156
157
 
157
158
  describe "exclude" do
158
159
  it "should match by single project name" do
159
- @project1.build_types({ :exclude => "project1-build2" }).should == [@bt11, @bt13]
160
+ @project1.build_types({ :exclude => "project1-build2" }).should == [@bt11, @bt13, @bt14]
160
161
  end
161
162
  it "should match by single project id" do
162
- @project1.build_types({ :exclude => "bt11" }).should == [@bt12, @bt13]
163
+ @project1.build_types({ :exclude => "bt11" }).should == [@bt12, @bt13, @bt14]
163
164
  end
164
165
  it "should match by multiple project id and name" do
165
- @project1.build_types({ :exclude => ["bt11","project1-build2"] }).should == [@bt13]
166
+ @project1.build_types({ :exclude => ["bt11","project1-build2"] }).should == [@bt13, @bt14]
166
167
  end
167
168
  end
168
169
 
@@ -186,12 +187,27 @@ module TeamcityRestClient
186
187
  end
187
188
 
188
189
  describe "asking it for it's builds" do
189
- before :each do
190
- @builds = @project1.builds
190
+ describe 'with no options' do
191
+ before :each do
192
+ @tc.should_receive(:builds).with({}).and_return([@bt11_1, @bt11_2, @bt12_33, @bt13_44])
193
+ @builds = @project1.builds
194
+ end
195
+
196
+ it "should have only builds for project 1" do
197
+ @builds.should == [@bt11_1, @bt11_2, @bt12_33, @bt13_44]
198
+ end
191
199
  end
192
-
193
- it "should have only builds for project 1" do
194
- @builds.should == [@bt11_1, @bt11_2, @bt12_33, @bt13_44]
200
+
201
+ describe "with some other options" do
202
+ before :each do
203
+ @options = {:running => true}
204
+ @tc.should_receive(:builds).with(@options).and_return([@bt11_1, @bt11_2, @bt12_33, @bt13_44])
205
+ @builds = @project1.builds @options
206
+ end
207
+
208
+ it 'should pass through the options to tc' do
209
+ @builds.should == [@bt11_1, @bt11_2, @bt12_33, @bt13_44]
210
+ end
195
211
  end
196
212
  end
197
213
 
@@ -200,6 +216,7 @@ module TeamcityRestClient
200
216
  @bt11.stub(:latest_build).and_return(@bt11_2)
201
217
  @bt12.stub(:latest_build).and_return(@bt12_33)
202
218
  @bt13.stub(:latest_build).and_return(@bt13_44)
219
+ @bt14.stub(:latest_build).and_return(nil)
203
220
  end
204
221
 
205
222
  describe "for all builds in project" do
@@ -302,12 +319,36 @@ module TeamcityRestClient
302
319
  end
303
320
 
304
321
  describe "latest_build" do
322
+ describe "when there has been at least 1 build" do
323
+ before :each do
324
+ @build = mock('build')
325
+ @tc.should_receive(:builds).with(:buildType => "id:bt123", :count => 1).and_return [@build]
326
+ end
327
+
328
+ it "should ask teamcity, and return the single build" do
329
+ @build_type.latest_build.should == @build
330
+ end
331
+ end
332
+
333
+ describe "when there hasnt ever been a build" do
334
+ before :each do
335
+ @tc.should_receive(:builds).with(:buildType => "id:bt123", :count => 1).and_return []
336
+ end
337
+
338
+ it "should ask teamcity, and get no build back" do
339
+ @build_type.latest_build.should be_nil
340
+ end
341
+ end
342
+ end
343
+
344
+ describe "builds" do
305
345
  before :each do
306
- @build = mock('build')
307
- @tc.should_receive(:builds).with(:buildType => "id:bt123", :count => 1).and_return [@build]
346
+ @build1 = mock('build1')
347
+ @build2 = mock('build2')
348
+ @tc.should_receive(:builds).with({:buildType => "id:bt123", :running => true, :somethingelse => 'here'}).and_return [@build1, @build2]
308
349
  end
309
350
  it "should ask teamcity" do
310
- @build_type.latest_build.should == @build
351
+ @build_type.builds({ :running => true, :somethingelse => 'here' }).should == [@build1, @build2]
311
352
  end
312
353
  end
313
354
  end
@@ -485,6 +526,18 @@ XML
485
526
  end
486
527
 
487
528
  describe "builds" do
529
+ describe "when there hasnt been any builds for configuration" do
530
+ before :each do
531
+ xml = <<XML
532
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
533
+ <builds count="0"/>
534
+ XML
535
+ end
536
+
537
+ pending "it should return an empty array"
538
+
539
+ end
540
+
488
541
  describe "with options specified" do
489
542
  before :each do
490
543
  xml = <<XML
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "teamcity-rest-client"
8
- s.version = "0.2.0"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["simon"]
12
- s.date = "2011-10-27"
12
+ s.date = "2011-11-03"
13
13
  s.description = "Teamcity rest api client (readonly)"
14
14
  s.email = "simojenki@gmail.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teamcity-rest-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-27 00:00:00.000000000Z
12
+ date: 2011-11-03 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2159724440 !ruby/object:Gem::Requirement
16
+ requirement: &2157516220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.3.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2159724440
24
+ version_requirements: *2157516220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &2159723960 !ruby/object:Gem::Requirement
27
+ requirement: &2157515740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2159723960
35
+ version_requirements: *2157515740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &2159723480 !ruby/object:Gem::Requirement
38
+ requirement: &2157515240 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.6.4
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2159723480
46
+ version_requirements: *2157515240
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rcov
49
- requirement: &2159723000 !ruby/object:Gem::Requirement
49
+ requirement: &2157514760 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2159723000
57
+ version_requirements: *2157514760
58
58
  description: Teamcity rest api client (readonly)
59
59
  email: simojenki@gmail.com
60
60
  executables: []
@@ -94,7 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
94
  version: '0'
95
95
  segments:
96
96
  - 0
97
- hash: -677859045905772882
97
+ hash: 1926460357061401344
98
98
  required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  none: false
100
100
  requirements: