build_eval 0.0.14 → 0.0.15
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 +8 -8
- data/lib/build_eval/monitor/server.rb +6 -3
- data/lib/build_eval/result/build_result.rb +15 -7
- data/lib/build_eval/result/status.rb +7 -6
- data/lib/build_eval/server/decorator.rb +5 -5
- data/lib/build_eval/server/jenkins.rb +2 -2
- data/lib/build_eval/server/team_city.rb +4 -3
- data/lib/build_eval/server/travis.rb +5 -3
- data/lib/build_eval/server/travis_pro.rb +6 -3
- data/lib/build_eval/travis/session/factory.rb +31 -0
- data/lib/build_eval/travis/session/pool.rb +44 -0
- data/lib/build_eval/travis/session/session.rb +18 -0
- data/lib/build_eval/travis/session.rb +14 -0
- data/lib/build_eval/travis.rb +9 -3
- data/lib/build_eval/version.rb +1 -1
- data/lib/build_eval.rb +4 -1
- data/spec/lib/build_eval/monitor/composite_spec.rb +1 -0
- data/spec/lib/build_eval/monitor/server_spec.rb +14 -6
- data/spec/lib/build_eval/result/build_result_spec.rb +42 -13
- data/spec/lib/build_eval/result/status_spec.rb +19 -6
- data/spec/lib/build_eval/server/decorator_spec.rb +21 -14
- data/spec/lib/build_eval/server/jenkins_integration_spec.rb +4 -3
- data/spec/lib/build_eval/server/jenkins_spec.rb +2 -1
- data/spec/lib/build_eval/server/team_city_integration_spec.rb +2 -1
- data/spec/lib/build_eval/server/team_city_spec.rb +2 -1
- data/spec/lib/build_eval/server/travis_pro_spec.rb +11 -6
- data/spec/lib/build_eval/server/travis_spec.rb +11 -6
- data/spec/lib/build_eval/travis/session/factory_spec.rb +85 -0
- data/spec/lib/build_eval/travis/session/pool_spec.rb +89 -0
- data/spec/lib/build_eval/travis/session/session_spec.rb +24 -0
- data/spec/lib/build_eval/travis/session_spec.rb +65 -0
- data/spec/lib/build_eval/travis_spec.rb +75 -50
- data/spec/lib/build_eval_smoke_spec.rb +4 -3
- metadata +18 -9
- data/lib/build_eval/travis/session_factory.rb +0 -38
- data/spec/lib/build_eval/travis/session_factory_spec.rb +0 -105
@@ -13,13 +13,14 @@ describe BuildEval::Server::Jenkins do
|
|
13
13
|
describe "#build_result" do
|
14
14
|
|
15
15
|
let(:build_name) { "some_build_name" }
|
16
|
+
let(:branch_name) { nil }
|
16
17
|
let(:response) { instance_double(Net::HTTPResponse) }
|
17
18
|
let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
|
18
19
|
let(:cruise_control_response) do
|
19
20
|
instance_double(BuildEval::Server::CruiseControlResponse, parse_result: build_result)
|
20
21
|
end
|
21
22
|
|
22
|
-
subject { jenkins_server.build_result(build_name) }
|
23
|
+
subject { jenkins_server.build_result(build_name, branch_name) }
|
23
24
|
|
24
25
|
before(:example) do
|
25
26
|
allow(http).to receive(:get).and_return(response)
|
@@ -8,11 +8,12 @@ describe BuildEval::Server::TeamCity, "integrating with a response parser", inte
|
|
8
8
|
describe "#build_result" do
|
9
9
|
|
10
10
|
let(:build_name) { "some_build_name" }
|
11
|
+
let(:branch_name) { nil }
|
11
12
|
let(:response_message) { nil }
|
12
13
|
let(:response_body) { nil }
|
13
14
|
let(:response) { instance_double(Net::HTTPResponse, message: response_message, body: response_body) }
|
14
15
|
|
15
|
-
subject { team_city_server.build_result(build_name) }
|
16
|
+
subject { team_city_server.build_result(build_name, branch_name) }
|
16
17
|
|
17
18
|
before(:example) { allow(http).to receive(:get).and_return(response) }
|
18
19
|
|
@@ -15,6 +15,7 @@ describe BuildEval::Server::TeamCity do
|
|
15
15
|
describe "#build_result" do
|
16
16
|
|
17
17
|
let(:build_name) { "some_build_name" }
|
18
|
+
let(:branch_name) { nil }
|
18
19
|
let(:response_body) do
|
19
20
|
<<-RESPONSE
|
20
21
|
<builds count="3" href="/httpAuth/app/rest/buildTypes/#{build_name}/builds/" nextHref="/httpAuth/app/rest/buildTypes/#{build_name}/builds/?count=3&start=3">
|
@@ -24,7 +25,7 @@ describe BuildEval::Server::TeamCity do
|
|
24
25
|
end
|
25
26
|
let(:response) { instance_double(Net::HTTPResponse, body: response_body) }
|
26
27
|
|
27
|
-
subject { team_city_server.build_result(build_name) }
|
28
|
+
subject { team_city_server.build_result(build_name, branch_name) }
|
28
29
|
|
29
30
|
before(:example) { allow(http).to receive(:get).and_return(response) }
|
30
31
|
|
@@ -9,19 +9,20 @@ describe BuildEval::Server::TravisPro do
|
|
9
9
|
describe "#build_result" do
|
10
10
|
|
11
11
|
let(:build_name) { "some_build_name" }
|
12
|
+
let(:branch_name) { "some_branch_name" }
|
12
13
|
let(:last_build_status) { "Unknown" }
|
13
14
|
let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
|
14
15
|
|
15
|
-
subject { travis_pro_server.build_result(build_name) }
|
16
|
+
subject { travis_pro_server.build_result(build_name, branch_name) }
|
16
17
|
|
17
18
|
before(:example) do
|
18
19
|
allow(BuildEval::Travis).to receive(:last_build_status).and_return(last_build_status)
|
19
20
|
allow(BuildEval::Result::BuildResult).to receive(:create).and_return(build_result)
|
20
21
|
end
|
21
22
|
|
22
|
-
it "retrieves the last build status from Travis using the provided GitHub token" do
|
23
|
+
it "retrieves the last build status for the provided branch from Travis using the provided GitHub token" do
|
23
24
|
expect(BuildEval::Travis).to(
|
24
|
-
receive(:last_build_status).with(hash_including(github_token: github_token))
|
25
|
+
receive(:last_build_status).with(hash_including(github_token: github_token, branch: branch_name))
|
25
26
|
)
|
26
27
|
|
27
28
|
subject
|
@@ -43,10 +44,14 @@ describe BuildEval::Server::TravisPro do
|
|
43
44
|
subject
|
44
45
|
end
|
45
46
|
|
47
|
+
it "creates a build result whose branch name is the provided branch" do
|
48
|
+
expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(branch_name: branch_name))
|
49
|
+
|
50
|
+
subject
|
51
|
+
end
|
52
|
+
|
46
53
|
it "creates a build result whose status is the status the last build status" do
|
47
|
-
expect(BuildEval::Result::BuildResult).to(
|
48
|
-
receive(:create).with(hash_including(status_name: last_build_status))
|
49
|
-
)
|
54
|
+
expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: last_build_status))
|
50
55
|
|
51
56
|
subject
|
52
57
|
end
|
@@ -8,19 +8,20 @@ describe BuildEval::Server::Travis do
|
|
8
8
|
describe "#build_result" do
|
9
9
|
|
10
10
|
let(:build_name) { "some_build_name" }
|
11
|
+
let(:branch_name) { "some_branch_name" }
|
11
12
|
let(:last_build_status) { "Failure" }
|
12
13
|
let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
|
13
14
|
|
14
|
-
subject { travis_server.build_result(build_name) }
|
15
|
+
subject { travis_server.build_result(build_name, branch_name) }
|
15
16
|
|
16
17
|
before(:example) do
|
17
18
|
allow(BuildEval::Travis).to receive(:last_build_status).and_return(last_build_status)
|
18
19
|
allow(BuildEval::Result::BuildResult).to receive(:create).and_return(build_result)
|
19
20
|
end
|
20
21
|
|
21
|
-
it "retrieves the last build status from Travis for the users build" do
|
22
|
+
it "retrieves the last build status for the provided branch from Travis for the users build" do
|
22
23
|
expect(BuildEval::Travis).to(
|
23
|
-
receive(:last_build_status).with(
|
24
|
+
receive(:last_build_status).with(repository_path: "#{username}/#{build_name}", branch: branch_name)
|
24
25
|
)
|
25
26
|
|
26
27
|
subject
|
@@ -34,10 +35,14 @@ describe BuildEval::Server::Travis do
|
|
34
35
|
subject
|
35
36
|
end
|
36
37
|
|
38
|
+
it "creates a build result whose branch name is the provided branch" do
|
39
|
+
expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(branch_name: branch_name))
|
40
|
+
|
41
|
+
subject
|
42
|
+
end
|
43
|
+
|
37
44
|
it "creates a build result whose status is the status the last build status" do
|
38
|
-
expect(BuildEval::Result::BuildResult).to(
|
39
|
-
receive(:create).with(hash_including(status_name: last_build_status))
|
40
|
-
)
|
45
|
+
expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: last_build_status))
|
41
46
|
|
42
47
|
subject
|
43
48
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
describe BuildEval::Travis::Session::Factory do
|
2
|
+
|
3
|
+
describe "::create" do
|
4
|
+
|
5
|
+
let(:github_token) { nil }
|
6
|
+
let(:travis_session) { instance_double(::Travis::Client::Session) }
|
7
|
+
|
8
|
+
subject { described_class.create(github_token) }
|
9
|
+
|
10
|
+
before(:example) { allow(::Travis::Client::Session).to receive(:new).and_return(travis_session) }
|
11
|
+
|
12
|
+
shared_examples_for "a factory method creating a new session" do
|
13
|
+
|
14
|
+
it "creates a Travis session with empty SSL settings to avoid using local security certificates" do
|
15
|
+
expect(::Travis::Client::Session).to receive(:new).with(hash_including(ssl: {}))
|
16
|
+
|
17
|
+
subject
|
18
|
+
end
|
19
|
+
|
20
|
+
it "creates a BuildEval session with the Travis session" do
|
21
|
+
expect(BuildEval::Travis::Session::Session).to receive(:new).with(travis_session, anything)
|
22
|
+
|
23
|
+
subject
|
24
|
+
end
|
25
|
+
|
26
|
+
it "creates a BuildEval session with the GitHub token" do
|
27
|
+
expect(BuildEval::Travis::Session::Session).to receive(:new).with(anything, github_token)
|
28
|
+
|
29
|
+
subject
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns the BuildEval session" do
|
33
|
+
build_eval_session = instance_double(BuildEval::Travis::Session::Session)
|
34
|
+
allow(BuildEval::Travis::Session::Session).to receive(:new).and_return(build_eval_session)
|
35
|
+
|
36
|
+
expect(subject).to equal(build_eval_session)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when a non-nil GitHub token is provided" do
|
42
|
+
|
43
|
+
let(:github_token) { "SOMEGITHUBAUTHTOKEN" }
|
44
|
+
|
45
|
+
before(:example) { allow(travis_session).to receive(:github_auth) }
|
46
|
+
|
47
|
+
it_behaves_like "a factory method creating a new session"
|
48
|
+
|
49
|
+
it "creates a Travis session connecting to the Travis Pro site" do
|
50
|
+
expect(::Travis::Client::Session).to receive(:new).with(hash_including(uri: ::Travis::Client::PRO_URI))
|
51
|
+
|
52
|
+
subject
|
53
|
+
end
|
54
|
+
|
55
|
+
it "logs-in using the provided GitHub token via the session" do
|
56
|
+
expect(travis_session).to receive(:github_auth).with(github_token)
|
57
|
+
|
58
|
+
subject
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
context "when a nil GitHub token is provided" do
|
64
|
+
|
65
|
+
let(:github_token) { nil }
|
66
|
+
|
67
|
+
it_behaves_like "a factory method creating a new session"
|
68
|
+
|
69
|
+
it "creates a Travis session connecting to the Travis Org site" do
|
70
|
+
expect(::Travis::Client::Session).to receive(:new).with(hash_including(uri: ::Travis::Client::ORG_URI))
|
71
|
+
|
72
|
+
subject
|
73
|
+
end
|
74
|
+
|
75
|
+
it "does not log-in" do
|
76
|
+
expect(travis_session).to_not receive(:github_auth)
|
77
|
+
|
78
|
+
subject
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
describe BuildEval::Travis::Session::Pool do
|
2
|
+
|
3
|
+
let(:github_token) { "SOMEGITHUBAUTHTOKEN" }
|
4
|
+
|
5
|
+
let(:session) { instance_double(BuildEval::Travis::Session::Session, github_token: github_token, clear_cache: nil) }
|
6
|
+
|
7
|
+
before(:example) { allow(BuildEval::Travis::Session::Factory).to receive(:create).and_return(session) }
|
8
|
+
after(:example) { described_class.clear }
|
9
|
+
|
10
|
+
describe "::get" do
|
11
|
+
|
12
|
+
subject { get_session }
|
13
|
+
|
14
|
+
context "when a session for the GitHub token has not been retrieved previously" do
|
15
|
+
|
16
|
+
it "creates a session for the token" do
|
17
|
+
expect(BuildEval::Travis::Session::Factory).to receive(:create).with(github_token)
|
18
|
+
|
19
|
+
subject
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns the session" do
|
23
|
+
expect(subject).to eql(session)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when a session for the GitHub token has been retrieved and released" do
|
29
|
+
|
30
|
+
before(:example) do
|
31
|
+
get_session
|
32
|
+
release_session
|
33
|
+
end
|
34
|
+
|
35
|
+
it "does not create a new session" do
|
36
|
+
expect(BuildEval::Travis::Session::Factory).to_not receive(:create)
|
37
|
+
|
38
|
+
subject
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns the previously created session" do
|
42
|
+
expect(subject).to eql(session)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
context "when a session for the GitHub token has been retrieved but not released" do
|
48
|
+
|
49
|
+
let(:new_session) { instance_double(BuildEval::Travis::Session::Session) }
|
50
|
+
|
51
|
+
before(:example) { get_session }
|
52
|
+
|
53
|
+
it "creates a session for the token" do
|
54
|
+
expect(BuildEval::Travis::Session::Factory).to receive(:create).with(github_token)
|
55
|
+
|
56
|
+
subject
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns the newly created session" do
|
60
|
+
allow(BuildEval::Travis::Session::Factory).to receive(:create).and_return(new_session)
|
61
|
+
|
62
|
+
expect(subject).to eql(new_session)
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "::release" do
|
70
|
+
|
71
|
+
subject { release_session }
|
72
|
+
|
73
|
+
it "clears the sessions cache" do
|
74
|
+
expect(session).to receive(:clear_cache)
|
75
|
+
|
76
|
+
subject
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
def release_session
|
82
|
+
described_class.release(session)
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_session
|
86
|
+
described_class.get(github_token)
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
describe BuildEval::Travis::Session::Session do
|
2
|
+
|
3
|
+
let(:travis_session) { ::Travis::Client::Session.new(uri: "some/uri", ssl: {}) }
|
4
|
+
let(:github_token) { "SOMEGITHUBAUTHTOKEN" }
|
5
|
+
|
6
|
+
let(:session) { described_class.new(travis_session, github_token) }
|
7
|
+
|
8
|
+
describe "#github_token" do
|
9
|
+
|
10
|
+
subject { session.github_token }
|
11
|
+
|
12
|
+
it "returns the provided token" do
|
13
|
+
expect(subject).to eql(github_token)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
it "delegates all other methods to the provided Travis session" do
|
19
|
+
expect(travis_session).to receive(:clear_cache)
|
20
|
+
|
21
|
+
session.clear_cache
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
describe BuildEval::Travis::Session do
|
2
|
+
|
3
|
+
describe "::open" do
|
4
|
+
|
5
|
+
let(:github_token) { "SOMEGITHIBTOKEN" }
|
6
|
+
let(:block) { lambda { |_session| "Some block" } }
|
7
|
+
|
8
|
+
let(:session) { instance_double(BuildEval::Travis::Session::Session) }
|
9
|
+
|
10
|
+
subject { described_class.open(github_token, &block) }
|
11
|
+
|
12
|
+
before(:example) do
|
13
|
+
allow(BuildEval::Travis::Session::Pool).to receive(:get).and_return(session)
|
14
|
+
allow(BuildEval::Travis::Session::Pool).to receive(:release)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "obtains a session for the provided GitHib token from the pool" do
|
18
|
+
expect(BuildEval::Travis::Session::Pool).to receive(:get).with(github_token)
|
19
|
+
|
20
|
+
subject
|
21
|
+
end
|
22
|
+
|
23
|
+
it "yields the session to the provided block" do
|
24
|
+
expect { |block| described_class.open(github_token, &block) }.to yield_with_args(session)
|
25
|
+
|
26
|
+
subject
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when an error is raised on yield" do
|
30
|
+
|
31
|
+
let(:error) { RuntimeError.new("Forced error") }
|
32
|
+
|
33
|
+
let(:block) { lambda { |_session| raise error } }
|
34
|
+
|
35
|
+
it "returns the session to the pool" do
|
36
|
+
expect(BuildEval::Travis::Session::Pool).to receive(:release).with(session)
|
37
|
+
|
38
|
+
subject rescue nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it "propogates the error" do
|
42
|
+
expect { subject }.to raise_error(error)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
context "when an error is not raised on yield" do
|
48
|
+
|
49
|
+
let(:block) { lambda { |_session| "Block result" } }
|
50
|
+
|
51
|
+
it "returns the session to the pool" do
|
52
|
+
expect(BuildEval::Travis::Session::Pool).to receive(:release).with(session)
|
53
|
+
|
54
|
+
subject
|
55
|
+
end
|
56
|
+
|
57
|
+
it "returns the last expression from the block" do
|
58
|
+
expect(subject).to eql("Block result")
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -3,23 +3,39 @@ describe BuildEval::Travis do
|
|
3
3
|
describe "::last_build_status" do
|
4
4
|
|
5
5
|
let(:repository_path) { "some/repository_path" }
|
6
|
+
let(:branch) { nil }
|
6
7
|
let(:optional_args) { {} }
|
8
|
+
let(:args) { { repository_path: repository_path, branch: branch }.merge(optional_args) }
|
7
9
|
|
8
|
-
let(:
|
9
|
-
|
10
|
-
|
11
|
-
let(:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
let(:build_color) { "red" }
|
11
|
+
let(:build) { instance_double(::Travis::Client::Build, color: build_color) }
|
12
|
+
let(:travis_repository) { instance_double(::Travis::Client::Repository, last_build: build) }
|
13
|
+
let(:travis_session) { instance_double(::Travis::Client::Session, repo: travis_repository) }
|
14
|
+
|
15
|
+
subject { described_class.last_build_status(args) }
|
16
|
+
|
17
|
+
before(:example) { allow(BuildEval::Travis::Session).to receive(:open).and_yield(travis_session) }
|
18
|
+
|
19
|
+
shared_examples_for "a Travis build whose status is determined" do
|
20
|
+
|
21
|
+
{
|
22
|
+
"green" => "Success",
|
23
|
+
"yellow" => "Building",
|
24
|
+
"red" => "Failure"
|
25
|
+
}.each do |color, status|
|
17
26
|
|
18
|
-
|
27
|
+
context "when the builds color is #{color}" do
|
28
|
+
|
29
|
+
let(:build_color) { color }
|
30
|
+
|
31
|
+
it "returns '#{status}'" do
|
32
|
+
expect(subject).to eql(status)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
19
38
|
|
20
|
-
before(:example) do
|
21
|
-
allow(BuildEval::Travis::SessionFactory).to receive(:create).and_return(travis_session)
|
22
|
-
allow(last_finished_build).to receive(:passed?).and_return(last_finished_build_passed_flag)
|
23
39
|
end
|
24
40
|
|
25
41
|
context "when a Github authentication token is provided" do
|
@@ -27,8 +43,8 @@ describe BuildEval::Travis do
|
|
27
43
|
let(:github_token) { "SOMEGITHUBAUTHTOKEN" }
|
28
44
|
let(:optional_args) { { github_token: github_token } }
|
29
45
|
|
30
|
-
it "
|
31
|
-
expect(BuildEval::Travis::
|
46
|
+
it "opens a Travis session using the token" do
|
47
|
+
expect(BuildEval::Travis::Session).to receive(:open).with(github_token)
|
32
48
|
|
33
49
|
subject
|
34
50
|
end
|
@@ -39,75 +55,84 @@ describe BuildEval::Travis do
|
|
39
55
|
|
40
56
|
let(:optional_args) { {} }
|
41
57
|
|
42
|
-
it "
|
43
|
-
expect(BuildEval::Travis::
|
58
|
+
it "opens a Travis session for a nil token" do
|
59
|
+
expect(BuildEval::Travis::Session).to receive(:open).with(nil)
|
44
60
|
|
45
61
|
subject
|
46
62
|
end
|
47
63
|
|
48
64
|
end
|
49
65
|
|
66
|
+
context "when an error occurs opening a session" do
|
50
67
|
|
51
|
-
|
52
|
-
|
68
|
+
before(:example) do
|
69
|
+
allow(BuildEval::Travis::Session).to(
|
70
|
+
receive(:open).and_raise(::Travis::Client::Error.new("Forced error"))
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "returns 'Unknown'" do
|
75
|
+
expect(subject).to eql("Unknown")
|
76
|
+
end
|
53
77
|
|
54
|
-
subject
|
55
78
|
end
|
56
79
|
|
57
|
-
it "retrieves the
|
58
|
-
expect(
|
80
|
+
it "retrieves the Travis repository for the provided repository path from the session" do
|
81
|
+
expect(travis_session).to receive(:repo).with(repository_path)
|
59
82
|
|
60
83
|
subject
|
61
84
|
end
|
62
85
|
|
63
|
-
|
64
|
-
expect(last_finished_build).to receive(:passed?)
|
86
|
+
context "when a branch is provided" do
|
65
87
|
|
66
|
-
|
67
|
-
|
88
|
+
let(:branch) { "some_branch" }
|
89
|
+
|
90
|
+
before(:example) { allow(travis_repository).to receive(:branch).and_return(build) }
|
68
91
|
|
69
|
-
|
92
|
+
it_behaves_like "a Travis build whose status is determined"
|
70
93
|
|
71
|
-
|
94
|
+
it "retrieves the last build for the branch" do
|
95
|
+
expect(travis_repository).to receive(:branch).with(branch)
|
72
96
|
|
73
|
-
|
74
|
-
expect(subject).to eql("Success")
|
97
|
+
subject
|
75
98
|
end
|
76
99
|
|
77
|
-
|
100
|
+
context "when an error occurs retrieving the last build" do
|
78
101
|
|
79
|
-
|
102
|
+
before(:example) do
|
103
|
+
allow(travis_repository).to receive(:branch).and_raise(::Travis::Client::Error.new("Forced error"))
|
104
|
+
end
|
80
105
|
|
81
|
-
|
106
|
+
it "returns 'Unknown'" do
|
107
|
+
expect(subject).to eql("Unknown")
|
108
|
+
end
|
82
109
|
|
83
|
-
it "returns 'Failure'" do
|
84
|
-
expect(subject).to eql("Failure")
|
85
110
|
end
|
86
111
|
|
87
112
|
end
|
88
113
|
|
89
|
-
context "when
|
114
|
+
context "when a branch is not provided" do
|
90
115
|
|
91
|
-
|
92
|
-
allow(BuildEval::Travis::SessionFactory).to(
|
93
|
-
receive(:create).and_raise(::Travis::Client::Error.new("Forced error"))
|
94
|
-
)
|
95
|
-
end
|
116
|
+
let(:branch) { nil }
|
96
117
|
|
97
|
-
|
98
|
-
|
118
|
+
it_behaves_like "a Travis build whose status is determined"
|
119
|
+
|
120
|
+
it "retrieves the last build repository" do
|
121
|
+
expect(travis_repository).to receive(:last_build)
|
122
|
+
|
123
|
+
subject
|
99
124
|
end
|
100
125
|
|
101
|
-
|
126
|
+
context "when an error occurs retrieving the last build" do
|
102
127
|
|
103
|
-
|
128
|
+
before(:example) do
|
129
|
+
allow(travis_repository).to receive(:last_build).and_raise(::Travis::Client::Error.new("Forced error"))
|
130
|
+
end
|
104
131
|
|
105
|
-
|
106
|
-
|
107
|
-
|
132
|
+
it "returns 'Unknown'" do
|
133
|
+
expect(subject).to eql("Unknown")
|
134
|
+
end
|
108
135
|
|
109
|
-
it "returns 'Unknown'" do
|
110
|
-
expect(subject).to eql("Unknown")
|
111
136
|
end
|
112
137
|
|
113
138
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
describe BuildEval, "integrating with a real CI server", smoke: true do
|
2
2
|
|
3
|
-
let(:
|
3
|
+
let(:build_configurations) { BuildEval::Examples::Travis.build_configurations }
|
4
4
|
|
5
5
|
let(:monitor) { BuildEval::Examples::Travis.monitor }
|
6
6
|
|
@@ -9,6 +9,7 @@ describe BuildEval, "integrating with a real CI server", smoke: true do
|
|
9
9
|
let(:tolerated_statuses) do
|
10
10
|
[
|
11
11
|
BuildEval::Result::Status::SUCCESS,
|
12
|
+
BuildEval::Result::Status::BUILDING,
|
12
13
|
BuildEval::Result::Status::UNKNOWN,
|
13
14
|
BuildEval::Result::Status::FAILURE,
|
14
15
|
BuildEval::Result::Status::ERROR
|
@@ -22,8 +23,8 @@ describe BuildEval, "integrating with a real CI server", smoke: true do
|
|
22
23
|
end
|
23
24
|
|
24
25
|
it "describes the builds and their individual status" do
|
25
|
-
|
26
|
-
expect(subject.to_s).to match(/#{
|
26
|
+
build_configurations.each do |build_configuration|
|
27
|
+
expect(subject.to_s).to match(/#{build_configuration} -> (#{tolerated_statuses.map(&:to_s).join("|")})/)
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|