build_eval 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTJiNTE3NDJkMjUxNWRkN2FmZTMwNjViY2MxNWJjOWEzZmM4YWRjNA==
4
+ N2I3Zjc5OWM0NDBmMTQ1MTM1YjVhODE1OWI3NTk0NzE1NGI0Y2Y3Mg==
5
5
  data.tar.gz: !binary |-
6
- OTBiZjJmOWJiMDBiYjFhZjViMmEyOGIyZWRlMDY5NWIyNjc0NTFhMw==
6
+ NWUyZDEyMzExZDM0NjkwMzY5MWNjNDczNGRkMzg0YTE0OWNlYzcxMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmY2Y2Q3ZmMxYzUzNTkwNGEwNzc2NGYxZGNjODkyNDlhZDIwMzg0YzczODBh
10
- ZDc0YWMyMjEzNzE2YWM3N2JmYmI1ZDhhNjIyMDYwM2NkODdiY2E1MzA5Nzk0
11
- Y2JiZTZhMWQzNDE4NDljMWE3ZGFhZGIwYTM2ZTA3MWNmMjcxMDA=
9
+ NTc3NGQyZmNiZjg0MmFjYzE2NDFkZmQ2OTBhZTc5ZTRhZjI2NTdkMmY5ZThh
10
+ N2NlNDUyODA4ZjgxMzlhMjhjMGU3N2NlNDljMGI0MmI4OGI5YWI3YWM4Y2E1
11
+ MzI1ZDc4YTdiOGNmMjYwMjIyYjU5MDBhOTAzMDBmOWUxNjYxZjU=
12
12
  data.tar.gz: !binary |-
13
- MDM5MmUwN2Q3NGQ5YWJlZDA5ZGYwY2E5NDVkMjc2YmU0NGQzNTQwZDY3N2Ri
14
- MzliZGM3NjRlOWFhM2ZjMTM0ZmFjZTVhNDJkN2NiNWM3OTU3Njk5NmUwMmZm
15
- OWQ0MTg3MmE2ODU3MGQ2Y2Y5MzAwN2RiNWQzMDRhYjc2YzFhNDU=
13
+ MTQzZWEyOWY2NmExZTBiZTkxNDhkOTM2M2EyYmZmOTZhOGYyMzcyMzVmYjgx
14
+ YTgzODM5ODM3YzRmMjE2NDg0NDcxN2NmNDZjZTZjMzA1MGJhZjE3MDEyNjY5
15
+ ZDkwOWIwOTQzYmRhNTZjNWYyMzdhMWE0ZjI2YTRhZTYwZjc5MWE=
@@ -8,18 +8,20 @@ module BuildEval
8
8
  end
9
9
 
10
10
  def build_result(name)
11
- repo_string = "#{@username}/#{name}"
12
- has_failed = ::Travis::Repository.find(repo_string).recent_builds.first.failed?
13
- BuildEval::Result::BuildResult.create(
14
- build_name: repo_string,
15
- status_name: has_failed ? "Failure" : "Success"
16
- )
11
+ build_path = "#{@username}/#{name}"
12
+ BuildEval::Result::BuildResult.create(build_name: build_path, status_name: last_status_name(build_path))
17
13
  end
18
14
 
19
15
  def to_s
20
16
  "Travis CI #{@username}"
21
17
  end
22
18
 
19
+ private
20
+
21
+ def last_status_name(build_path)
22
+ ::Travis::Repository.find(build_path).recent_builds.find(&:finished?).passed? ? "Success" : "Failure"
23
+ end
24
+
23
25
  end
24
26
 
25
27
  end
@@ -9,11 +9,8 @@ module BuildEval
9
9
  end
10
10
 
11
11
  def build_result(name)
12
- repository_path = "#{@username}/#{name}"
13
- BuildEval::Result::BuildResult.create(
14
- build_name: repository_path,
15
- status_name: last_build_failed?(repository_path) ? "Failure" : "Success"
16
- )
12
+ build_path = "#{@username}/#{name}"
13
+ BuildEval::Result::BuildResult.create(build_name: build_path, status_name: last_status_name(build_path))
17
14
  end
18
15
 
19
16
  def to_s
@@ -22,9 +19,9 @@ module BuildEval
22
19
 
23
20
  private
24
21
 
25
- def last_build_failed?(repository_path)
22
+ def last_status_name(build_path)
26
23
  ::Travis::Pro.github_auth(@github_token)
27
- ::Travis::Pro::Repository.find(repository_path).recent_builds.first.failed?
24
+ ::Travis::Pro::Repository.find(build_path).recent_builds.find(&:finished?).passed? ? "Success" : "Failure"
28
25
  end
29
26
 
30
27
  end
@@ -1,3 +1,3 @@
1
1
  module BuildEval
2
- VERSION = "0.0.8".freeze
2
+ VERSION = "0.0.9".freeze
3
3
  end
@@ -14,12 +14,14 @@ describe BuildEval::Server::TravisPro do
14
14
 
15
15
  describe "#build_result" do
16
16
 
17
- let(:build_name) { "some_build_name" }
18
- let(:travis_repository) { instance_double(::Travis::Client::Repository) }
19
- let(:recent_builds) { (1..3).map { instance_double(::Travis::Client::Build) } }
20
- let(:last_build) { recent_builds.first }
21
- let(:last_build_failed_flag) { false }
22
- let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
17
+ let(:build_name) { "some_build_name" }
18
+ let(:travis_repository) { instance_double(::Travis::Client::Repository) }
19
+ let(:recent_builds) do
20
+ (1..3).map { |i| instance_double(::Travis::Client::Build, finished?: i > 1) }
21
+ end
22
+ let(:last_finished_build) { recent_builds[1] }
23
+ let(:last_finished_build_passed_flag) { true }
24
+ let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
23
25
 
24
26
  subject { travis_pro_server.build_result(build_name) }
25
27
 
@@ -27,7 +29,7 @@ describe BuildEval::Server::TravisPro do
27
29
  allow(::Travis::Pro).to receive(:github_auth)
28
30
  allow(::Travis::Pro::Repository).to receive(:find).and_return(travis_repository)
29
31
  allow(travis_repository).to receive(:recent_builds).and_return(recent_builds)
30
- allow(last_build).to receive(:failed?).and_return(last_build_failed_flag)
32
+ allow(last_finished_build).to receive(:passed?).and_return(last_finished_build_passed_flag)
31
33
  allow(BuildEval::Result::BuildResult).to receive(:create).and_return(build_result)
32
34
  end
33
35
 
@@ -49,8 +51,8 @@ describe BuildEval::Server::TravisPro do
49
51
  subject
50
52
  end
51
53
 
52
- it "determines if the last build has failed" do
53
- expect(last_build).to receive(:failed?)
54
+ it "determines if the last finished build has passed" do
55
+ expect(last_finished_build).to receive(:passed?)
54
56
 
55
57
  subject
56
58
  end
@@ -63,9 +65,9 @@ describe BuildEval::Server::TravisPro do
63
65
  subject
64
66
  end
65
67
 
66
- context "when the last build had passed" do
68
+ context "when the last finished build passed" do
67
69
 
68
- let(:last_build_failed_flag) { false }
70
+ let(:last_finished_build_passed_flag) { true }
69
71
 
70
72
  it "creates a successful build result" do
71
73
  expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: "Success"))
@@ -75,9 +77,9 @@ describe BuildEval::Server::TravisPro do
75
77
 
76
78
  end
77
79
 
78
- context "when the last build had failed" do
80
+ context "when the last finished build failed" do
79
81
 
80
- let(:last_build_failed_flag) { true }
82
+ let(:last_finished_build_passed_flag) { false }
81
83
 
82
84
  it "creates a failed build result" do
83
85
  expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: "Failure"))
@@ -8,19 +8,21 @@ describe BuildEval::Server::Travis do
8
8
 
9
9
  describe "#build_result" do
10
10
 
11
- let(:build_name) { "some_build_name" }
12
- let(:travis_repository) { instance_double(::Travis::Client::Repository) }
13
- let(:recent_builds) { (1..3).map { instance_double(::Travis::Client::Build) } }
14
- let(:last_build) { recent_builds.first }
15
- let(:last_build_failed_flag) { false }
16
- let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
11
+ let(:build_name) { "some_build_name" }
12
+ let(:travis_repository) { instance_double(::Travis::Client::Repository) }
13
+ let(:recent_builds) do
14
+ (1..3).map { |i| instance_double(::Travis::Client::Build, finished?: i > 1) }
15
+ end
16
+ let(:last_finished_build) { recent_builds[1] }
17
+ let(:last_finished_build_passed_flag) { true }
18
+ let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
17
19
 
18
20
  subject { travis_server.build_result(build_name) }
19
21
 
20
22
  before(:example) do
21
23
  allow(::Travis::Repository).to receive(:find).and_return(travis_repository)
22
24
  allow(travis_repository).to receive(:recent_builds).and_return(recent_builds)
23
- allow(last_build).to receive(:failed?).and_return(last_build_failed_flag)
25
+ allow(last_finished_build).to receive(:passed?).and_return(last_finished_build_passed_flag)
24
26
  allow(BuildEval::Result::BuildResult).to receive(:create).and_return(build_result)
25
27
  end
26
28
 
@@ -36,8 +38,8 @@ describe BuildEval::Server::Travis do
36
38
  subject
37
39
  end
38
40
 
39
- it "determines if the last build has failed" do
40
- expect(last_build).to receive(:failed?)
41
+ it "determines if the last finished build has passed" do
42
+ expect(last_finished_build).to receive(:passed?)
41
43
 
42
44
  subject
43
45
  end
@@ -50,9 +52,9 @@ describe BuildEval::Server::Travis do
50
52
  subject
51
53
  end
52
54
 
53
- context "when the last build has passed" do
55
+ context "when the last finished build passed" do
54
56
 
55
- let(:last_build_failed_flag) { false }
57
+ let(:last_finished_build_passed_flag) { true }
56
58
 
57
59
  it "creates a successful build result" do
58
60
  expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: "Success"))
@@ -62,9 +64,9 @@ describe BuildEval::Server::Travis do
62
64
 
63
65
  end
64
66
 
65
- context "when the last build has failed" do
67
+ context "when the last finished build failed" do
66
68
 
67
- let(:last_build_failed_flag) { true }
69
+ let(:last_finished_build_passed_flag) { false }
68
70
 
69
71
  it "creates a failed build result" do
70
72
  expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: "Failure"))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: build_eval
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ueckerman