build_eval 0.0.6 → 0.0.7

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
- ODM2MmZjNDRlYmE4NDU0MTA2Mjc0ODUyZWNiYzFiNWI3M2Q2YWFiZA==
4
+ Yjk2OGI1MTg0ZWFiYjBhYTgyZDE4MmY5NzI2ODRkNDMyNWVjM2Y1NA==
5
5
  data.tar.gz: !binary |-
6
- Nzg4Yjg5NTBkMGYxNWRjZmJiMjk1ODU1YjQ0OGRiNjljYTM0NWE0NQ==
6
+ ZjFmYmY4MjEzNzViNTYxZWExZmZiNTg1OTBiYTRjZWFiMjU3MDZmMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWMwNjViYWYyNjNjN2YwNThmNTEwNjc3ODU2YjE2YTlhNTg2ODkzMDJmZDkx
10
- MmUzMjM4Y2Y0YjIzZGFlNTBiZDNlMDUyZjg2NGVjZTBiYTI5MWZmMDJkNzQ3
11
- YzU2YTI1MTU5ZmQxNjRkOGIxNjQ3ZDdhZjVhNmFjYTdjMjVkZmI=
9
+ YThkNjhmN2Q4YmFmM2Q4NjU5MTk0ZjZjOGE3ZjAwODFkMWRjYjgyNWNkOTJl
10
+ MGYwMTUxNDVhMzRlZjE2Nzk0NjU0MjNiMDBlNTcwMzFhMThhNWNkNTNmOWFh
11
+ YmUxY2MxMTc1NTJlYTU4ZWIxMmU0Mjc5MmE5MzA1ZDQyYTE2NjM=
12
12
  data.tar.gz: !binary |-
13
- ZGVjZDU1Y2VlNmMwMmQ5NmQ0YTdkMDViYjUyNzUzNDU1NzhlNWViNTg2NjU4
14
- NzdhYTAxMThkZjk5MjY3NjhlMjRhNTEyZjI1MTAyMGU1ODU0MGIxMmM2MDRh
15
- ZmFhNjAzZDNhMTgwNDJiNzMzNWQ4YzU4Mzg1YTdkMmM3ODdjZDQ=
13
+ YjY0ZTUyZGRiMWEyYTIxNzc2MGVhYmQ1ZjRjODEwZTc4NWRlNzI2NWFiNmRl
14
+ Y2JmZWIzNDU5YmVjMWI3ODlkOGJiNjhmOTFlZmI4YzgzZWIyODk5Yjg3YTRh
15
+ ODY3NTZhYWVjZjZhMzhjNTk2MzM3ZGI5NDg5ZDAyMTk1YWYyNTk=
@@ -9,7 +9,7 @@ module BuildEval
9
9
 
10
10
  def build_result(name)
11
11
  repo_string = "#{@username}/#{name}"
12
- has_failed = ::Travis::Repository.find(repo_string).last_build.failed?
12
+ has_failed = ::Travis::Repository.find(repo_string).recent_builds.first.failed?
13
13
  BuildEval::Result::BuildResult.create(
14
14
  build_name: repo_string,
15
15
  status_name: has_failed ? "Failure" : "Success"
@@ -19,6 +19,7 @@ module BuildEval
19
19
  def to_s
20
20
  "Travis CI #{@username}"
21
21
  end
22
+
22
23
  end
23
24
 
24
25
  end
@@ -10,7 +10,7 @@ module BuildEval
10
10
 
11
11
  def build_result(name)
12
12
  repo_string = "#{@username}/#{name}"
13
- has_failed = ::Travis::Pro::Repository.find(repo_string).last_build.failed?
13
+ has_failed = ::Travis::Pro::Repository.find(repo_string).recent_builds.first.failed?
14
14
  BuildEval::Result::BuildResult.create(
15
15
  build_name: repo_string,
16
16
  status_name: has_failed ? "Failure" : "Success"
@@ -1,3 +1,3 @@
1
1
  module BuildEval
2
- VERSION = "0.0.6".freeze
2
+ VERSION = "0.0.7".freeze
3
3
  end
@@ -19,7 +19,7 @@ describe BuildEval::Server::TravisPro do
19
19
  subject { described_class.new(constructor_args) }
20
20
 
21
21
  it "establishes the GitHub auth token" do
22
- expect(Travis::Pro).to receive(:github_auth).with(github_token)
22
+ expect(::Travis::Pro).to receive(:github_auth).with(github_token)
23
23
 
24
24
  subject
25
25
  end
@@ -28,47 +28,72 @@ describe BuildEval::Server::TravisPro do
28
28
 
29
29
  describe "#build_result" do
30
30
 
31
- let(:build_name) { "some_build_name" }
32
- let(:travis_repository) { instance_double(Travis::Client::Repository) }
33
- let(:travis_build) { instance_double(Travis::Client::Build) }
34
- let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
31
+ let(:build_name) { "some_build_name" }
32
+ let(:travis_repository) { instance_double(::Travis::Client::Repository) }
33
+ let(:recent_builds) { (1..3).map { instance_double(::Travis::Client::Build) } }
34
+ let(:last_build) { recent_builds.first }
35
+ let(:last_build_failed_flag) { false }
36
+ let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
35
37
 
36
38
  subject { travis_pro_server.build_result(build_name) }
37
39
 
38
40
  before(:example) do
39
- allow(Travis::Pro::Repository).to receive(:find).and_return(travis_repository)
40
- allow(travis_repository).to receive(:last_build).and_return(travis_build)
41
- allow(travis_build).to receive(:failed?).and_return(false)
41
+ allow(::Travis::Pro::Repository).to receive(:find).and_return(travis_repository)
42
+ allow(travis_repository).to receive(:recent_builds).and_return(recent_builds)
43
+ allow(last_build).to receive(:failed?).and_return(last_build_failed_flag)
42
44
  allow(BuildEval::Result::BuildResult).to receive(:create).and_return(build_result)
43
45
  end
44
46
 
45
47
  it "retrieves the relevant Travis repository" do
46
- expect(Travis::Pro::Repository).to receive(:find).with("#{username}/#{build_name}").and_return(travis_repository)
48
+ expect(::Travis::Pro::Repository).to receive(:find).with("#{username}/#{build_name}")
47
49
 
48
50
  subject
49
51
  end
50
52
 
51
- it "retrieves the last build on the Travis repository" do
52
- expect(travis_repository).to receive(:last_build).and_return(travis_build)
53
+ it "retrieves the recent builds from Travis" do
54
+ expect(travis_repository).to receive(:recent_builds)
53
55
 
54
56
  subject
55
57
  end
56
58
 
57
- it "retrieves the build status from the build" do
58
- expect(travis_build).to receive(:failed?).and_return(false)
59
+ it "retrieves the build status from the last build" do
60
+ expect(last_build).to receive(:failed?)
59
61
 
60
62
  subject
61
63
  end
62
64
 
63
- it "creates a build result" do
64
- expect(BuildEval::Result::BuildResult).to receive(:create).with(
65
- build_name: "#{username}/#{build_name}",
66
- status_name: "Success"
67
- ).and_return(build_result)
65
+ it "creates a build result whose build name is the path to the repository" do
66
+ expect(BuildEval::Result::BuildResult).to(
67
+ receive(:create).with(hash_including(build_name: "#{username}/#{build_name}"))
68
+ )
68
69
 
69
70
  subject
70
71
  end
71
72
 
73
+ context "when the last build has passed" do
74
+
75
+ let(:last_build_failed_flag) { false }
76
+
77
+ it "creates a successful build result" do
78
+ expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: "Success"))
79
+
80
+ subject
81
+ end
82
+
83
+ end
84
+
85
+ context "when the last build has failed" do
86
+
87
+ let(:last_build_failed_flag) { true }
88
+
89
+ it "creates a failed build result" do
90
+ expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: "Failure"))
91
+
92
+ subject
93
+ end
94
+
95
+ end
96
+
72
97
  it "returns the parsed build result" do
73
98
  expect(subject).to eql(build_result)
74
99
  end
@@ -8,47 +8,72 @@ 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(:travis_build) { instance_double(Travis::Client::Build) }
14
- 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) { (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) }
15
17
 
16
18
  subject { travis_server.build_result(build_name) }
17
19
 
18
20
  before(:example) do
19
- allow(Travis::Repository).to receive(:find).and_return(travis_repository)
20
- allow(travis_repository).to receive(:last_build).and_return(travis_build)
21
- allow(travis_build).to receive(:failed?).and_return(false)
21
+ allow(::Travis::Repository).to receive(:find).and_return(travis_repository)
22
+ allow(travis_repository).to receive(:recent_builds).and_return(recent_builds)
23
+ allow(last_build).to receive(:failed?).and_return(last_build_failed_flag)
22
24
  allow(BuildEval::Result::BuildResult).to receive(:create).and_return(build_result)
23
25
  end
24
26
 
25
27
  it "retrieves the relevant Travis repository" do
26
- expect(Travis::Repository).to receive(:find).with("#{username}/#{build_name}").and_return(travis_repository)
28
+ expect(::Travis::Repository).to receive(:find).with("#{username}/#{build_name}")
27
29
 
28
30
  subject
29
31
  end
30
32
 
31
- it "retrieves the last build on the Travis repository" do
32
- expect(travis_repository).to receive(:last_build).and_return(travis_build)
33
+ it "retrieves the recent builds from Travis" do
34
+ expect(travis_repository).to receive(:recent_builds)
33
35
 
34
36
  subject
35
37
  end
36
38
 
37
- it "retrieves the build status from the build" do
38
- expect(travis_build).to receive(:failed?).and_return(false)
39
+ it "retrieves the status of the last build" do
40
+ expect(last_build).to receive(:failed?)
39
41
 
40
42
  subject
41
43
  end
42
44
 
43
- it "creates a build result" do
44
- expect(BuildEval::Result::BuildResult).to receive(:create).with(
45
- build_name: "#{username}/#{build_name}",
46
- status_name: "Success"
47
- ).and_return(build_result)
45
+ it "creates a build result whose build name is the path to the repository" do
46
+ expect(BuildEval::Result::BuildResult).to(
47
+ receive(:create).with(hash_including(build_name: "#{username}/#{build_name}"))
48
+ )
48
49
 
49
50
  subject
50
51
  end
51
52
 
53
+ context "when the last build has passed" do
54
+
55
+ let(:last_build_failed_flag) { false }
56
+
57
+ it "creates a successful build result" do
58
+ expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: "Success"))
59
+
60
+ subject
61
+ end
62
+
63
+ end
64
+
65
+ context "when the last build has failed" do
66
+
67
+ let(:last_build_failed_flag) { true }
68
+
69
+ it "creates a failed build result" do
70
+ expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: "Failure"))
71
+
72
+ subject
73
+ end
74
+
75
+ end
76
+
52
77
  it "returns the parsed build result" do
53
78
  expect(subject).to eql(build_result)
54
79
  end
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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ueckerman