build_eval 0.0.4 → 0.0.5

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