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.
- checksums.yaml +13 -5
- data/lib/build_eval/error.rb +4 -0
- data/lib/build_eval/http.rb +5 -1
- data/lib/build_eval/monitor/base.rb +4 -0
- data/lib/build_eval/monitor/composite.rb +4 -0
- data/lib/build_eval/monitor/server.rb +4 -0
- data/lib/build_eval/result/build_result.rb +6 -0
- data/lib/build_eval/result/composite_result.rb +4 -0
- data/lib/build_eval/result/server_result.rb +4 -0
- data/lib/build_eval/result/status.rb +11 -5
- data/lib/build_eval/server/cruise_control_response.rb +6 -2
- data/lib/build_eval/server/decorator.rb +4 -0
- data/lib/build_eval/server/invalid_selector_error.rb +4 -0
- data/lib/build_eval/server/jenkins.rb +4 -0
- data/lib/build_eval/server/team_city.rb +6 -2
- data/lib/build_eval/server/{travis_org.rb → travis.rb} +7 -4
- data/lib/build_eval/server/{travis_com.rb → travis_pro.rb} +9 -5
- data/lib/build_eval/version.rb +1 -1
- data/lib/build_eval.rb +7 -2
- data/spec/lib/build_eval/error_spec.rb +8 -4
- data/spec/lib/build_eval/http_shared_context.rb +3 -1
- data/spec/lib/build_eval/http_spec.rb +48 -29
- data/spec/lib/build_eval/monitor/base_spec.rb +7 -3
- data/spec/lib/build_eval/monitor/composite_spec.rb +8 -5
- data/spec/lib/build_eval/monitor/server_spec.rb +10 -6
- data/spec/lib/build_eval/result/build_result_spec.rb +29 -19
- data/spec/lib/build_eval/result/composite_result_spec.rb +18 -10
- data/spec/lib/build_eval/result/server_result_spec.rb +25 -13
- data/spec/lib/build_eval/result/status_spec.rb +70 -34
- data/spec/lib/build_eval/server/cruise_control_response_spec.rb +41 -25
- data/spec/lib/build_eval/server/decorator_spec.rb +31 -17
- data/spec/lib/build_eval/server/invalid_selector_error_spec.rb +11 -7
- data/spec/lib/build_eval/server/jenkins_integration_spec.rb +15 -10
- data/spec/lib/build_eval/server/jenkins_spec.rb +18 -13
- data/spec/lib/build_eval/server/server_shared_examples.rb +7 -3
- data/spec/lib/build_eval/server/team_city_integration_spec.rb +28 -19
- data/spec/lib/build_eval/server/team_city_spec.rb +17 -12
- data/spec/lib/build_eval/server/travis_pro_spec.rb +92 -0
- data/spec/lib/build_eval/server/{travis_org_spec.rb → travis_spec.rb} +24 -23
- data/spec/lib/build_eval_smoke_spec.rb +9 -6
- data/spec/lib/build_eval_spec.rb +16 -8
- metadata +92 -91
- data/spec/lib/build_eval/server/travis_com_spec.rb +0 -91
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ODM2MmZjNDRlYmE4NDU0MTA2Mjc0ODUyZWNiYzFiNWI3M2Q2YWFiZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
Nzg4Yjg5NTBkMGYxNWRjZmJiMjk1ODU1YjQ0OGRiNjljYTM0NWE0NQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NWMwNjViYWYyNjNjN2YwNThmNTEwNjc3ODU2YjE2YTlhNTg2ODkzMDJmZDkx
|
10
|
+
MmUzMjM4Y2Y0YjIzZGFlNTBiZDNlMDUyZjg2NGVjZTBiYTI5MWZmMDJkNzQ3
|
11
|
+
YzU2YTI1MTU5ZmQxNjRkOGIxNjQ3ZDdhZjVhNmFjYTdjMjVkZmI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZGVjZDU1Y2VlNmMwMmQ5NmQ0YTdkMDViYjUyNzUzNDU1NzhlNWViNTg2NjU4
|
14
|
+
NzdhYTAxMThkZjk5MjY3NjhlMjRhNTEyZjI1MTAyMGU1ODU0MGIxMmM2MDRh
|
15
|
+
ZmFhNjAzZDNhMTgwNDJiNzMzNWQ4YzU4Mzg1YTdkMmM3ODdjZDQ=
|
data/lib/build_eval/error.rb
CHANGED
data/lib/build_eval/http.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module BuildEval
|
2
|
+
|
2
3
|
class Http
|
4
|
+
|
3
5
|
def initialize(config)
|
4
6
|
@username = config[:username]
|
5
7
|
@password = config[:password]
|
@@ -18,9 +20,11 @@ module BuildEval
|
|
18
20
|
private
|
19
21
|
|
20
22
|
def ssl_options(uri)
|
21
|
-
ssl_options = { use_ssl: uri.scheme ==
|
23
|
+
ssl_options = { use_ssl: uri.scheme == "https" }
|
22
24
|
ssl_options[:ssl_verify_mode] = @ssl_verify_mode if @ssl_verify_mode
|
23
25
|
ssl_options
|
24
26
|
end
|
27
|
+
|
25
28
|
end
|
29
|
+
|
26
30
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module BuildEval
|
2
2
|
module Monitor
|
3
|
+
|
3
4
|
class Composite < BuildEval::Monitor::Base
|
5
|
+
|
4
6
|
def initialize(*monitors)
|
5
7
|
@monitors = monitors
|
6
8
|
end
|
@@ -8,6 +10,8 @@ module BuildEval
|
|
8
10
|
def evaluate
|
9
11
|
BuildEval::Result::CompositeResult.new(@monitors.map(&:evaluate))
|
10
12
|
end
|
13
|
+
|
11
14
|
end
|
15
|
+
|
12
16
|
end
|
13
17
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module BuildEval
|
2
2
|
module Monitor
|
3
|
+
|
3
4
|
class Server < BuildEval::Monitor::Base
|
5
|
+
|
4
6
|
def initialize(args)
|
5
7
|
@server = args[:server]
|
6
8
|
@build_names = args[:build_names]
|
@@ -10,6 +12,8 @@ module BuildEval
|
|
10
12
|
build_results = @build_names.map { |build_name| @server.build_result(build_name) }
|
11
13
|
BuildEval::Result::ServerResult.new(@server, build_results)
|
12
14
|
end
|
15
|
+
|
13
16
|
end
|
17
|
+
|
14
18
|
end
|
15
19
|
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module BuildEval
|
2
2
|
module Result
|
3
|
+
|
3
4
|
class BuildResult
|
5
|
+
|
4
6
|
class << self
|
7
|
+
|
5
8
|
def create(args)
|
6
9
|
new(build_name: args[:build_name], status: BuildEval::Result::Status.find(args[:status_name]))
|
7
10
|
end
|
@@ -9,6 +12,7 @@ module BuildEval
|
|
9
12
|
def indeterminate(build_name)
|
10
13
|
new(build_name: build_name, status: BuildEval::Result::Status::INDETERMINATE)
|
11
14
|
end
|
15
|
+
|
12
16
|
end
|
13
17
|
|
14
18
|
attr_reader :build_name
|
@@ -30,6 +34,8 @@ module BuildEval
|
|
30
34
|
def to_s
|
31
35
|
"#{@build_name}: #{@status}"
|
32
36
|
end
|
37
|
+
|
33
38
|
end
|
39
|
+
|
34
40
|
end
|
35
41
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module BuildEval
|
2
2
|
module Result
|
3
|
+
|
3
4
|
class ServerResult
|
5
|
+
|
4
6
|
def initialize(server, build_results)
|
5
7
|
@server = server
|
6
8
|
@build_results = build_results
|
@@ -17,6 +19,8 @@ module BuildEval
|
|
17
19
|
def to_s
|
18
20
|
"#{@server}: #{@build_results.map(&:to_s).join(", ")}"
|
19
21
|
end
|
22
|
+
|
20
23
|
end
|
24
|
+
|
21
25
|
end
|
22
26
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module BuildEval
|
2
2
|
module Result
|
3
|
+
|
3
4
|
class Status
|
5
|
+
|
4
6
|
private
|
5
7
|
|
6
8
|
def initialize(args)
|
@@ -11,13 +13,14 @@ module BuildEval
|
|
11
13
|
|
12
14
|
public
|
13
15
|
|
14
|
-
SUCCESS = new(severity: 0, symbol: :success!, description:
|
15
|
-
UNKNOWN = new(severity: 1, symbol: :warning!, description:
|
16
|
-
INDETERMINATE = new(severity: 2, symbol: :warning!, description:
|
17
|
-
FAILURE = new(severity: 3, symbol: :failure!, description:
|
18
|
-
ERROR = new(severity: 4, symbol: :failure!, description:
|
16
|
+
SUCCESS = new(severity: 0, symbol: :success!, description: "succeeded")
|
17
|
+
UNKNOWN = new(severity: 1, symbol: :warning!, description: "unknown")
|
18
|
+
INDETERMINATE = new(severity: 2, symbol: :warning!, description: "indeterminate")
|
19
|
+
FAILURE = new(severity: 3, symbol: :failure!, description: "failed")
|
20
|
+
ERROR = new(severity: 4, symbol: :failure!, description: "errored")
|
19
21
|
|
20
22
|
class << self
|
23
|
+
|
21
24
|
def find(name)
|
22
25
|
const_get(name.upcase)
|
23
26
|
rescue NameError
|
@@ -27,6 +30,7 @@ module BuildEval
|
|
27
30
|
def effective_status(statuses)
|
28
31
|
statuses.sort_by(&:severity).last
|
29
32
|
end
|
33
|
+
|
30
34
|
end
|
31
35
|
|
32
36
|
attr_reader :severity
|
@@ -42,6 +46,8 @@ module BuildEval
|
|
42
46
|
def to_s
|
43
47
|
@description
|
44
48
|
end
|
49
|
+
|
45
50
|
end
|
51
|
+
|
46
52
|
end
|
47
53
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module BuildEval
|
2
2
|
module Server
|
3
|
+
|
3
4
|
class CruiseControlResponse
|
5
|
+
|
4
6
|
def initialize(raw_response)
|
5
7
|
@raw_response = raw_response
|
6
8
|
end
|
@@ -9,10 +11,12 @@ module BuildEval
|
|
9
11
|
build_element = Nokogiri::XML(@raw_response.body).xpath(project_selector).first
|
10
12
|
raise BuildEval::Server::InvalidSelectorError.new(@raw_response, project_selector) unless build_element
|
11
13
|
BuildEval::Result::BuildResult.create(
|
12
|
-
build_name: build_element.attribute(
|
13
|
-
status_name: build_element.attribute(
|
14
|
+
build_name: build_element.attribute("name").value.match(%r{[^\/]+$})[0],
|
15
|
+
status_name: build_element.attribute("lastBuildStatus").value
|
14
16
|
)
|
15
17
|
end
|
18
|
+
|
16
19
|
end
|
20
|
+
|
17
21
|
end
|
18
22
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module BuildEval
|
2
2
|
module Server
|
3
|
+
|
3
4
|
class Decorator
|
5
|
+
|
4
6
|
def initialize(delegate)
|
5
7
|
@delegate = delegate
|
6
8
|
end
|
@@ -14,6 +16,8 @@ module BuildEval
|
|
14
16
|
def monitor(*build_names)
|
15
17
|
BuildEval::Monitor::Server.new(server: @delegate, build_names: build_names.flatten)
|
16
18
|
end
|
19
|
+
|
17
20
|
end
|
21
|
+
|
18
22
|
end
|
19
23
|
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module BuildEval
|
2
2
|
module Server
|
3
|
+
|
3
4
|
class InvalidSelectorError < BuildEval::Error
|
5
|
+
|
4
6
|
def initialize(response, selector)
|
5
7
|
super("Build response did not match selector:\nResponse: #{response.message}\nSelector: #{selector}")
|
6
8
|
end
|
9
|
+
|
7
10
|
end
|
11
|
+
|
8
12
|
end
|
9
13
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module BuildEval
|
2
2
|
module Server
|
3
|
+
|
3
4
|
class Jenkins
|
5
|
+
|
4
6
|
def initialize(args)
|
5
7
|
@http = BuildEval::Http.new(args)
|
6
8
|
@base_uri = args[:uri]
|
@@ -14,6 +16,8 @@ module BuildEval
|
|
14
16
|
def to_s
|
15
17
|
"Jenkins server #{@base_uri}"
|
16
18
|
end
|
19
|
+
|
17
20
|
end
|
21
|
+
|
18
22
|
end
|
19
23
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module BuildEval
|
2
2
|
module Server
|
3
|
+
|
3
4
|
class TeamCity
|
5
|
+
|
4
6
|
def initialize(args)
|
5
7
|
@http = BuildEval::Http.new(args)
|
6
8
|
@base_uri = args[:uri]
|
@@ -8,14 +10,16 @@ module BuildEval
|
|
8
10
|
|
9
11
|
def build_result(name)
|
10
12
|
response = @http.get("#{@base_uri}/httpAuth/app/rest/buildTypes/id:#{name}/builds")
|
11
|
-
build_element = Nokogiri::XML(response.body).xpath(
|
13
|
+
build_element = Nokogiri::XML(response.body).xpath("//build").first
|
12
14
|
raise "Unexpected build response: #{response.message}" unless build_element
|
13
|
-
BuildEval::Result::BuildResult.create(build_name: name, status_name: build_element.attribute(
|
15
|
+
BuildEval::Result::BuildResult.create(build_name: name, status_name: build_element.attribute("status").value)
|
14
16
|
end
|
15
17
|
|
16
18
|
def to_s
|
17
19
|
"TeamCity server #{@base_uri}"
|
18
20
|
end
|
21
|
+
|
19
22
|
end
|
23
|
+
|
20
24
|
end
|
21
25
|
end
|
@@ -1,22 +1,25 @@
|
|
1
1
|
module BuildEval
|
2
2
|
module Server
|
3
|
-
|
3
|
+
|
4
|
+
class Travis
|
5
|
+
|
4
6
|
def initialize(args)
|
5
7
|
@username = args[:username]
|
6
8
|
end
|
7
9
|
|
8
10
|
def build_result(name)
|
9
11
|
repo_string = "#{@username}/#{name}"
|
10
|
-
has_failed = Travis::Repository.find(repo_string).last_build.failed?
|
12
|
+
has_failed = ::Travis::Repository.find(repo_string).last_build.failed?
|
11
13
|
BuildEval::Result::BuildResult.create(
|
12
14
|
build_name: repo_string,
|
13
|
-
status_name: has_failed ?
|
15
|
+
status_name: has_failed ? "Failure" : "Success"
|
14
16
|
)
|
15
17
|
end
|
16
18
|
|
17
19
|
def to_s
|
18
|
-
"Travis CI
|
20
|
+
"Travis CI #{@username}"
|
19
21
|
end
|
20
22
|
end
|
23
|
+
|
21
24
|
end
|
22
25
|
end
|
@@ -1,23 +1,27 @@
|
|
1
1
|
module BuildEval
|
2
2
|
module Server
|
3
|
-
|
3
|
+
|
4
|
+
class TravisPro
|
5
|
+
|
4
6
|
def initialize(args)
|
5
7
|
@username = args[:username]
|
6
|
-
Travis::Pro.github_auth(args[:github_token])
|
8
|
+
::Travis::Pro.github_auth(args[:github_token])
|
7
9
|
end
|
8
10
|
|
9
11
|
def build_result(name)
|
10
12
|
repo_string = "#{@username}/#{name}"
|
11
|
-
has_failed = Travis::Pro::Repository.find(repo_string).last_build.failed?
|
13
|
+
has_failed = ::Travis::Pro::Repository.find(repo_string).last_build.failed?
|
12
14
|
BuildEval::Result::BuildResult.create(
|
13
15
|
build_name: repo_string,
|
14
|
-
status_name: has_failed ?
|
16
|
+
status_name: has_failed ? "Failure" : "Success"
|
15
17
|
)
|
16
18
|
end
|
17
19
|
|
18
20
|
def to_s
|
19
|
-
"Travis CI
|
21
|
+
"Travis CI Pro #{@username}"
|
20
22
|
end
|
23
|
+
|
21
24
|
end
|
22
25
|
end
|
26
|
+
|
23
27
|
end
|
data/lib/build_eval/version.rb
CHANGED
data/lib/build_eval.rb
CHANGED
@@ -4,6 +4,7 @@ require 'net/http'
|
|
4
4
|
require 'net/https'
|
5
5
|
require 'travis'
|
6
6
|
require 'travis/tools/github'
|
7
|
+
|
7
8
|
require_relative 'build_eval/error'
|
8
9
|
require_relative 'build_eval/http'
|
9
10
|
require_relative 'build_eval/result/status'
|
@@ -14,15 +15,17 @@ require_relative 'build_eval/server/invalid_selector_error'
|
|
14
15
|
require_relative 'build_eval/server/decorator'
|
15
16
|
require_relative 'build_eval/server/cruise_control_response'
|
16
17
|
require_relative 'build_eval/server/team_city'
|
17
|
-
require_relative 'build_eval/server/
|
18
|
-
require_relative 'build_eval/server/
|
18
|
+
require_relative 'build_eval/server/travis'
|
19
|
+
require_relative 'build_eval/server/travis_pro'
|
19
20
|
require_relative 'build_eval/server/jenkins'
|
20
21
|
require_relative 'build_eval/monitor/base'
|
21
22
|
require_relative 'build_eval/monitor/server'
|
22
23
|
require_relative 'build_eval/monitor/composite'
|
23
24
|
|
24
25
|
module BuildEval
|
26
|
+
|
25
27
|
class << self
|
28
|
+
|
26
29
|
def server(args)
|
27
30
|
type_args = args.clone
|
28
31
|
server_type = type_args.delete(:type)
|
@@ -36,5 +39,7 @@ module BuildEval
|
|
36
39
|
rescue NameError
|
37
40
|
raise "Server type '#{type}' is invalid"
|
38
41
|
end
|
42
|
+
|
39
43
|
end
|
44
|
+
|
40
45
|
end
|
@@ -1,17 +1,21 @@
|
|
1
1
|
describe BuildEval::Error do
|
2
|
-
|
2
|
+
|
3
|
+
let(:message) { "some message" }
|
3
4
|
|
4
5
|
let(:error) { described_class.new(message) }
|
5
6
|
|
6
|
-
it
|
7
|
+
it "is a standard error" do
|
7
8
|
expect(error).to be_a(::StandardError)
|
8
9
|
end
|
9
10
|
|
10
|
-
describe
|
11
|
+
describe "#messsage" do
|
12
|
+
|
11
13
|
subject { error.message }
|
12
14
|
|
13
|
-
it
|
15
|
+
it "returns the provided message" do
|
14
16
|
expect(subject).to eql(message)
|
15
17
|
end
|
18
|
+
|
16
19
|
end
|
20
|
+
|
17
21
|
end
|
@@ -3,80 +3,99 @@ describe BuildEval::Http do
|
|
3
3
|
|
4
4
|
let(:http) { described_class.new(config) }
|
5
5
|
|
6
|
-
shared_examples_for
|
6
|
+
shared_examples_for "a http method returning a response" do
|
7
|
+
|
7
8
|
let(:response_status) { %w(200 OK) }
|
8
|
-
let(:response_body) {
|
9
|
+
let(:response_body) { "Some Response Body" }
|
9
10
|
|
10
|
-
it
|
11
|
+
it "returns a response containing the response body" do
|
11
12
|
expect(subject.body).to eql(response_body)
|
12
13
|
end
|
13
14
|
|
14
|
-
it
|
15
|
-
expect(subject.code).to eql(
|
15
|
+
it "returns a response containing the response status" do
|
16
|
+
expect(subject.code).to eql("200")
|
16
17
|
end
|
17
18
|
|
18
|
-
it
|
19
|
-
expect(subject.message).to eql(
|
19
|
+
it "returns a response containing the response message" do
|
20
|
+
expect(subject.message).to eql("OK")
|
20
21
|
end
|
22
|
+
|
21
23
|
end
|
22
24
|
|
23
|
-
describe
|
24
|
-
|
25
|
-
let(:
|
26
|
-
let(:
|
25
|
+
describe "#get" do
|
26
|
+
|
27
|
+
let(:scheme) { "http" }
|
28
|
+
let(:host) { "a.host" }
|
29
|
+
let(:path) { "some/path" }
|
27
30
|
let(:uri_string) { "#{scheme}://#{host}/#{path}" }
|
28
31
|
|
29
32
|
subject { http.get(uri_string) }
|
30
33
|
|
31
|
-
context
|
34
|
+
context "when the uri is valid" do
|
35
|
+
|
32
36
|
let(:expected_request_uri) { uri_string }
|
33
37
|
|
34
38
|
before(:example) do
|
35
39
|
FakeWeb.register_uri(:get, expected_request_uri, status: response_status, body: response_body)
|
36
40
|
end
|
37
41
|
|
38
|
-
context
|
39
|
-
|
42
|
+
context "and the uri contains a http scheme" do
|
43
|
+
|
44
|
+
let(:scheme) { "http" }
|
45
|
+
|
46
|
+
it_behaves_like "a http method returning a response"
|
40
47
|
|
41
|
-
it_behaves_like 'a http method returning a response'
|
42
48
|
end
|
43
49
|
|
44
|
-
context
|
45
|
-
|
50
|
+
context "and the uri contains a https scheme" do
|
51
|
+
|
52
|
+
let(:scheme) { "https" }
|
53
|
+
|
54
|
+
it_behaves_like "a http method returning a response"
|
46
55
|
|
47
|
-
it_behaves_like 'a http method returning a response'
|
48
56
|
end
|
49
57
|
|
50
|
-
context
|
58
|
+
context "and an ssl verification mode configuration option was established" do
|
59
|
+
|
51
60
|
let(:ssl_verification_mode) { OpenSSL::SSL::VERIFY_NONE }
|
52
61
|
let(:config) { { ssl_verify_mode: ssl_verification_mode } }
|
53
62
|
|
54
|
-
it_behaves_like
|
63
|
+
it_behaves_like "a http method returning a response"
|
64
|
+
|
55
65
|
end
|
56
66
|
|
57
|
-
context
|
58
|
-
|
67
|
+
context "and partial authentication configuration options were established" do
|
68
|
+
|
69
|
+
let(:config) { { username: "some_username" } }
|
70
|
+
|
71
|
+
it_behaves_like "a http method returning a response"
|
59
72
|
|
60
|
-
it_behaves_like 'a http method returning a response'
|
61
73
|
end
|
62
74
|
|
63
|
-
context
|
64
|
-
|
65
|
-
let(:
|
75
|
+
context "and basic authentication configuration options were established" do
|
76
|
+
|
77
|
+
let(:username) { "some_username" }
|
78
|
+
let(:password) { "some_password" }
|
66
79
|
let(:config) { { username: username, password: password } }
|
67
80
|
|
68
81
|
let(:expected_request_uri) { "#{scheme}://#{username}:#{password}@#{host}/#{path}" }
|
69
82
|
|
70
|
-
it_behaves_like
|
83
|
+
it_behaves_like "a http method returning a response"
|
84
|
+
|
71
85
|
end
|
86
|
+
|
72
87
|
end
|
73
88
|
|
74
|
-
context
|
89
|
+
context "when the uri is invalid" do
|
90
|
+
|
75
91
|
before(:example) { FakeWeb.clean_registry }
|
76
92
|
|
77
|
-
it
|
93
|
+
it "raises an error" do
|
78
94
|
expect { subject }.to raise_error(SocketError)
|
79
95
|
end
|
96
|
+
|
80
97
|
end
|
98
|
+
|
81
99
|
end
|
100
|
+
|
82
101
|
end
|
@@ -1,25 +1,29 @@
|
|
1
1
|
describe BuildEval::Monitor::Base do
|
2
|
+
|
2
3
|
class BuildEval::Monitor::TestableBase < BuildEval::Monitor::Base
|
3
4
|
end
|
4
5
|
|
5
6
|
let(:base_monitor) { BuildEval::Monitor::TestableBase.new }
|
6
7
|
|
7
|
-
describe
|
8
|
+
describe "#+" do
|
9
|
+
|
8
10
|
let(:provided_monitor) { instance_double(BuildEval::Monitor::Base) }
|
9
11
|
|
10
12
|
subject { base_monitor + provided_monitor }
|
11
13
|
|
12
|
-
it
|
14
|
+
it "creates a composite monitor combining the monitor with the provided monitor" do
|
13
15
|
expect(BuildEval::Monitor::Composite).to receive(:new).with(base_monitor, provided_monitor)
|
14
16
|
|
15
17
|
subject
|
16
18
|
end
|
17
19
|
|
18
|
-
it
|
20
|
+
it "returns the composite monitor" do
|
19
21
|
composite_monitor = instance_double(BuildEval::Monitor::Composite)
|
20
22
|
allow(BuildEval::Monitor::Composite).to receive(:new).and_return(composite_monitor)
|
21
23
|
|
22
24
|
expect(subject).to eql(composite_monitor)
|
23
25
|
end
|
26
|
+
|
24
27
|
end
|
28
|
+
|
25
29
|
end
|
@@ -3,8 +3,9 @@ describe BuildEval::Monitor::Composite do
|
|
3
3
|
|
4
4
|
let(:composite) { described_class.new(*monitors) }
|
5
5
|
|
6
|
-
describe
|
7
|
-
|
6
|
+
describe "#evaluate" do
|
7
|
+
|
8
|
+
let(:results) { monitors.map { instance_double("BuildEval::Result") } }
|
8
9
|
|
9
10
|
subject { composite.evaluate }
|
10
11
|
|
@@ -12,23 +13,25 @@ describe BuildEval::Monitor::Composite do
|
|
12
13
|
monitors.zip(results) { |monitor, result| allow(monitor).to receive(:evaluate).and_return(result) }
|
13
14
|
end
|
14
15
|
|
15
|
-
it
|
16
|
+
it "delegates to the monitors" do
|
16
17
|
monitors.each { |monitor| expect(monitor).to receive(:evaluate) }
|
17
18
|
|
18
19
|
subject
|
19
20
|
end
|
20
21
|
|
21
|
-
it
|
22
|
+
it "creates a composite result containing the result of each monitor" do
|
22
23
|
expect(BuildEval::Result::CompositeResult).to receive(:new).with(results)
|
23
24
|
|
24
25
|
subject
|
25
26
|
end
|
26
27
|
|
27
|
-
it
|
28
|
+
it "returns the composite result" do
|
28
29
|
composite_result = instance_double(BuildEval::Result::CompositeResult)
|
29
30
|
allow(BuildEval::Result::CompositeResult).to receive(:new).and_return(composite_result)
|
30
31
|
|
31
32
|
expect(subject).to eql(composite_result)
|
32
33
|
end
|
34
|
+
|
33
35
|
end
|
36
|
+
|
34
37
|
end
|