build_eval 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +13 -5
  2. data/lib/build_eval/error.rb +4 -0
  3. data/lib/build_eval/http.rb +5 -1
  4. data/lib/build_eval/monitor/base.rb +4 -0
  5. data/lib/build_eval/monitor/composite.rb +4 -0
  6. data/lib/build_eval/monitor/server.rb +4 -0
  7. data/lib/build_eval/result/build_result.rb +6 -0
  8. data/lib/build_eval/result/composite_result.rb +4 -0
  9. data/lib/build_eval/result/server_result.rb +4 -0
  10. data/lib/build_eval/result/status.rb +11 -5
  11. data/lib/build_eval/server/cruise_control_response.rb +6 -2
  12. data/lib/build_eval/server/decorator.rb +4 -0
  13. data/lib/build_eval/server/invalid_selector_error.rb +4 -0
  14. data/lib/build_eval/server/jenkins.rb +4 -0
  15. data/lib/build_eval/server/team_city.rb +6 -2
  16. data/lib/build_eval/server/{travis_org.rb → travis.rb} +7 -4
  17. data/lib/build_eval/server/{travis_com.rb → travis_pro.rb} +9 -5
  18. data/lib/build_eval/version.rb +1 -1
  19. data/lib/build_eval.rb +7 -2
  20. data/spec/lib/build_eval/error_spec.rb +8 -4
  21. data/spec/lib/build_eval/http_shared_context.rb +3 -1
  22. data/spec/lib/build_eval/http_spec.rb +48 -29
  23. data/spec/lib/build_eval/monitor/base_spec.rb +7 -3
  24. data/spec/lib/build_eval/monitor/composite_spec.rb +8 -5
  25. data/spec/lib/build_eval/monitor/server_spec.rb +10 -6
  26. data/spec/lib/build_eval/result/build_result_spec.rb +29 -19
  27. data/spec/lib/build_eval/result/composite_result_spec.rb +18 -10
  28. data/spec/lib/build_eval/result/server_result_spec.rb +25 -13
  29. data/spec/lib/build_eval/result/status_spec.rb +70 -34
  30. data/spec/lib/build_eval/server/cruise_control_response_spec.rb +41 -25
  31. data/spec/lib/build_eval/server/decorator_spec.rb +31 -17
  32. data/spec/lib/build_eval/server/invalid_selector_error_spec.rb +11 -7
  33. data/spec/lib/build_eval/server/jenkins_integration_spec.rb +15 -10
  34. data/spec/lib/build_eval/server/jenkins_spec.rb +18 -13
  35. data/spec/lib/build_eval/server/server_shared_examples.rb +7 -3
  36. data/spec/lib/build_eval/server/team_city_integration_spec.rb +28 -19
  37. data/spec/lib/build_eval/server/team_city_spec.rb +17 -12
  38. data/spec/lib/build_eval/server/travis_pro_spec.rb +92 -0
  39. data/spec/lib/build_eval/server/{travis_org_spec.rb → travis_spec.rb} +24 -23
  40. data/spec/lib/build_eval_smoke_spec.rb +9 -6
  41. data/spec/lib/build_eval_spec.rb +16 -8
  42. metadata +92 -91
  43. data/spec/lib/build_eval/server/travis_com_spec.rb +0 -91
@@ -1,39 +1,43 @@
1
1
  describe BuildEval::Monitor::Server do
2
- let(:server) { double('BuildEval::Server') }
2
+
3
+ let(:server) { double("BuildEval::Server") }
3
4
  let(:build_names) { (1..3).map { |i| "build##{i}" } }
4
5
 
5
6
  let(:server_monitor) { described_class.new(server: server, build_names: build_names) }
6
7
 
7
- describe '#evaluate' do
8
+ describe "#evaluate" do
9
+
8
10
  let(:results) { build_names.map { instance_double(BuildEval::Result::BuildResult) } }
9
11
 
10
12
  subject { server_monitor.evaluate }
11
13
 
12
14
  before(:example) { allow(server).to receive(:build_result).and_return(*results) }
13
15
 
14
- it 'determines build results for builds of interest' do
16
+ it "determines build results for builds of interest" do
15
17
  build_names.each { |build_name| expect(server).to receive(:build_result).with(build_name) }
16
18
 
17
19
  subject
18
20
  end
19
21
 
20
- it 'composes a server result for the server' do
22
+ it "composes a server result for the server" do
21
23
  expect(BuildEval::Result::ServerResult).to receive(:new).with(server, anything)
22
24
 
23
25
  subject
24
26
  end
25
27
 
26
- it 'composes a server result containing the results' do
28
+ it "composes a server result containing the results" do
27
29
  expect(BuildEval::Result::ServerResult).to receive(:new).with(anything, results)
28
30
 
29
31
  subject
30
32
  end
31
33
 
32
- it 'returns the server result' do
34
+ it "returns the server result" do
33
35
  server_result = instance_double(BuildEval::Result::ServerResult)
34
36
  expect(BuildEval::Result::ServerResult).to receive(:new).and_return(server_result)
35
37
 
36
38
  expect(subject).to eql(server_result)
37
39
  end
40
+
38
41
  end
42
+
39
43
  end
@@ -1,74 +1,84 @@
1
1
  describe BuildEval::Result::BuildResult do
2
- describe '::create' do
3
- let(:build_name) { 'Some build name' }
4
- let(:status_name) { 'SUCCESS' }
2
+
3
+ describe "::create" do
4
+
5
+ let(:build_name) { "Some build name" }
6
+ let(:status_name) { "SUCCESS" }
5
7
 
6
8
  subject { described_class.create(build_name: build_name, status_name: status_name) }
7
9
 
8
- it 'returns a result with the provided build name' do
10
+ it "returns a result with the provided build name" do
9
11
  expect(subject.build_name).to eql(build_name)
10
12
  end
11
13
 
12
- it 'determines the status with the provided status name' do
14
+ it "determines the status with the provided status name" do
13
15
  expect(BuildEval::Result::Status).to receive(:find).with(status_name)
14
16
 
15
17
  subject
16
18
  end
17
19
 
18
- it 'returns a result with the determined status' do
20
+ it "returns a result with the determined status" do
19
21
  status = BuildEval::Result::Status::UNKNOWN
20
22
  allow(BuildEval::Result::Status).to receive(:find).and_return(status)
21
23
 
22
24
  expect(subject.status).to eql(status)
23
25
  end
26
+
24
27
  end
25
28
 
26
- describe '::indeterminate' do
27
- let(:build_name) { 'Some build name' }
29
+ describe "::indeterminate" do
30
+
31
+ let(:build_name) { "Some build name" }
28
32
 
29
33
  subject { described_class.indeterminate(build_name) }
30
34
 
31
- it 'returns a result with the provided build name' do
35
+ it "returns a result with the provided build name" do
32
36
  expect(subject.build_name).to eql(build_name)
33
37
  end
34
38
 
35
- it 'returns a result with an indeterminate status' do
39
+ it "returns a result with an indeterminate status" do
36
40
  expect(subject.status).to eql(BuildEval::Result::Status::INDETERMINATE)
37
41
  end
42
+
38
43
  end
39
44
 
40
- describe '#unsuccessful?' do
45
+ describe "#unsuccessful?" do
46
+
41
47
  let(:status) { instance_double(BuildEval::Result::Status) }
42
- let(:build_result) { described_class.create(build_name: 'some build', status_name: 'some status') }
48
+ let(:build_result) { described_class.create(build_name: "some build", status_name: "some status") }
43
49
 
44
50
  subject { build_result.unsuccessful? }
45
51
 
46
52
  before(:example) { allow(BuildEval::Result::Status).to receive(:find).and_return(status) }
47
53
 
48
- it 'delegates to the underlying status' do
54
+ it "delegates to the underlying status" do
49
55
  allow(status).to receive(:unsuccessful?).and_return(true)
50
56
 
51
57
  expect(subject).to be(true)
52
58
  end
59
+
53
60
  end
54
61
 
55
- describe '#to_s' do
56
- let(:build_name) { 'Some build name' }
57
- let(:status_string_representation) { 'SUCCESS' }
62
+ describe "#to_s" do
63
+
64
+ let(:build_name) { "Some build name" }
65
+ let(:status_string_representation) { "SUCCESS" }
58
66
  let(:status) { instance_double(BuildEval::Result::Status, to_s: status_string_representation) }
59
67
 
60
- let(:build_result) { described_class.create(build_name: build_name, status_name: 'some status') }
68
+ let(:build_result) { described_class.create(build_name: build_name, status_name: "some status") }
61
69
 
62
70
  subject { build_result.to_s }
63
71
 
64
72
  before(:example) { allow(BuildEval::Result::Status).to receive(:find).and_return(status) }
65
73
 
66
- it 'contains the name of the build' do
74
+ it "contains the name of the build" do
67
75
  expect(subject).to include(build_name)
68
76
  end
69
77
 
70
- it 'contains the string representation of the status' do
78
+ it "contains the string representation of the status" do
71
79
  expect(subject).to include(status_string_representation)
72
80
  end
81
+
73
82
  end
83
+
74
84
  end
@@ -1,9 +1,11 @@
1
1
  describe BuildEval::Result::CompositeResult do
2
- let(:results) { (1..2).map { double('BuildEval::Result') } }
2
+
3
+ let(:results) { (1..2).map { double("BuildEval::Result") } }
3
4
 
4
5
  let(:composite_result) { described_class.new(results) }
5
6
 
6
- describe '#status' do
7
+ describe "#status" do
8
+
7
9
  let(:statuses) { results.map { instance_double(BuildEval::Result::Status) } }
8
10
 
9
11
  subject { composite_result.status }
@@ -14,27 +16,29 @@ describe BuildEval::Result::CompositeResult do
14
16
 
15
17
  before(:example) { allow(BuildEval::Result::Status).to receive(:effective_status) }
16
18
 
17
- it 'determines the status of the results' do
19
+ it "determines the status of the results" do
18
20
  results.each { |underlying_array| expect(underlying_array).to receive(:status) }
19
21
 
20
22
  subject
21
23
  end
22
24
 
23
- it 'determines the effective status of the result statuses' do
25
+ it "determines the effective status of the result statuses" do
24
26
  expect(BuildEval::Result::Status).to receive(:effective_status).with(statuses)
25
27
 
26
28
  subject
27
29
  end
28
30
 
29
- it 'returns the effective status' do
31
+ it "returns the effective status" do
30
32
  effective_status = instance_double(BuildEval::Result::Status)
31
33
  allow(BuildEval::Result::Status).to receive(:effective_status).and_return(effective_status)
32
34
 
33
35
  expect(subject).to eql(effective_status)
34
36
  end
37
+
35
38
  end
36
39
 
37
- describe '#unsuccessful' do
40
+ describe "#unsuccessful" do
41
+
38
42
  let(:unsuccessful_builds_array) { results.map { (1..3).map { instance_double(BuildEval::Result::BuildResult) } } }
39
43
 
40
44
  subject { composite_result.unsuccessful }
@@ -45,18 +49,20 @@ describe BuildEval::Result::CompositeResult do
45
49
  end
46
50
  end
47
51
 
48
- it 'determines the unsuccessful builds from the results' do
52
+ it "determines the unsuccessful builds from the results" do
49
53
  results.each { |result| expect(result).to receive(:unsuccessful) }
50
54
 
51
55
  subject
52
56
  end
53
57
 
54
- it 'returns all unsuccessful builds' do
58
+ it "returns all unsuccessful builds" do
55
59
  expect(subject).to eql(unsuccessful_builds_array.flatten)
56
60
  end
61
+
57
62
  end
58
63
 
59
- describe '#to_s' do
64
+ describe "#to_s" do
65
+
60
66
  let(:results_string_representations) { (1..results.length).map { |i| "Result #{i}" } }
61
67
 
62
68
  subject { composite_result.to_s }
@@ -67,10 +73,12 @@ describe BuildEval::Result::CompositeResult do
67
73
  end
68
74
  end
69
75
 
70
- it 'returns a string containing the string representation of each result' do
76
+ it "returns a string containing the string representation of each result" do
71
77
  results_string_representations.each do |string_representation|
72
78
  expect(subject).to include(string_representation)
73
79
  end
74
80
  end
81
+
75
82
  end
83
+
76
84
  end
@@ -1,10 +1,12 @@
1
1
  describe BuildEval::Result::ServerResult do
2
- let(:server) { double('BuildEval::Server') }
2
+
3
+ let(:server) { double("BuildEval::Server") }
3
4
  let(:build_results) { (1..3).map { instance_double(BuildEval::Result::BuildResult) } }
4
5
 
5
6
  let(:server_result) { described_class.new(server, build_results) }
6
7
 
7
- describe '#status' do
8
+ describe "#status" do
9
+
8
10
  let(:statuses) { build_results.map { instance_double(BuildEval::Result::Status) } }
9
11
 
10
12
  subject { server_result.status }
@@ -15,21 +17,23 @@ describe BuildEval::Result::ServerResult do
15
17
  end
16
18
  end
17
19
 
18
- it 'determines the effective status of the build results' do
20
+ it "determines the effective status of the build results" do
19
21
  expect(BuildEval::Result::Status).to receive(:effective_status).with(statuses)
20
22
 
21
23
  subject
22
24
  end
23
25
 
24
- it 'returns the effective status' do
26
+ it "returns the effective status" do
25
27
  status = instance_double(BuildEval::Result::Status)
26
28
  allow(BuildEval::Result::Status).to receive(:effective_status).and_return(status)
27
29
 
28
30
  expect(subject).to be(status)
29
31
  end
32
+
30
33
  end
31
34
 
32
- describe '#unsuccessful' do
35
+ describe "#unsuccessful" do
36
+
33
37
  subject { server_result.unsuccessful }
34
38
 
35
39
  before(:example) do
@@ -38,25 +42,31 @@ describe BuildEval::Result::ServerResult do
38
42
  end
39
43
  end
40
44
 
41
- context 'when some build results are unsuccessful' do
45
+ context "when some build results are unsuccessful" do
46
+
42
47
  let(:unsuccessful_results) { [build_results[0], build_results[2]] }
43
48
 
44
- it 'returns the unsuccessful build results' do
49
+ it "returns the unsuccessful build results" do
45
50
  expect(subject).to eql(unsuccessful_results)
46
51
  end
52
+
47
53
  end
48
54
 
49
- context 'when no build results are unsuccessful' do
55
+ context "when no build results are unsuccessful" do
56
+
50
57
  let(:unsuccessful_results) { [] }
51
58
 
52
- it 'returns an empty array' do
59
+ it "returns an empty array" do
53
60
  expect(subject).to eql([])
54
61
  end
62
+
55
63
  end
64
+
56
65
  end
57
66
 
58
- describe '#to_s' do
59
- let(:server_string_representation) { 'Server description' }
67
+ describe "#to_s" do
68
+
69
+ let(:server_string_representation) { "Server description" }
60
70
  let(:result_string_representations) { build_results.each_with_index.map { |_, i| "Build result ##{i}" } }
61
71
 
62
72
  subject { server_result.to_s }
@@ -69,12 +79,14 @@ describe BuildEval::Result::ServerResult do
69
79
  end
70
80
  end
71
81
 
72
- it 'contains the string representation of the server' do
82
+ it "contains the string representation of the server" do
73
83
  expect(subject).to include(server_string_representation)
74
84
  end
75
85
 
76
- it 'contains the string representation of each result' do
86
+ it "contains the string representation of each result" do
77
87
  result_string_representations.each { |string| expect(subject).to include(string) }
78
88
  end
89
+
79
90
  end
91
+
80
92
  end
@@ -1,44 +1,57 @@
1
1
  describe BuildEval::Result::Status do
2
- describe '::find' do
2
+
3
+ describe "::find" do
4
+
3
5
  subject { described_class.find(name) }
4
6
 
5
- context 'when the name exactly matches a status constant name' do
6
- let(:name) { 'UNKNOWN' }
7
+ context "when the name exactly matches a status constant name" do
8
+
9
+ let(:name) { "UNKNOWN" }
7
10
 
8
- it 'returns the constant' do
11
+ it "returns the constant" do
9
12
  expect(subject).to be(BuildEval::Result::Status::UNKNOWN)
10
13
  end
14
+
11
15
  end
12
16
 
13
- context 'when the name matches a status constant name with different casing' do
14
- let(:name) { 'Success' }
17
+ context "when the name matches a status constant name with different casing" do
18
+
19
+ let(:name) { "Success" }
15
20
 
16
- it 'returns the constant' do
21
+ it "returns the constant" do
17
22
  expect(subject).to be(BuildEval::Result::Status::SUCCESS)
18
23
  end
24
+
19
25
  end
20
26
 
21
- context 'when the name is completely different from a status constant name' do
22
- let(:name) { 'does_not_match' }
27
+ context "when the name is completely different from a status constant name" do
28
+
29
+ let(:name) { "does_not_match" }
23
30
 
24
- it 'raises an error indicating the name is invalid' do
31
+ it "raises an error indicating the name is invalid" do
25
32
  expect { subject }.to raise_error("Build status '#{name}' is invalid")
26
33
  end
34
+
27
35
  end
36
+
28
37
  end
29
38
 
30
- describe '::effective_status' do
39
+ describe "::effective_status" do
40
+
31
41
  subject { described_class.effective_status(statuses) }
32
42
 
33
- context 'when a single status is provided' do
43
+ context "when a single status is provided" do
44
+
34
45
  let(:statuses) { [BuildEval::Result::Status::UNKNOWN] }
35
46
 
36
- it 'returns the status' do
47
+ it "returns the status" do
37
48
  expect(subject).to eql(BuildEval::Result::Status::UNKNOWN)
38
49
  end
50
+
39
51
  end
40
52
 
41
- context 'when the statuses are ordered in ascending severity' do
53
+ context "when the statuses are ordered in ascending severity" do
54
+
42
55
  let(:statuses) do
43
56
  [
44
57
  BuildEval::Result::Status::ERROR,
@@ -49,12 +62,14 @@ describe BuildEval::Result::Status do
49
62
  ]
50
63
  end
51
64
 
52
- it 'returns the most severe status' do
65
+ it "returns the most severe status" do
53
66
  expect(subject).to eql(BuildEval::Result::Status::ERROR)
54
67
  end
68
+
55
69
  end
56
70
 
57
- context 'when the statuses are ordered in descending severity' do
71
+ context "when the statuses are ordered in descending severity" do
72
+
58
73
  let(:statuses) do
59
74
  [
60
75
  BuildEval::Result::Status::SUCCESS,
@@ -65,40 +80,49 @@ describe BuildEval::Result::Status do
65
80
  ]
66
81
  end
67
82
 
68
- it 'returns the most severe status' do
83
+ it "returns the most severe status" do
69
84
  expect(subject).to eql(BuildEval::Result::Status::ERROR)
70
85
  end
86
+
71
87
  end
88
+
72
89
  end
73
90
 
74
- describe '#unsuccessful?' do
91
+ describe "#unsuccessful?" do
92
+
75
93
  subject { status.unsuccessful? }
76
94
 
77
- context 'when the status is SUCCESS' do
95
+ context "when the status is SUCCESS" do
78
96
  let(:status) { BuildEval::Result::Status::SUCCESS }
79
97
 
80
- it 'returns false' do
98
+ it "returns false" do
81
99
  expect(subject).to be(false)
82
100
  end
83
101
  end
84
102
 
85
103
  {
86
- 'UNKNOWN' => BuildEval::Result::Status::UNKNOWN,
87
- 'FAILURE' => BuildEval::Result::Status::FAILURE,
88
- 'ERROR' => BuildEval::Result::Status::ERROR,
89
- 'INDETERMINATE' => BuildEval::Result::Status::INDETERMINATE
104
+ "UNKNOWN" => BuildEval::Result::Status::UNKNOWN,
105
+ "FAILURE" => BuildEval::Result::Status::FAILURE,
106
+ "ERROR" => BuildEval::Result::Status::ERROR,
107
+ "INDETERMINATE" => BuildEval::Result::Status::INDETERMINATE
90
108
  }.each do |name, status|
109
+
91
110
  context "when the status is #{name}" do
111
+
92
112
  let(:status) { status }
93
113
 
94
- it 'returns true' do
114
+ it "returns true" do
95
115
  expect(subject).to be(true)
96
116
  end
117
+
97
118
  end
119
+
98
120
  end
121
+
99
122
  end
100
123
 
101
- describe '#to_sym' do
124
+ describe "#to_sym" do
125
+
102
126
  subject { status.to_sym }
103
127
 
104
128
  {
@@ -108,33 +132,45 @@ describe BuildEval::Result::Status do
108
132
  FAILURE: :failure!,
109
133
  ERROR: :failure!
110
134
  }.each do |name, expected_symbol|
135
+
111
136
  context "when the status is #{name}" do
137
+
112
138
  let(:status) { BuildEval::Result::Status.const_get(name) }
113
139
 
114
- it 'returns success!' do
140
+ it "returns success!" do
115
141
  expect(subject).to eql(expected_symbol)
116
142
  end
143
+
117
144
  end
145
+
118
146
  end
147
+
119
148
  end
120
149
 
121
- describe '#to_s' do
150
+ describe "#to_s" do
151
+
122
152
  subject { status.to_s }
123
153
 
124
154
  {
125
- SUCCESS: 'succeeded',
126
- UNKNOWN: 'unknown',
127
- INDETERMINATE: 'indeterminate',
128
- FAILURE: 'failed',
129
- ERROR: 'errored'
155
+ SUCCESS: "succeeded",
156
+ UNKNOWN: "unknown",
157
+ INDETERMINATE: "indeterminate",
158
+ FAILURE: "failed",
159
+ ERROR: "errored"
130
160
  }.each do |name, expected_string|
161
+
131
162
  context "when the status is #{name}" do
163
+
132
164
  let(:status) { BuildEval::Result::Status.const_get(name) }
133
165
 
134
- it 'returns success!' do
166
+ it "returns success!" do
135
167
  expect(subject).to eql(expected_string)
136
168
  end
169
+
137
170
  end
171
+
138
172
  end
173
+
139
174
  end
175
+
140
176
  end