teamcity-ruby-client 0.1.0
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.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/.rvmrc +48 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +153 -0
- data/Rakefile +16 -0
- data/lib/faraday/null_response_body.rb +17 -0
- data/lib/teamcity/api.rb +19 -0
- data/lib/teamcity/client/build_types.rb +93 -0
- data/lib/teamcity/client/builds.rb +36 -0
- data/lib/teamcity/client/common.rb +24 -0
- data/lib/teamcity/client/projects.rb +46 -0
- data/lib/teamcity/client.rb +14 -0
- data/lib/teamcity/configuration.rb +47 -0
- data/lib/teamcity/connection.rb +27 -0
- data/lib/teamcity/request.rb +40 -0
- data/lib/teamcity/version.rb +3 -0
- data/lib/teamcity.rb +24 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype/should_fetch_the_details_of_a_buildtype_by_id.yml +49 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype/should_raise_an_error_if_the_buildtype_does_not_exist.yml +50 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_agent_requirements/should_fetch_the_build_configuration_agent_requirements_for_a_buildtype.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_agent_requirements/should_return_an_array.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_agent_requirements/should_return_nil_if_there_are_no_agent_requirements_defined.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_artifact_dependencies/should_fetch_the_build_configuration_artifact_dependencies_for_a_buildtype.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_artifact_dependencies/should_return_an_array.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_artifact_dependencies/should_return_nil_if_there_are_no_artifact_dependencies_defined.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_features/should_fetch_the_build_configuration_features_for_a_buildtype.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_features/should_return_an_array.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_features/should_return_nil_if_there_are_no_features_defined.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_parameters/should_fetch_the_build_configuration_parameters_for_a_buildtype.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_parameters/should_return_an_array.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_parameters/should_return_nil_if_there_are_no_parameters_defined.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_settings/should_fetch_the_settings_for_a_given_buildtype.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_settings/should_return_an_array.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_snapshot_dependencies/should_fetch_the_build_configuration_snapshot_dependencies_for_a_buildtype.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_snapshot_dependencies/should_return_an_array.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_snapshot_dependencies/should_return_nil_if_there_are_no_snapshot_dependencies_defined.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_steps/should_fetch_the_build_configuration_steps_for_a_buildtype.yml +46 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_steps/should_return_an_array.yml +46 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_steps/should_return_nil_if_there_are_no_steps_defined.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_template/should_raise_an_exception_if_the_response_is_not_due_to_a_template_not_assigned.yml +50 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_template/should_return_nil_if_the_buildtype_is_not_associated_with_a_template.yml +50 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_template/should_return_the_attributes_of_the_associated_template.yml +45 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_triggers/should_fetch_the_build_configuration_triggers_for_a_buildtype.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_triggers/should_return_an_array.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_triggers/should_return_nil_if_there_are_no_triggers_defined.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_vcs_root_entries/should_fetch_the_build_configuration_vcs_root_entries_for_a_buildtype.yml +45 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_vcs_root_entries/should_return_an_array.yml +45 -0
- data/spec/cassettes/BuildTypes/GET/_buildtype_vcs_root_entries/should_return_nil_if_there_are_no_vcs_root_entries_defined.yml +44 -0
- data/spec/cassettes/BuildTypes/GET/_buildtypes/should_fetch_all_the_buildtypes.yml +49 -0
- data/spec/cassettes/Builds/GET/_build/should_fetch_the_build_details.yml +49 -0
- data/spec/cassettes/Builds/GET/_build/should_raise_an_error_if_the_build_does_not_exist.yml +50 -0
- data/spec/cassettes/Builds/GET/_build_tags/should_fetch_the_build_tags.yml +44 -0
- data/spec/cassettes/Builds/GET/_build_tags/should_return_nil_if_there_are_no_build_tags_defined_for_a_build.yml +44 -0
- data/spec/cassettes/Builds/GET/_builds/should_allow_you_to_filter_by_multiple_build_locators.yml +44 -0
- data/spec/cassettes/Builds/GET/_builds/should_allow_you_to_filter_results_by_build_locators.yml +44 -0
- data/spec/cassettes/Builds/GET/_builds/should_allow_you_to_search_by_locator.yml +44 -0
- data/spec/cassettes/Builds/GET/_builds/should_fetch_all_the_builds.yml +44 -0
- data/spec/cassettes/Projects/GET/_project/should_fetch_a_single_project_by_id.yml +47 -0
- data/spec/cassettes/Projects/GET/_project/should_raise_an_error_if_the_project_does_not_exist.yml +50 -0
- data/spec/cassettes/Projects/GET/_project_buildtypes/should_fetch_all_the_buildTypes_for_a_project.yml +45 -0
- data/spec/cassettes/Projects/GET/_project_buildtypes/should_return_nil_if_the_project_does_not_have_any_build_build_types.yml +44 -0
- data/spec/cassettes/Projects/GET/_project_parameters/should_fetch_all_the_paramters_for_a_given_project.yml +44 -0
- data/spec/cassettes/Projects/GET/_project_parameters/should_return_nil_if_there_are_no_parameters_defined_for_a_project.yml +44 -0
- data/spec/cassettes/Projects/GET/_projects/should_fetch_projects.yml +46 -0
- data/spec/cassettes/Projects/GET/_projects/should_return_nil_if_there_are_no_projects.yml +44 -0
- data/spec/faraday/null_response_body_spec.rb +18 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/support/vcr_setup.rb +9 -0
- data/spec/teamcity/api_spec.rb +63 -0
- data/spec/teamcity/client/builds_spec.rb +62 -0
- data/spec/teamcity/client/buildtypes_spec.rb +106 -0
- data/spec/teamcity/client/projects_spec.rb +82 -0
- data/spec/teamcity/client_spec.rb +10 -0
- data/spec/teamcity/version_spec.rb +7 -0
- data/spec/teamcity_spec.rb +90 -0
- data/teamcity-ruby-client.gemspec +32 -0
- metadata +334 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: http://localhost:8111/guestAuth/app/rest/7.0/projects/id:project2/buildTypes
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept:
|
|
11
|
+
- application/json; charset=utf-8
|
|
12
|
+
User-Agent:
|
|
13
|
+
- TeamCity Ruby Client 0.0.1
|
|
14
|
+
Accept-Encoding:
|
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Server:
|
|
22
|
+
- Apache-Coyote/1.1
|
|
23
|
+
Set-Cookie:
|
|
24
|
+
- JSESSIONID=CDED34F8A3AEFF72A18A3733E4E38B68; Path=/; HttpOnly
|
|
25
|
+
- RememberMe=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly
|
|
26
|
+
Pragma:
|
|
27
|
+
- no-cache
|
|
28
|
+
Expires:
|
|
29
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
|
30
|
+
Cache-Control:
|
|
31
|
+
- no-cache
|
|
32
|
+
- no-store
|
|
33
|
+
Content-Type:
|
|
34
|
+
- application/json
|
|
35
|
+
Transfer-Encoding:
|
|
36
|
+
- chunked
|
|
37
|
+
Date:
|
|
38
|
+
- Tue, 26 Feb 2013 03:28:32 GMT
|
|
39
|
+
body:
|
|
40
|
+
encoding: US-ASCII
|
|
41
|
+
string: ! '{"buildType":[{"id":"bt2","name":"build A1","href":"/guestAuth/app/rest/7.0/buildTypes/id:bt2","projectName":"Project
|
|
42
|
+
A","projectId":"project2","webUrl":"http://localhost:8111/viewType.html?buildTypeId=bt2"}]}'
|
|
43
|
+
http_version:
|
|
44
|
+
recorded_at: Tue, 26 Feb 2013 03:28:32 GMT
|
|
45
|
+
recorded_with: VCR 2.4.0
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: http://localhost:8111/guestAuth/app/rest/7.0/projects/id:project5/buildTypes
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept:
|
|
11
|
+
- application/json; charset=utf-8
|
|
12
|
+
User-Agent:
|
|
13
|
+
- TeamCity Ruby Client 0.0.1
|
|
14
|
+
Accept-Encoding:
|
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Server:
|
|
22
|
+
- Apache-Coyote/1.1
|
|
23
|
+
Set-Cookie:
|
|
24
|
+
- JSESSIONID=A8CE54A1F37D36EB7C9300AA1456389C; Path=/; HttpOnly
|
|
25
|
+
- RememberMe=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly
|
|
26
|
+
Pragma:
|
|
27
|
+
- no-cache
|
|
28
|
+
Expires:
|
|
29
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
|
30
|
+
Cache-Control:
|
|
31
|
+
- no-cache
|
|
32
|
+
- no-store
|
|
33
|
+
Content-Type:
|
|
34
|
+
- application/json
|
|
35
|
+
Transfer-Encoding:
|
|
36
|
+
- chunked
|
|
37
|
+
Date:
|
|
38
|
+
- Tue, 26 Feb 2013 03:46:46 GMT
|
|
39
|
+
body:
|
|
40
|
+
encoding: US-ASCII
|
|
41
|
+
string: 'null'
|
|
42
|
+
http_version:
|
|
43
|
+
recorded_at: Tue, 26 Feb 2013 03:46:46 GMT
|
|
44
|
+
recorded_with: VCR 2.4.0
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: http://localhost:8111/guestAuth/app/rest/7.0/projects/id:project2/parameters
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept:
|
|
11
|
+
- application/json; charset=utf-8
|
|
12
|
+
User-Agent:
|
|
13
|
+
- TeamCity Ruby Client 0.0.1
|
|
14
|
+
Accept-Encoding:
|
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Server:
|
|
22
|
+
- Apache-Coyote/1.1
|
|
23
|
+
Set-Cookie:
|
|
24
|
+
- JSESSIONID=941AB4BA14E5E85C970F81A63BF2D69D; Path=/; HttpOnly
|
|
25
|
+
- RememberMe=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly
|
|
26
|
+
Pragma:
|
|
27
|
+
- no-cache
|
|
28
|
+
Expires:
|
|
29
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
|
30
|
+
Cache-Control:
|
|
31
|
+
- no-cache
|
|
32
|
+
- no-store
|
|
33
|
+
Content-Type:
|
|
34
|
+
- application/json
|
|
35
|
+
Transfer-Encoding:
|
|
36
|
+
- chunked
|
|
37
|
+
Date:
|
|
38
|
+
- Wed, 27 Feb 2013 12:52:33 GMT
|
|
39
|
+
body:
|
|
40
|
+
encoding: US-ASCII
|
|
41
|
+
string: ! '{"property":[{"name":"env.test1","value":"test"},{"name":"param1","value":"1"},{"name":"system.test","value":"test"}]}'
|
|
42
|
+
http_version:
|
|
43
|
+
recorded_at: Wed, 27 Feb 2013 12:52:33 GMT
|
|
44
|
+
recorded_with: VCR 2.4.0
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: http://localhost:8111/guestAuth/app/rest/7.0/projects/id:project3/parameters
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept:
|
|
11
|
+
- application/json; charset=utf-8
|
|
12
|
+
User-Agent:
|
|
13
|
+
- TeamCity Ruby Client 0.0.1
|
|
14
|
+
Accept-Encoding:
|
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Server:
|
|
22
|
+
- Apache-Coyote/1.1
|
|
23
|
+
Set-Cookie:
|
|
24
|
+
- JSESSIONID=DED63B8443311CD8DBFB7C4BDB8FE7E2; Path=/; HttpOnly
|
|
25
|
+
- RememberMe=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly
|
|
26
|
+
Pragma:
|
|
27
|
+
- no-cache
|
|
28
|
+
Expires:
|
|
29
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
|
30
|
+
Cache-Control:
|
|
31
|
+
- no-cache
|
|
32
|
+
- no-store
|
|
33
|
+
Content-Type:
|
|
34
|
+
- application/json
|
|
35
|
+
Transfer-Encoding:
|
|
36
|
+
- chunked
|
|
37
|
+
Date:
|
|
38
|
+
- Wed, 27 Feb 2013 12:57:56 GMT
|
|
39
|
+
body:
|
|
40
|
+
encoding: US-ASCII
|
|
41
|
+
string: 'null'
|
|
42
|
+
http_version:
|
|
43
|
+
recorded_at: Wed, 27 Feb 2013 12:57:57 GMT
|
|
44
|
+
recorded_with: VCR 2.4.0
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: http://localhost:8111/guestAuth/app/rest/7.0/projects
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept:
|
|
11
|
+
- application/json; charset=utf-8
|
|
12
|
+
User-Agent:
|
|
13
|
+
- TeamCity Ruby Client 0.0.1
|
|
14
|
+
Accept-Encoding:
|
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Server:
|
|
22
|
+
- Apache-Coyote/1.1
|
|
23
|
+
Set-Cookie:
|
|
24
|
+
- JSESSIONID=5057656A6D66E122DBED5E13085F68F2; Path=/; HttpOnly
|
|
25
|
+
- RememberMe=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly
|
|
26
|
+
Pragma:
|
|
27
|
+
- no-cache
|
|
28
|
+
Expires:
|
|
29
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
|
30
|
+
Cache-Control:
|
|
31
|
+
- no-cache
|
|
32
|
+
- no-store
|
|
33
|
+
Content-Type:
|
|
34
|
+
- application/json
|
|
35
|
+
Transfer-Encoding:
|
|
36
|
+
- chunked
|
|
37
|
+
Date:
|
|
38
|
+
- Tue, 26 Feb 2013 03:04:07 GMT
|
|
39
|
+
body:
|
|
40
|
+
encoding: US-ASCII
|
|
41
|
+
string: ! '{"project":[{"id":"project2","name":"Project A","href":"/guestAuth/app/rest/7.0/projects/id:project2"},{"id":"project3","name":"Project
|
|
42
|
+
B","href":"/guestAuth/app/rest/7.0/projects/id:project3"},{"id":"project4","name":"Project
|
|
43
|
+
C","href":"/guestAuth/app/rest/7.0/projects/id:project4"}]}'
|
|
44
|
+
http_version:
|
|
45
|
+
recorded_at: Tue, 26 Feb 2013 03:04:07 GMT
|
|
46
|
+
recorded_with: VCR 2.4.0
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: http://localhost:8111/guestAuth/app/rest/7.0/projects
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept:
|
|
11
|
+
- application/json; charset=utf-8
|
|
12
|
+
User-Agent:
|
|
13
|
+
- TeamCity Ruby Client 0.0.1
|
|
14
|
+
Accept-Encoding:
|
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Server:
|
|
22
|
+
- Apache-Coyote/1.1
|
|
23
|
+
Set-Cookie:
|
|
24
|
+
- JSESSIONID=D4F1893628C97DB58C370726929F7B67; Path=/; HttpOnly
|
|
25
|
+
- RememberMe=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly
|
|
26
|
+
Pragma:
|
|
27
|
+
- no-cache
|
|
28
|
+
Expires:
|
|
29
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
|
30
|
+
Cache-Control:
|
|
31
|
+
- no-cache
|
|
32
|
+
- no-store
|
|
33
|
+
Content-Type:
|
|
34
|
+
- application/json
|
|
35
|
+
Transfer-Encoding:
|
|
36
|
+
- chunked
|
|
37
|
+
Date:
|
|
38
|
+
- Tue, 26 Feb 2013 03:04:07 GMT
|
|
39
|
+
body:
|
|
40
|
+
encoding: US-ASCII
|
|
41
|
+
string: 'null'
|
|
42
|
+
http_version:
|
|
43
|
+
recorded_at: Tue, 26 Feb 2013 03:04:07 GMT
|
|
44
|
+
recorded_with: VCR 2.4.0
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "spec_helper.rb"
|
|
2
|
+
|
|
3
|
+
describe 'FaradayMiddleware' do
|
|
4
|
+
describe 'NullResponseBody' do
|
|
5
|
+
|
|
6
|
+
before(:each) do
|
|
7
|
+
@url = "#{TeamCity::Configuration::DEFAULT_ENDPOINT}projects"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should return empty hash if the body is 'null'" do
|
|
11
|
+
stub_request(:get, @url).to_return(:body => "null", :headers => {:content_type => "application/json; charset=utf-8"})
|
|
12
|
+
VCR.turned_off do
|
|
13
|
+
results = TeamCity.get('projects')
|
|
14
|
+
results.should be_empty
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'rspec/autorun'
|
|
2
|
+
require 'webmock/rspec'
|
|
3
|
+
require_relative 'support/vcr_setup'
|
|
4
|
+
|
|
5
|
+
require File.expand_path('../../lib/teamcity', __FILE__)
|
|
6
|
+
|
|
7
|
+
RSpec.configure do |c|
|
|
8
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def stub_get(path)
|
|
12
|
+
stub_request(:get, TeamCity.endpoint + path)
|
|
13
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require 'vcr'
|
|
2
|
+
|
|
3
|
+
# See https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/configuration
|
|
4
|
+
# for more configuration options (make sure and check the version of vcr matches)
|
|
5
|
+
VCR.configure do |c|
|
|
6
|
+
c.cassette_library_dir = 'spec/cassettes'
|
|
7
|
+
c.hook_into :webmock
|
|
8
|
+
c.configure_rspec_metadata!
|
|
9
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
|
2
|
+
|
|
3
|
+
describe TeamCity::API do
|
|
4
|
+
before do
|
|
5
|
+
@keys = TeamCity::Configuration::VALID_OPTIONS_KEYS
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
context "with module configuration" do
|
|
9
|
+
|
|
10
|
+
before do
|
|
11
|
+
TeamCity.configure do |config|
|
|
12
|
+
@keys.each do |key|
|
|
13
|
+
config.send("#{key}=", key)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
after do
|
|
19
|
+
TeamCity.reset
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should inherit module configuration" do
|
|
23
|
+
api = TeamCity::API.new
|
|
24
|
+
@keys.each do |key|
|
|
25
|
+
api.send(key).should == key
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context "with class configuration" do
|
|
30
|
+
|
|
31
|
+
before do
|
|
32
|
+
@configuration = {
|
|
33
|
+
:adapter => :excon,
|
|
34
|
+
:endpoint => 'http://teamcity.mydomain.com/',
|
|
35
|
+
:format => :xml,
|
|
36
|
+
:user_agent => 'My User Agent',
|
|
37
|
+
}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context "during initialization"
|
|
41
|
+
|
|
42
|
+
it "should override module configuration" do
|
|
43
|
+
api = TeamCity::API.new(@configuration)
|
|
44
|
+
@keys.each do |key|
|
|
45
|
+
api.send(key).should == @configuration[key]
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
context "after initilization" do
|
|
50
|
+
|
|
51
|
+
it "should override module configuration after initialization" do
|
|
52
|
+
api = TeamCity::API.new
|
|
53
|
+
@configuration.each do |key, value|
|
|
54
|
+
api.send("#{key}=", value)
|
|
55
|
+
end
|
|
56
|
+
@keys.each do |key|
|
|
57
|
+
api.send(key).should == @configuration[key]
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'Builds' do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@tc = TeamCity
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
before(:all) do
|
|
10
|
+
TeamCity.configure do |config|
|
|
11
|
+
config.endpoint = 'http://localhost:8111/guestAuth/app/rest/7.0/'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
after(:all) do
|
|
16
|
+
TeamCity.reset
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Get requests
|
|
20
|
+
describe 'GET', :vcr do
|
|
21
|
+
|
|
22
|
+
describe '.builds' do
|
|
23
|
+
it 'should fetch all the builds' do
|
|
24
|
+
@tc.builds.size.should eq(4)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'should allow you to filter results by build locators' do
|
|
28
|
+
@tc.builds(count:2).size.should eq(2)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'should allow you to filter by multiple build locators' do
|
|
32
|
+
@tc.builds(count: 2, status: 'SUCCESS').size.should eq(2)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe '.build' do
|
|
37
|
+
it 'should fetch the build details' do
|
|
38
|
+
@tc.build(id: 2).id.should eq(2)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'should raise an error if the build does not exist' do
|
|
42
|
+
expect { @tc.build(id: 10000) }.to raise_error
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'should raise an error if an id is not provided' do
|
|
46
|
+
expect { @tc.build }.to raise_error
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe '.build_tags' do
|
|
51
|
+
it 'should fetch the build tags' do
|
|
52
|
+
tags = @tc.build_tags(id: 2)
|
|
53
|
+
tags.size.should eq(1)
|
|
54
|
+
tags.first.should eq('release_tag')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'should return nil if there are no build tags defined for a build' do
|
|
58
|
+
@tc.build_tags(id: 1).should be_nil
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'BuildTypes' do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@tc = TeamCity
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
before(:all) do
|
|
10
|
+
TeamCity.configure do |config|
|
|
11
|
+
config.endpoint = 'http://localhost:8111/guestAuth/app/rest/7.0/'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
after(:all) do
|
|
16
|
+
TeamCity.reset
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Get requests
|
|
20
|
+
describe 'GET', :vcr do
|
|
21
|
+
|
|
22
|
+
describe '.buildtypes' do
|
|
23
|
+
|
|
24
|
+
it 'should fetch all the buildtypes' do
|
|
25
|
+
@tc.buildtypes.size.should eq(3)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe '.buildtype' do
|
|
31
|
+
|
|
32
|
+
it 'should fetch the details of a buildtype by id' do
|
|
33
|
+
@tc.buildtype(id: 'bt2').id.should eq('bt2')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'should raise an error if the buildtype does not exist' do
|
|
37
|
+
expect { @tc.buildtype(id: 'missing') }.to raise_error
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'should raise an error if an id is not provided' do
|
|
41
|
+
expect { @tc.buildtype }.to raise_error
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe '.buildtype_state' do
|
|
46
|
+
it 'should fetch the state of the buildtype' do
|
|
47
|
+
pending "bug in rest api plugin"
|
|
48
|
+
@tc.buildtype_state(id: 'bt2')
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe '.buildtype_settings' do
|
|
53
|
+
it 'should fetch the settings for a given buildtype' do
|
|
54
|
+
@tc.buildtype_settings(id: 'bt2').should have_at_least(1).items
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'should return an array' do
|
|
58
|
+
@tc.buildtype_settings(id: 'bt2').should be_kind_of(Array)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe '.buildtype_template' do
|
|
63
|
+
it 'should return the attributes of the associated template' do
|
|
64
|
+
@tc.buildtype_template(id: 'bt2').id.should_not be_nil
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it 'should return nil if the buildtype is not associated with a template' do
|
|
68
|
+
@tc.buildtype_template(id: 'bt3').should be_nil
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'should raise an exception if the response is not due to a template not assigned' do
|
|
72
|
+
expect { @tc.buildtype_template(id: 'bt500').should be_nil }.to raise_error
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
[
|
|
77
|
+
:parameters,
|
|
78
|
+
:steps,
|
|
79
|
+
:features,
|
|
80
|
+
:triggers,
|
|
81
|
+
:agent_requirements,
|
|
82
|
+
:snapshot_dependencies,
|
|
83
|
+
:artifact_dependencies,
|
|
84
|
+
:vcs_root_entries
|
|
85
|
+
].each do |type|
|
|
86
|
+
describe ".buildtype_#{type}" do
|
|
87
|
+
|
|
88
|
+
before(:each) do
|
|
89
|
+
@method_name = "buildtype_#{type}"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should fetch the build configuration #{type} for a buildtype" do
|
|
93
|
+
@tc.send(@method_name, id: 'bt2').should have_at_least(1).items
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it 'should return an array' do
|
|
97
|
+
@tc.send(@method_name, id: 'bt2').should be_kind_of(Array)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it "should return nil if there are no #{type} defined" do
|
|
101
|
+
@tc.send(@method_name, id: 'bt4').should be_nil
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'Projects' do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@tc = TeamCity
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
before(:all) do
|
|
10
|
+
TeamCity.configure do |config|
|
|
11
|
+
config.endpoint = 'http://localhost:8111/guestAuth/app/rest/7.0/'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
after(:all) do
|
|
16
|
+
TeamCity.reset
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Get requests
|
|
20
|
+
describe 'GET', :vcr do
|
|
21
|
+
|
|
22
|
+
describe '.projects' do
|
|
23
|
+
|
|
24
|
+
it 'should fetch projects' do
|
|
25
|
+
@tc.projects.should_not be_nil
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'should return nil if there are no projects' do
|
|
29
|
+
@tc.projects.should be_nil
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '.project' do
|
|
34
|
+
|
|
35
|
+
it 'should fetch a single project by id' do
|
|
36
|
+
@tc.project(id: 'project2').should_not be_nil
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'should raise an error if the project does not exist' do
|
|
40
|
+
expect { @tc.project(id: 'missing') }.to raise_error
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should raise an error if an id is not provided' do
|
|
44
|
+
expect { @tc.project }.to raise_error
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe '.project_buildtypes' do
|
|
49
|
+
|
|
50
|
+
it 'should fetch all the buildTypes for a project' do
|
|
51
|
+
bts = @tc.project_buildtypes(id: 'project2')
|
|
52
|
+
bts.each do |bt|
|
|
53
|
+
bt.projectId.should eq('project2')
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'should return nil if the project does not have any build build types' do
|
|
58
|
+
bts = @tc.project_buildtypes(id: 'project5')
|
|
59
|
+
bts.should be_nil
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe '.project_parameters' do
|
|
64
|
+
it 'should fetch all the paramters for a given project' do
|
|
65
|
+
parameters = @tc.project_parameters(id: 'project2')
|
|
66
|
+
parameters.size.should eq(3)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'should return nil if there are no parameters defined for a project' do
|
|
70
|
+
parameters = @tc.project_parameters(id: 'project3')
|
|
71
|
+
parameters.should be_nil
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'should raise an error if the project does not exist' do
|
|
75
|
+
expect { @tc.project_parameters(id: 'missing')}
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
|
2
|
+
|
|
3
|
+
describe TeamCity::Client do
|
|
4
|
+
it "should connect using the endpoint configuration" do
|
|
5
|
+
client = TeamCity::Client.new
|
|
6
|
+
endpoint = URI.parse(client.endpoint)
|
|
7
|
+
connection = client.send(:connection).build_url(nil).to_s
|
|
8
|
+
(connection + '/').should == endpoint.to_s
|
|
9
|
+
end
|
|
10
|
+
end
|