build_eval 0.0.4 → 0.0.5
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 +4 -4
- data/lib/build_eval/error.rb +0 -4
- data/lib/build_eval/http.rb +1 -5
- data/lib/build_eval/monitor/base.rb +2 -6
- data/lib/build_eval/monitor/composite.rb +0 -4
- data/lib/build_eval/monitor/server.rb +0 -3
- data/lib/build_eval/result/build_result.rb +2 -8
- data/lib/build_eval/result/composite_result.rb +0 -4
- data/lib/build_eval/result/server_result.rb +0 -4
- data/lib/build_eval/result/status.rb +9 -17
- data/lib/build_eval/server/cruise_control_response.rb +2 -6
- data/lib/build_eval/server/decorator.rb +3 -9
- data/lib/build_eval/server/invalid_selector_error.rb +0 -4
- data/lib/build_eval/server/jenkins.rb +0 -4
- data/lib/build_eval/server/team_city.rb +2 -6
- data/lib/build_eval/server/travis_com.rb +23 -0
- data/lib/build_eval/server/travis_org.rb +22 -0
- data/lib/build_eval/version.rb +1 -1
- data/lib/build_eval.rb +7 -11
- data/spec/lib/build_eval/error_spec.rb +4 -8
- data/spec/lib/build_eval/http_shared_context.rb +2 -4
- data/spec/lib/build_eval/http_spec.rb +30 -50
- data/spec/lib/build_eval/monitor/base_spec.rb +3 -7
- data/spec/lib/build_eval/monitor/composite_spec.rb +5 -9
- data/spec/lib/build_eval/monitor/server_spec.rb +6 -10
- data/spec/lib/build_eval/result/build_result_spec.rb +19 -30
- data/spec/lib/build_eval/result/composite_result_spec.rb +10 -18
- data/spec/lib/build_eval/result/server_result_spec.rb +14 -26
- data/spec/lib/build_eval/result/status_spec.rb +35 -73
- data/spec/lib/build_eval/server/cruise_control_response_spec.rb +33 -41
- data/spec/lib/build_eval/server/decorator_spec.rb +17 -31
- data/spec/lib/build_eval/server/invalid_selector_error_spec.rb +7 -11
- data/spec/lib/build_eval/server/jenkins_integration_spec.rb +10 -15
- data/spec/lib/build_eval/server/jenkins_spec.rb +17 -24
- data/spec/lib/build_eval/server/server_shared_examples.rb +3 -7
- data/spec/lib/build_eval/server/team_city_integration_spec.rb +18 -27
- data/spec/lib/build_eval/server/team_city_spec.rb +13 -20
- data/spec/lib/build_eval/server/travis_com_spec.rb +91 -0
- data/spec/lib/build_eval/server/travis_org_spec.rb +71 -0
- data/spec/lib/build_eval_smoke_spec.rb +11 -10
- data/spec/lib/build_eval_spec.rb +8 -16
- data/spec/spec_helper.rb +4 -4
- metadata +33 -18
- data/lib/build_eval/server/travis.rb +0 -23
- data/spec/lib/build_eval/server/travis_integration_spec.rb +0 -53
- data/spec/lib/build_eval/server/travis_spec.rb +0 -70
@@ -1,20 +1,17 @@
|
|
1
1
|
describe BuildEval::Server::CruiseControlResponse do
|
2
|
-
|
3
|
-
let(:raw_response) { double("RawResponse", body: response_body) }
|
2
|
+
let(:raw_response) { double('RawResponse', body: response_body) }
|
4
3
|
|
5
4
|
let(:cruise_control_response) { described_class.new(raw_response) }
|
6
5
|
|
7
|
-
describe
|
8
|
-
|
9
|
-
let(:build_name) { "some_build_name" }
|
6
|
+
describe '#parse_result' do
|
7
|
+
let(:build_name) { 'some_build_name' }
|
10
8
|
let(:response_build_name) { build_name }
|
11
|
-
let(:project_selector) {
|
9
|
+
let(:project_selector) { '//Project[2]' }
|
12
10
|
|
13
11
|
subject { cruise_control_response.parse_result(project_selector) }
|
14
12
|
|
15
|
-
context
|
16
|
-
|
17
|
-
let(:latest_build_status) { "Success" }
|
13
|
+
context 'when the response is successful, containing projects' do
|
14
|
+
let(:latest_build_status) { 'Success' }
|
18
15
|
let(:response_body) do
|
19
16
|
<<-RESPONSE
|
20
17
|
<Projects>
|
@@ -25,31 +22,26 @@ describe BuildEval::Server::CruiseControlResponse do
|
|
25
22
|
RESPONSE
|
26
23
|
end
|
27
24
|
|
28
|
-
context
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
it "creates a build result with the build name from the response" do
|
25
|
+
context 'and the selector matches a project' do
|
26
|
+
context 'and the build name in the response is not a path' do
|
27
|
+
it 'creates a build result with the build name from the response' do
|
33
28
|
expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(build_name: build_name))
|
34
29
|
|
35
30
|
subject
|
36
31
|
end
|
37
|
-
|
38
32
|
end
|
39
33
|
|
40
|
-
context
|
41
|
-
|
34
|
+
context 'and the build name in the response is a path' do
|
42
35
|
let(:response_build_name) { "some/path/to/#{build_name}" }
|
43
36
|
|
44
|
-
it
|
37
|
+
it 'creates a build result with the build name from the response with the path omitted' do
|
45
38
|
expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(build_name: build_name))
|
46
39
|
|
47
40
|
subject
|
48
41
|
end
|
49
|
-
|
50
42
|
end
|
51
43
|
|
52
|
-
it
|
44
|
+
it 'creates a build result containing the latest build status' do
|
53
45
|
expect(BuildEval::Result::BuildResult).to(
|
54
46
|
receive(:create).with(hash_including(status_name: latest_build_status))
|
55
47
|
)
|
@@ -57,59 +49,59 @@ describe BuildEval::Server::CruiseControlResponse do
|
|
57
49
|
subject
|
58
50
|
end
|
59
51
|
|
60
|
-
it
|
52
|
+
it 'returns the created result' do
|
61
53
|
build_result = instance_double(BuildEval::Result::BuildResult)
|
62
54
|
allow(BuildEval::Result::BuildResult).to receive(:create).and_return(build_result)
|
63
55
|
|
64
56
|
expect(subject).to eql(build_result)
|
65
57
|
end
|
66
|
-
|
67
58
|
end
|
68
59
|
|
69
|
-
context
|
70
|
-
|
71
|
-
let(:
|
72
|
-
let(:error) { "an error" }
|
60
|
+
context 'and the selector does not match a project' do
|
61
|
+
let(:project_selector) { 'does_not_match' }
|
62
|
+
let(:error) { 'an error' }
|
73
63
|
|
74
64
|
before(:example) { allow(BuildEval::Server::InvalidSelectorError).to receive(:new).and_return(error) }
|
75
65
|
|
76
|
-
it
|
66
|
+
it 'creates an invalid selector error' do
|
77
67
|
expect(BuildEval::Server::InvalidSelectorError).to(
|
78
68
|
receive(:new).with(raw_response, project_selector).and_return(error)
|
79
69
|
)
|
80
70
|
|
81
|
-
|
71
|
+
begin
|
72
|
+
subject
|
73
|
+
rescue
|
74
|
+
Exception
|
75
|
+
end
|
82
76
|
end
|
83
77
|
|
84
|
-
it
|
78
|
+
it 'raises the error' do
|
85
79
|
expect { subject }.to raise_error(error)
|
86
80
|
end
|
87
|
-
|
88
81
|
end
|
89
|
-
|
90
82
|
end
|
91
83
|
|
92
|
-
context
|
93
|
-
|
94
|
-
let(:
|
95
|
-
let(:error) { "an error" }
|
84
|
+
context 'when the response is in error' do
|
85
|
+
let(:response_body) { { 'file' => 'not found' }.to_json }
|
86
|
+
let(:error) { 'an error' }
|
96
87
|
|
97
88
|
before(:example) { allow(BuildEval::Server::InvalidSelectorError).to receive(:new).and_return(error) }
|
98
89
|
|
99
|
-
it
|
90
|
+
it 'creates an invalid selector error' do
|
100
91
|
expect(BuildEval::Server::InvalidSelectorError).to(
|
101
92
|
receive(:new).with(raw_response, project_selector).and_return(error)
|
102
93
|
)
|
103
94
|
|
104
|
-
|
95
|
+
begin
|
96
|
+
subject
|
97
|
+
rescue
|
98
|
+
Exception
|
99
|
+
end
|
105
100
|
end
|
106
101
|
|
107
|
-
it
|
102
|
+
it 'raises an invalid selector error' do
|
108
103
|
expect { subject }.to raise_error(error)
|
109
104
|
end
|
110
|
-
|
111
105
|
end
|
112
|
-
|
113
106
|
end
|
114
|
-
|
115
107
|
end
|
@@ -1,97 +1,83 @@
|
|
1
1
|
describe BuildEval::Server::Decorator do
|
2
|
-
|
3
|
-
let(:server) { double("BuildEval::Server::Server") }
|
2
|
+
let(:server) { double('BuildEval::Server::Server') }
|
4
3
|
|
5
4
|
let(:decorator) { described_class.new(server) }
|
6
5
|
|
7
|
-
describe
|
8
|
-
|
9
|
-
let(:build_name) { "some build name" }
|
6
|
+
describe '#build_result' do
|
7
|
+
let(:build_name) { 'some build name' }
|
10
8
|
|
11
9
|
subject { decorator.build_result(build_name) }
|
12
10
|
|
13
|
-
it
|
11
|
+
it 'delegates to the decorated server' do
|
14
12
|
expect(server).to receive(:build_result).with(build_name)
|
15
13
|
|
16
14
|
subject
|
17
15
|
end
|
18
16
|
|
19
|
-
context
|
20
|
-
|
17
|
+
context 'when the decorated server returns a result' do
|
21
18
|
let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
|
22
19
|
|
23
20
|
before(:example) { allow(server).to receive(:build_result).and_return(build_result) }
|
24
21
|
|
25
|
-
it
|
22
|
+
it 'returns the result' do
|
26
23
|
expect(subject).to eql(build_result)
|
27
24
|
end
|
28
|
-
|
29
25
|
end
|
30
26
|
|
31
|
-
context
|
27
|
+
context 'when the decorated server raises an error' do
|
28
|
+
before(:example) { allow(server).to receive(:build_result).and_raise('Forced error') }
|
32
29
|
|
33
|
-
|
34
|
-
|
35
|
-
it "creates an indeterminate result" do
|
30
|
+
it 'creates an indeterminate result' do
|
36
31
|
expect(BuildEval::Result::BuildResult).to receive(:indeterminate).with(build_name)
|
37
32
|
|
38
33
|
subject
|
39
34
|
end
|
40
35
|
|
41
|
-
it
|
36
|
+
it 'returns the indeterminate result' do
|
42
37
|
indeterminate_result = instance_double(BuildEval::Result::BuildResult)
|
43
38
|
allow(BuildEval::Result::BuildResult).to receive(:indeterminate).and_return(indeterminate_result)
|
44
39
|
|
45
40
|
expect(subject).to eql(indeterminate_result)
|
46
41
|
end
|
47
|
-
|
48
42
|
end
|
49
|
-
|
50
43
|
end
|
51
44
|
|
52
|
-
describe
|
53
|
-
|
45
|
+
describe '#monitor' do
|
54
46
|
let(:build_names) { (1..3).map { |i| "build##{i}" } }
|
55
47
|
|
56
48
|
subject { decorator.monitor(*build_names) }
|
57
49
|
|
58
|
-
it
|
50
|
+
it 'creates a server monitor for the decorated server' do
|
59
51
|
expect(BuildEval::Monitor::Server).to receive(:new).with(hash_including(server: server))
|
60
52
|
|
61
53
|
subject
|
62
54
|
end
|
63
55
|
|
64
|
-
it
|
56
|
+
it 'returns the server monitor' do
|
65
57
|
monitor = instance_double(BuildEval::Monitor::Server)
|
66
58
|
allow(BuildEval::Monitor::Server).to receive(:new).and_return(monitor)
|
67
59
|
|
68
60
|
expect(subject).to eql(monitor)
|
69
61
|
end
|
70
62
|
|
71
|
-
context
|
72
|
-
|
63
|
+
context 'when an array of build names is provided' do
|
73
64
|
subject { decorator.monitor(build_names) }
|
74
65
|
|
75
|
-
it
|
66
|
+
it 'creates a server monitor for the provided build names' do
|
76
67
|
expect(BuildEval::Monitor::Server).to receive(:new).with(hash_including(build_names: build_names))
|
77
68
|
|
78
69
|
subject
|
79
70
|
end
|
80
|
-
|
81
71
|
end
|
82
72
|
|
83
|
-
context
|
84
|
-
|
73
|
+
context 'when variable argument list of build names is provided' do
|
85
74
|
subject { decorator.monitor(*build_names) }
|
86
75
|
|
87
|
-
it
|
76
|
+
it 'creates a server monitor for the provided build names' do
|
88
77
|
expect(BuildEval::Monitor::Server).to receive(:new).with(hash_including(build_names: build_names))
|
89
78
|
|
90
79
|
subject
|
91
80
|
end
|
92
|
-
|
93
81
|
end
|
94
|
-
|
95
82
|
end
|
96
|
-
|
97
83
|
end
|
@@ -1,27 +1,23 @@
|
|
1
1
|
describe BuildEval::Server::InvalidSelectorError do
|
2
|
-
|
3
|
-
let(:
|
4
|
-
let(:
|
5
|
-
let(:selector) { "some/selector" }
|
2
|
+
let(:response_message) { 'Some response message' }
|
3
|
+
let(:response) { double('HttpResponse', message: response_message) }
|
4
|
+
let(:selector) { 'some/selector' }
|
6
5
|
|
7
6
|
let(:error) { described_class.new(response, selector) }
|
8
7
|
|
9
|
-
describe
|
10
|
-
|
8
|
+
describe '#message' do
|
11
9
|
subject { error.message }
|
12
10
|
|
13
|
-
it
|
11
|
+
it 'indicates the selector was not matched' do
|
14
12
|
expect(subject).to match(/response did not match selector/i)
|
15
13
|
end
|
16
14
|
|
17
|
-
it
|
15
|
+
it 'contains a message describing the response' do
|
18
16
|
expect(subject).to include(response_message)
|
19
17
|
end
|
20
18
|
|
21
|
-
it
|
19
|
+
it 'contains the selector that was invalid' do
|
22
20
|
expect(subject).to include(selector)
|
23
21
|
end
|
24
|
-
|
25
22
|
end
|
26
|
-
|
27
23
|
end
|
@@ -1,22 +1,20 @@
|
|
1
|
-
describe BuildEval::Server::Jenkins,
|
2
|
-
include_context
|
1
|
+
describe BuildEval::Server::Jenkins, 'integrating with a response parser', integration: true do
|
2
|
+
include_context 'stubbed http interactions'
|
3
3
|
|
4
|
-
let(:uri) {
|
4
|
+
let(:uri) { 'https://some.jenkins.server' }
|
5
5
|
|
6
6
|
let(:jenkins) { described_class.new(uri: uri) }
|
7
7
|
|
8
|
-
describe
|
9
|
-
|
10
|
-
let(:build_name) { "some_build_name" }
|
8
|
+
describe '#build_result' do
|
9
|
+
let(:build_name) { 'some_build_name' }
|
11
10
|
let(:response) { instance_double(Net::HTTPResponse, body: response_body) }
|
12
11
|
|
13
12
|
subject { jenkins.build_result(build_name) }
|
14
13
|
|
15
14
|
before(:example) { allow(http).to receive(:get).and_return(response) }
|
16
15
|
|
17
|
-
context
|
18
|
-
|
19
|
-
let(:latest_build_status) { "Failure" }
|
16
|
+
context 'when the server responds successfully with build results' do
|
17
|
+
let(:latest_build_status) { 'Failure' }
|
20
18
|
let(:response_body) do
|
21
19
|
<<-RESPONSE
|
22
20
|
<Projects>
|
@@ -27,26 +25,23 @@ describe BuildEval::Server::Jenkins, "integrating with a response parser", integ
|
|
27
25
|
RESPONSE
|
28
26
|
end
|
29
27
|
|
30
|
-
it
|
28
|
+
it 'creates a build result containing the build name' do
|
31
29
|
expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(build_name: build_name))
|
32
30
|
|
33
31
|
subject
|
34
32
|
end
|
35
33
|
|
36
|
-
it
|
34
|
+
it 'creates a build result containing the latest build status' do
|
37
35
|
expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: latest_build_status))
|
38
36
|
subject
|
39
37
|
end
|
40
38
|
|
41
|
-
it
|
39
|
+
it 'returns the created result' do
|
42
40
|
build_result = instance_double(BuildEval::Result::BuildResult)
|
43
41
|
allow(BuildEval::Result::BuildResult).to receive(:create).and_return(build_result)
|
44
42
|
|
45
43
|
expect(subject).to eql(build_result)
|
46
44
|
end
|
47
|
-
|
48
45
|
end
|
49
|
-
|
50
46
|
end
|
51
|
-
|
52
47
|
end
|
@@ -1,20 +1,17 @@
|
|
1
1
|
describe BuildEval::Server::Jenkins do
|
2
|
-
include_context
|
2
|
+
include_context 'stubbed http interactions'
|
3
3
|
|
4
|
-
let(:uri) {
|
4
|
+
let(:uri) { 'https://some.jenkins.server' }
|
5
5
|
let(:constructor_args) { { uri: uri } }
|
6
6
|
|
7
7
|
let(:jenkins_server) { described_class.new(constructor_args) }
|
8
8
|
|
9
|
-
it_behaves_like
|
10
|
-
|
9
|
+
it_behaves_like 'a continuous integration server' do
|
11
10
|
let(:server) { jenkins_server }
|
12
|
-
|
13
11
|
end
|
14
12
|
|
15
|
-
describe
|
16
|
-
|
17
|
-
let(:build_name) { "some_build_name" }
|
13
|
+
describe '#build_result' do
|
14
|
+
let(:build_name) { 'some_build_name' }
|
18
15
|
let(:response) { instance_double(Net::HTTPResponse) }
|
19
16
|
let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
|
20
17
|
let(:cruise_control_response) do
|
@@ -29,42 +26,38 @@ describe BuildEval::Server::Jenkins do
|
|
29
26
|
allow(cruise_control_response).to receive(:parse_result).and_return(build_result)
|
30
27
|
end
|
31
28
|
|
32
|
-
it
|
29
|
+
it 'issues a GET request for the build' do
|
33
30
|
expect(http).to receive(:get).with("#{uri}/cc.xml")
|
34
31
|
|
35
32
|
subject
|
36
33
|
end
|
37
34
|
|
38
|
-
it
|
35
|
+
it 'creates a Cruise Control response containing the GET request response' do
|
39
36
|
expect(BuildEval::Server::CruiseControlResponse).to receive(:new).with(response)
|
40
37
|
|
41
38
|
subject
|
42
39
|
end
|
43
40
|
|
44
|
-
it
|
41
|
+
it 'parses the Cruise Control response to return the project with a matching build name' do
|
45
42
|
expect(cruise_control_response).to receive(:parse_result).with(a_string_including(build_name))
|
46
43
|
|
47
44
|
subject
|
48
45
|
end
|
49
46
|
|
50
|
-
it
|
47
|
+
it 'returns the parsed build result' do
|
51
48
|
expect(subject).to eql(build_result)
|
52
49
|
end
|
53
|
-
|
54
50
|
end
|
55
51
|
|
56
|
-
|
57
|
-
|
58
|
-
subject { jenkins_server.to_s }
|
59
|
-
|
60
|
-
it "returns a string indicating it is a Jenkins server" do
|
61
|
-
expect(subject).to include("Jenkins server")
|
62
|
-
end
|
63
|
-
|
64
|
-
it "returns a string containing the username" do
|
65
|
-
expect(subject).to include(uri)
|
66
|
-
end
|
52
|
+
describe '#to_s' do
|
53
|
+
subject { jenkins_server.to_s }
|
67
54
|
|
55
|
+
it 'returns a string indicating it is a Jenkins server' do
|
56
|
+
expect(subject).to include('Jenkins server')
|
68
57
|
end
|
69
58
|
|
59
|
+
it 'returns a string containing the username' do
|
60
|
+
expect(subject).to include(uri)
|
61
|
+
end
|
62
|
+
end
|
70
63
|
end
|
@@ -1,15 +1,11 @@
|
|
1
|
-
shared_examples_for
|
2
|
-
|
3
|
-
describe "constructor" do
|
4
|
-
|
1
|
+
shared_examples_for 'a continuous integration server' do
|
2
|
+
describe 'constructor' do
|
5
3
|
subject { server }
|
6
4
|
|
7
|
-
it
|
5
|
+
it 'creates a http object with any provided http configuration options' do
|
8
6
|
expect(BuildEval::Http).to receive(:new).with(constructor_args)
|
9
7
|
|
10
8
|
subject
|
11
9
|
end
|
12
|
-
|
13
10
|
end
|
14
|
-
|
15
11
|
end
|
@@ -1,13 +1,12 @@
|
|
1
|
-
describe BuildEval::Server::TeamCity,
|
2
|
-
include_context
|
1
|
+
describe BuildEval::Server::TeamCity, 'integrating with a response parser', integration: true do
|
2
|
+
include_context 'stubbed http interactions'
|
3
3
|
|
4
|
-
let(:uri) {
|
4
|
+
let(:uri) { 'https://some.teamcity.server' }
|
5
5
|
|
6
6
|
let(:team_city_server) { described_class.new(uri: uri) }
|
7
7
|
|
8
|
-
describe
|
9
|
-
|
10
|
-
let(:build_name) { "some_build_name" }
|
8
|
+
describe '#build_result' do
|
9
|
+
let(:build_name) { 'some_build_name' }
|
11
10
|
let(:response_message) { nil }
|
12
11
|
let(:response_body) { nil }
|
13
12
|
let(:response) { instance_double(Net::HTTPResponse, message: response_message, body: response_body) }
|
@@ -16,10 +15,9 @@ describe BuildEval::Server::TeamCity, "integrating with a response parser", inte
|
|
16
15
|
|
17
16
|
before(:example) { allow(http).to receive(:get).and_return(response) }
|
18
17
|
|
19
|
-
context
|
20
|
-
|
21
|
-
let(:
|
22
|
-
let(:response_message) { "OK" }
|
18
|
+
context 'when the server responds with build results' do
|
19
|
+
let(:latest_build_status) { 'FAILED' }
|
20
|
+
let(:response_message) { 'OK' }
|
23
21
|
let(:response_body) do
|
24
22
|
<<-RESPONSE
|
25
23
|
<builds count="3" href="/httpAuth/app/rest/buildTypes/#{build_name}/builds/" nextHref="/httpAuth/app/rest/buildTypes/#{build_name}/builds/?count=3&start=3">
|
@@ -30,13 +28,13 @@ describe BuildEval::Server::TeamCity, "integrating with a response parser", inte
|
|
30
28
|
RESPONSE
|
31
29
|
end
|
32
30
|
|
33
|
-
it
|
31
|
+
it 'creates a build result containing the build name' do
|
34
32
|
expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(build_name: build_name))
|
35
33
|
|
36
34
|
subject
|
37
35
|
end
|
38
36
|
|
39
|
-
it
|
37
|
+
it 'creates a build result containing the latest build status' do
|
40
38
|
expect(BuildEval::Result::BuildResult).to(
|
41
39
|
receive(:create).with(hash_including(status_name: latest_build_status))
|
42
40
|
)
|
@@ -44,29 +42,25 @@ describe BuildEval::Server::TeamCity, "integrating with a response parser", inte
|
|
44
42
|
subject
|
45
43
|
end
|
46
44
|
|
47
|
-
it
|
45
|
+
it 'returns the created result' do
|
48
46
|
build_result = instance_double(BuildEval::Result::BuildResult)
|
49
47
|
allow(BuildEval::Result::BuildResult).to receive(:create).and_return(build_result)
|
50
48
|
|
51
49
|
expect(subject).to eql(build_result)
|
52
50
|
end
|
53
|
-
|
54
51
|
end
|
55
52
|
|
56
|
-
context
|
53
|
+
context 'when the server authentication request fails' do
|
54
|
+
let(:response_message) { 'Unauthorized' }
|
55
|
+
let(:response_body) { 'Incorrect username or password' }
|
57
56
|
|
58
|
-
|
59
|
-
let(:response_body) { "Incorrect username or password" }
|
60
|
-
|
61
|
-
it "raises an error" do
|
57
|
+
it 'raises an error' do
|
62
58
|
expect { subject }.to raise_error(/Unauthorized/)
|
63
59
|
end
|
64
|
-
|
65
60
|
end
|
66
61
|
|
67
|
-
context
|
68
|
-
|
69
|
-
let(:response_message) { "Not Found" }
|
62
|
+
context 'when the build is not found' do
|
63
|
+
let(:response_message) { 'Not Found' }
|
70
64
|
let(:response_body) do
|
71
65
|
<<-BODY
|
72
66
|
Error has occurred during request processing (Not Found).
|
@@ -74,12 +68,9 @@ describe BuildEval::Server::TeamCity, "integrating with a response parser", inte
|
|
74
68
|
BODY
|
75
69
|
end
|
76
70
|
|
77
|
-
it
|
71
|
+
it 'raises an error' do
|
78
72
|
expect { subject }.to raise_error(/Not Found/)
|
79
73
|
end
|
80
|
-
|
81
74
|
end
|
82
|
-
|
83
75
|
end
|
84
|
-
|
85
76
|
end
|
@@ -1,22 +1,19 @@
|
|
1
1
|
describe BuildEval::Server::TeamCity do
|
2
|
-
include_context
|
2
|
+
include_context 'stubbed http interactions'
|
3
3
|
|
4
|
-
let(:uri) {
|
5
|
-
let(:username) {
|
6
|
-
let(:password) {
|
4
|
+
let(:uri) { 'https://some.teamcity.server' }
|
5
|
+
let(:username) { 'some_username' }
|
6
|
+
let(:password) { 'some_password' }
|
7
7
|
let(:constructor_args) { { uri: uri, username: username, password: password } }
|
8
8
|
|
9
9
|
let(:team_city_server) { described_class.new(constructor_args) }
|
10
10
|
|
11
|
-
it_behaves_like
|
12
|
-
|
11
|
+
it_behaves_like 'a continuous integration server' do
|
13
12
|
let(:server) { team_city_server }
|
14
|
-
|
15
13
|
end
|
16
14
|
|
17
|
-
describe
|
18
|
-
|
19
|
-
let(:build_name) { "some_build_name" }
|
15
|
+
describe '#build_result' do
|
16
|
+
let(:build_name) { 'some_build_name' }
|
20
17
|
let(:response_body) do
|
21
18
|
<<-RESPONSE
|
22
19
|
<builds count="3" href="/httpAuth/app/rest/buildTypes/#{build_name}/builds/" nextHref="/httpAuth/app/rest/buildTypes/#{build_name}/builds/?count=3&start=3">
|
@@ -24,32 +21,28 @@ describe BuildEval::Server::TeamCity do
|
|
24
21
|
</builds>
|
25
22
|
RESPONSE
|
26
23
|
end
|
27
|
-
let(:response)
|
24
|
+
let(:response) { instance_double(Net::HTTPResponse, body: response_body) }
|
28
25
|
|
29
26
|
subject { team_city_server.build_result(build_name) }
|
30
27
|
|
31
28
|
before(:example) { allow(http).to receive(:get).and_return(response) }
|
32
29
|
|
33
|
-
it
|
30
|
+
it 'issues a GET request for the build' do
|
34
31
|
expect(http).to receive(:get).with("#{uri}/httpAuth/app/rest/buildTypes/id:#{build_name}/builds")
|
35
32
|
|
36
33
|
subject
|
37
34
|
end
|
38
|
-
|
39
35
|
end
|
40
36
|
|
41
|
-
describe
|
42
|
-
|
37
|
+
describe '#to_s' do
|
43
38
|
subject { team_city_server.to_s }
|
44
39
|
|
45
|
-
it
|
46
|
-
expect(subject).to include(
|
40
|
+
it 'returns a string indicating it is a TeamCity server' do
|
41
|
+
expect(subject).to include('TeamCity')
|
47
42
|
end
|
48
43
|
|
49
|
-
it
|
44
|
+
it 'returns a string containing the uri to the server' do
|
50
45
|
expect(subject).to include(uri)
|
51
46
|
end
|
52
|
-
|
53
47
|
end
|
54
|
-
|
55
48
|
end
|