build_eval 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +8 -8
  2. data/lib/build_eval/monitor/server.rb +6 -3
  3. data/lib/build_eval/result/build_result.rb +15 -7
  4. data/lib/build_eval/result/status.rb +7 -6
  5. data/lib/build_eval/server/decorator.rb +5 -5
  6. data/lib/build_eval/server/jenkins.rb +2 -2
  7. data/lib/build_eval/server/team_city.rb +4 -3
  8. data/lib/build_eval/server/travis.rb +5 -3
  9. data/lib/build_eval/server/travis_pro.rb +6 -3
  10. data/lib/build_eval/travis/session/factory.rb +31 -0
  11. data/lib/build_eval/travis/session/pool.rb +44 -0
  12. data/lib/build_eval/travis/session/session.rb +18 -0
  13. data/lib/build_eval/travis/session.rb +14 -0
  14. data/lib/build_eval/travis.rb +9 -3
  15. data/lib/build_eval/version.rb +1 -1
  16. data/lib/build_eval.rb +4 -1
  17. data/spec/lib/build_eval/monitor/composite_spec.rb +1 -0
  18. data/spec/lib/build_eval/monitor/server_spec.rb +14 -6
  19. data/spec/lib/build_eval/result/build_result_spec.rb +42 -13
  20. data/spec/lib/build_eval/result/status_spec.rb +19 -6
  21. data/spec/lib/build_eval/server/decorator_spec.rb +21 -14
  22. data/spec/lib/build_eval/server/jenkins_integration_spec.rb +4 -3
  23. data/spec/lib/build_eval/server/jenkins_spec.rb +2 -1
  24. data/spec/lib/build_eval/server/team_city_integration_spec.rb +2 -1
  25. data/spec/lib/build_eval/server/team_city_spec.rb +2 -1
  26. data/spec/lib/build_eval/server/travis_pro_spec.rb +11 -6
  27. data/spec/lib/build_eval/server/travis_spec.rb +11 -6
  28. data/spec/lib/build_eval/travis/session/factory_spec.rb +85 -0
  29. data/spec/lib/build_eval/travis/session/pool_spec.rb +89 -0
  30. data/spec/lib/build_eval/travis/session/session_spec.rb +24 -0
  31. data/spec/lib/build_eval/travis/session_spec.rb +65 -0
  32. data/spec/lib/build_eval/travis_spec.rb +75 -50
  33. data/spec/lib/build_eval_smoke_spec.rb +4 -3
  34. metadata +18 -9
  35. data/lib/build_eval/travis/session_factory.rb +0 -38
  36. data/spec/lib/build_eval/travis/session_factory_spec.rb +0 -105
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTdkYTU0YWU2NWVlN2EzMjcxYTg4NjdkMDQ0MjQ1MDcwZjdiMzBiOQ==
4
+ MjgwN2ZiZjMyOWY1YTM2YzZmNmQyZmQ0NjJhZGM4ZTY4YWQ5NTRlMw==
5
5
  data.tar.gz: !binary |-
6
- NTc2OGJjMWIyOTY3YTQ5ODBlNWJjMTk3MjM4ZWU0NWU5NWYzM2M3Nw==
6
+ MTZkMmJjYjQyMjc3NWI0ZWNmY2NhMzNlMzU5YWZhMjMzNjk5ZjY3ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzM1OTUxNjIzZjYzZWNkYmFlNTczYTNjNjlkMDlkZjM4NTg5ODNlMTg1Yjli
10
- ODZkZTBlOGYyYjM1OTQyMTdiZGRjMzlmYTkwODYxZTlkYjUxOTQyZDFlNzdj
11
- Y2YxNzFiZGJkMTk3MTE5NTM3NWYwM2JiMTZiMzNlMGY1NDQ3MTE=
9
+ MmRhMmNhMWJhNDZkM2RlNDZlYTEwZWE5MDIxMDYyYzJkNmQ3M2ZlMzc5OTJm
10
+ MjIxOGZjZTU2ZmMwOWFmODhjMTg5YzM2Y2IyNjgyMWJjZTIyMWQxZDc0YTk0
11
+ YmJiNWM0ZjA1YWIwZDkxMDZlNTYzYTEyZjBjNzMzMThjNTUwZmI=
12
12
  data.tar.gz: !binary |-
13
- Y2I1ZTBiYTNkZDRlMTdhNzc3YzBkM2ViMDQxYWQzMTlhMDQxNTM5MjhjYzU5
14
- MDhkOTZjMGI1ZjJiMDg5YTZlMWRjODRiYjhmNTYwNjE4MjFmZTRlNjg1ZjA2
15
- ZDRiZmFjZDk3NTc1YjE3MmUwNGFiNjBlODg2OTI3YjBlZjI3ODc=
13
+ MTU3YmRhYTZiZGRhYTVhZGJmZTZiNjlmZTliZjk3OTQzNWY0NTViZjQ0OWE1
14
+ YTZlNTM2NmYxYjI0N2U0MmVlZDRjZTE0ZjU4OGE0MGY5NzRjNzA1OTkzYzUx
15
+ MDFiOWM3OGQyNzQ3NDdhNDhjYTJmZDc1NjFlZTYwYjZhYzI0MzY=
@@ -4,12 +4,15 @@ module BuildEval
4
4
  class Server < BuildEval::Monitor::Base
5
5
 
6
6
  def initialize(args)
7
- @server = args[:server]
8
- @build_names = args[:build_names]
7
+ @server = args[:server]
8
+ @build_configurations = args[:build_configurations]
9
9
  end
10
10
 
11
11
  def evaluate
12
- build_results = @build_names.map { |build_name| @server.build_result(build_name) }
12
+ build_results = @build_configurations.map do |build_configuration|
13
+ build_name, branch_name = build_configuration.split(":")
14
+ @server.build_result(build_name, branch_name)
15
+ end
13
16
  BuildEval::Result::ServerResult.new(@server, build_results)
14
17
  end
15
18
 
@@ -6,23 +6,31 @@ module BuildEval
6
6
  class << self
7
7
 
8
8
  def create(args)
9
- new(build_name: args[:build_name], status: BuildEval::Result::Status.find(args[:status_name]))
9
+ new(
10
+ build_name: args[:build_name],
11
+ branch_name: args[:branch_name],
12
+ status: BuildEval::Result::Status.find(args[:status_name])
13
+ )
10
14
  end
11
15
 
12
- def indeterminate(build_name)
13
- new(build_name: build_name, status: BuildEval::Result::Status::INDETERMINATE)
16
+ def indeterminate(args)
17
+ new(
18
+ build_name: args[:build_name],
19
+ branch_name: args[:branch_name],
20
+ status: BuildEval::Result::Status::INDETERMINATE
21
+ )
14
22
  end
15
23
 
16
24
  end
17
25
 
18
- attr_reader :build_name
19
26
  attr_reader :status
20
27
 
21
28
  private
22
29
 
23
30
  def initialize(args)
24
- @build_name = args[:build_name]
25
- @status = args[:status]
31
+ @build_name = args[:build_name]
32
+ @branch_name = args[:branch_name]
33
+ @status = args[:status]
26
34
  end
27
35
 
28
36
  public
@@ -32,7 +40,7 @@ module BuildEval
32
40
  end
33
41
 
34
42
  def to_s
35
- "#{@build_name}: #{@status}"
43
+ "#{@build_name}#{@branch_name ? ":#{@branch_name}" : ""} -> #{@status}"
36
44
  end
37
45
 
38
46
  end
@@ -13,11 +13,12 @@ module BuildEval
13
13
 
14
14
  public
15
15
 
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")
16
+ SUCCESS = new(severity: 0, symbol: :success!, description: "succeeded")
17
+ BUILDING = new(severity: 1, symbol: :building!, description: "building")
18
+ UNKNOWN = new(severity: 2, symbol: :warning!, description: "unknown")
19
+ INDETERMINATE = new(severity: 3, symbol: :warning!, description: "indeterminate")
20
+ FAILURE = new(severity: 4, symbol: :failure!, description: "failed")
21
+ ERROR = new(severity: 5, symbol: :failure!, description: "errored")
21
22
 
22
23
  class << self
23
24
 
@@ -36,7 +37,7 @@ module BuildEval
36
37
  attr_reader :severity
37
38
 
38
39
  def unsuccessful?
39
- self != SUCCESS
40
+ ![ SUCCESS, BUILDING ].include?(self)
40
41
  end
41
42
 
42
43
  def to_sym
@@ -7,14 +7,14 @@ module BuildEval
7
7
  @delegate = delegate
8
8
  end
9
9
 
10
- def build_result(name)
11
- @delegate.build_result(name)
10
+ def build_result(build_name, branch_name)
11
+ @delegate.build_result(build_name, branch_name)
12
12
  rescue StandardError
13
- BuildEval::Result::BuildResult.indeterminate(name)
13
+ BuildEval::Result::BuildResult.indeterminate(build_name: build_name, branch_name: branch_name)
14
14
  end
15
15
 
16
- def monitor(*build_names)
17
- BuildEval::Monitor::Server.new(server: @delegate, build_names: build_names.flatten)
16
+ def monitor(*build_configurations)
17
+ BuildEval::Monitor::Server.new(server: @delegate, build_configurations: build_configurations.flatten)
18
18
  end
19
19
 
20
20
  end
@@ -8,9 +8,9 @@ module BuildEval
8
8
  @base_uri = args[:uri]
9
9
  end
10
10
 
11
- def build_result(name)
11
+ def build_result(build_name, _branch_name)
12
12
  raw_response = @http.get("#{@base_uri}/cc.xml")
13
- BuildEval::Server::CruiseControlResponse.new(raw_response).parse_result("//Project[@name=\"#{name}\"]")
13
+ BuildEval::Server::CruiseControlResponse.new(raw_response).parse_result("//Project[@name=\"#{build_name}\"]")
14
14
  end
15
15
 
16
16
  def to_s
@@ -8,11 +8,12 @@ module BuildEval
8
8
  @base_uri = args[:uri]
9
9
  end
10
10
 
11
- def build_result(name)
12
- response = @http.get("#{@base_uri}/httpAuth/app/rest/buildTypes/id:#{name}/builds")
11
+ def build_result(build_name, _branch_name)
12
+ response = @http.get("#{@base_uri}/httpAuth/app/rest/buildTypes/id:#{build_name}/builds")
13
13
  build_element = Nokogiri::XML(response.body).xpath("//build").first
14
14
  raise "Unexpected build response: #{response.message}" unless build_element
15
- BuildEval::Result::BuildResult.create(build_name: name, status_name: build_element.attribute("status").value)
15
+ BuildEval::Result::BuildResult.create(build_name: build_name,
16
+ status_name: build_element.attribute("status").value)
16
17
  end
17
18
 
18
19
  def to_s
@@ -5,13 +5,15 @@ module BuildEval
5
5
 
6
6
  def initialize(args)
7
7
  @username = args[:username]
8
+ @branch = args[:branch]
8
9
  end
9
10
 
10
- def build_result(name)
11
- repository_path = "#{@username}/#{name}"
11
+ def build_result(build_name, branch_name)
12
+ repository_path = "#{@username}/#{build_name}"
12
13
  BuildEval::Result::BuildResult.create(
13
14
  build_name: repository_path,
14
- status_name: BuildEval::Travis.last_build_status(repository_path: repository_path)
15
+ branch_name: branch_name,
16
+ status_name: BuildEval::Travis.last_build_status(repository_path: repository_path, branch: branch_name)
15
17
  )
16
18
  end
17
19
 
@@ -6,14 +6,17 @@ module BuildEval
6
6
  def initialize(args)
7
7
  @username = args[:username]
8
8
  @github_token = args[:github_token]
9
+ @branch = args[:branch]
9
10
  end
10
11
 
11
- def build_result(name)
12
- repository_path = "#{@username}/#{name}"
12
+ def build_result(build_name, branch_name)
13
+ repository_path = "#{@username}/#{build_name}"
13
14
  BuildEval::Result::BuildResult.create(
14
15
  build_name: repository_path,
16
+ branch_name: branch_name,
15
17
  status_name: BuildEval::Travis.last_build_status(github_token: @github_token,
16
- repository_path: repository_path)
18
+ repository_path: repository_path,
19
+ branch: branch_name)
17
20
  )
18
21
  end
19
22
 
@@ -0,0 +1,31 @@
1
+ module BuildEval
2
+ module Travis
3
+ module Session
4
+
5
+ class Factory
6
+
7
+ class << self
8
+
9
+ def create(github_token)
10
+ BuildEval::Travis::Session::Session.new(create_raw_session(github_token), github_token)
11
+ end
12
+
13
+ private
14
+
15
+ def create_raw_session(github_token)
16
+ ::Travis::Client::Session.new(uri: uri_for(github_token), ssl: {}).tap do |session|
17
+ session.github_auth(github_token) if github_token
18
+ end
19
+ end
20
+
21
+ def uri_for(github_token)
22
+ github_token ? ::Travis::Client::PRO_URI : ::Travis::Client::ORG_URI
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,44 @@
1
+ module BuildEval
2
+ module Travis
3
+ module Session
4
+
5
+ class Pool
6
+
7
+ class << self
8
+
9
+ def get(github_token)
10
+ get_session(github_token) || create_session(github_token)
11
+ end
12
+
13
+ def release(session)
14
+ session.clear_cache
15
+ sessions_for(session.github_token) << session
16
+ end
17
+
18
+ def clear
19
+ @pool = {}
20
+ end
21
+
22
+ private
23
+
24
+ def get_session(github_token)
25
+ sessions_for(github_token).shift
26
+ end
27
+
28
+ def create_session(github_token)
29
+ BuildEval::Travis::Session::Factory.create(github_token)
30
+ end
31
+
32
+ def sessions_for(github_token)
33
+ @pool ||= {}
34
+ @pool[github_token] ||= []
35
+ @pool[github_token]
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,18 @@
1
+ module BuildEval
2
+ module Travis
3
+ module Session
4
+
5
+ class Session < DelegateClass(::Travis::Client::Session)
6
+
7
+ attr_reader :github_token
8
+
9
+ def initialize(raw_session, github_token)
10
+ super(raw_session)
11
+ @github_token = github_token
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ module BuildEval
2
+ module Travis
3
+ module Session
4
+
5
+ def self.open(github_token)
6
+ session = BuildEval::Travis::Session::Pool.get(github_token)
7
+ yield session
8
+ ensure
9
+ BuildEval::Travis::Session::Pool.release(session)
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -2,10 +2,16 @@ module BuildEval
2
2
 
3
3
  module Travis
4
4
 
5
+ STATUS_BY_COLOR = { green: "Success", yellow: "Building", red: "Failure" }.freeze
6
+
7
+ private_constant :STATUS_BY_COLOR
8
+
5
9
  def self.last_build_status(args)
6
- session = BuildEval::Travis::SessionFactory.create(args[:github_token])
7
- repository = session.repo(args[:repository_path])
8
- repository.recent_builds.find(&:finished?).passed? ? "Success" : "Failure"
10
+ BuildEval::Travis::Session.open(args[:github_token]) do |session|
11
+ repository = session.repo(args[:repository_path])
12
+ build = args[:branch] ? repository.branch(args[:branch]) : repository.last_build
13
+ STATUS_BY_COLOR[build.color.to_sym]
14
+ end
9
15
  rescue ::Travis::Client::Error
10
16
  "Unknown"
11
17
  end
@@ -1,3 +1,3 @@
1
1
  module BuildEval
2
- VERSION = "0.0.14".freeze
2
+ VERSION = "0.0.15".freeze
3
3
  end
data/lib/build_eval.rb CHANGED
@@ -6,7 +6,10 @@ require 'travis/client/session'
6
6
 
7
7
  require_relative 'build_eval/error'
8
8
  require_relative 'build_eval/http'
9
- require_relative 'build_eval/travis/session_factory'
9
+ require_relative 'build_eval/travis/session/session'
10
+ require_relative 'build_eval/travis/session/factory'
11
+ require_relative 'build_eval/travis/session/pool'
12
+ require_relative 'build_eval/travis/session'
10
13
  require_relative 'build_eval/travis'
11
14
  require_relative 'build_eval/result/status'
12
15
  require_relative 'build_eval/result/build_result'
@@ -1,4 +1,5 @@
1
1
  describe BuildEval::Monitor::Composite do
2
+
2
3
  let(:monitors) { (1..2).map { double(BuildEval::Monitor::Base) } }
3
4
 
4
5
  let(:composite) { described_class.new(*monitors) }
@@ -1,20 +1,28 @@
1
1
  describe BuildEval::Monitor::Server do
2
2
 
3
- let(:server) { double("BuildEval::Server") }
4
- let(:build_names) { (1..3).map { |i| "build##{i}" } }
3
+ let(:server) { double("BuildEval::Server") }
4
+ let(:build_configurations) { %w{ build#1 build#2:branch#1 build#2:branch#2 build#3 } }
5
5
 
6
- let(:server_monitor) { described_class.new(server: server, build_names: build_names) }
6
+ let(:server_monitor) { described_class.new(server: server, build_configurations: build_configurations) }
7
7
 
8
8
  describe "#evaluate" do
9
9
 
10
- let(:results) { build_names.map { instance_double(BuildEval::Result::BuildResult) } }
10
+ let(:results) { build_configurations.map { instance_double(BuildEval::Result::BuildResult) } }
11
11
 
12
12
  subject { server_monitor.evaluate }
13
13
 
14
14
  before(:example) { allow(server).to receive(:build_result).and_return(*results) }
15
15
 
16
- it "determines build results for builds of interest" do
17
- build_names.each { |build_name| expect(server).to receive(:build_result).with(build_name) }
16
+ it "determines build results for builds with branches" do
17
+ [ [ "build#2", "branch#1" ], ["build#2", "branch#2" ] ].each do |build_name, branch_name|
18
+ expect(server).to receive(:build_result).with(build_name, branch_name)
19
+ end
20
+
21
+ subject
22
+ end
23
+
24
+ it "determines build results for builds without branches" do
25
+ %w{ build#1 build#3 }.each { |build_name| expect(server).to receive(:build_result).with(build_name, nil) }
18
26
 
19
27
  subject
20
28
  end
@@ -3,13 +3,10 @@ describe BuildEval::Result::BuildResult do
3
3
  describe "::create" do
4
4
 
5
5
  let(:build_name) { "Some build name" }
6
+ let(:branch_name) { "Some branch name" }
6
7
  let(:status_name) { "SUCCESS" }
7
8
 
8
- subject { described_class.create(build_name: build_name, status_name: status_name) }
9
-
10
- it "returns a result with the provided build name" do
11
- expect(subject.build_name).to eql(build_name)
12
- end
9
+ subject { described_class.create(build_name: build_name, branch_name: branch_name, status_name: status_name) }
13
10
 
14
11
  it "determines the status with the provided status name" do
15
12
  expect(BuildEval::Result::Status).to receive(:find).with(status_name)
@@ -29,12 +26,9 @@ describe BuildEval::Result::BuildResult do
29
26
  describe "::indeterminate" do
30
27
 
31
28
  let(:build_name) { "Some build name" }
29
+ let(:branch_name) { "Some branch name" }
32
30
 
33
- subject { described_class.indeterminate(build_name) }
34
-
35
- it "returns a result with the provided build name" do
36
- expect(subject.build_name).to eql(build_name)
37
- end
31
+ subject { described_class.indeterminate(build_name: build_name, branch_name: branch_name) }
38
32
 
39
33
  it "returns a result with an indeterminate status" do
40
34
  expect(subject.status).to eql(BuildEval::Result::Status::INDETERMINATE)
@@ -45,7 +39,9 @@ describe BuildEval::Result::BuildResult do
45
39
  describe "#unsuccessful?" do
46
40
 
47
41
  let(:status) { instance_double(BuildEval::Result::Status) }
48
- let(:build_result) { described_class.create(build_name: "some build", status_name: "some status") }
42
+ let(:build_result) do
43
+ described_class.create(build_name: "some build", branch_name: "some branch", status_name: "some status")
44
+ end
49
45
 
50
46
  subject { build_result.unsuccessful? }
51
47
 
@@ -62,10 +58,15 @@ describe BuildEval::Result::BuildResult do
62
58
  describe "#to_s" do
63
59
 
64
60
  let(:build_name) { "Some build name" }
61
+ let(:branch_name) { "Some branch name" }
65
62
  let(:status_string_representation) { "SUCCESS" }
66
- let(:status) { instance_double(BuildEval::Result::Status, to_s: status_string_representation) }
63
+ let(:status) do
64
+ instance_double(BuildEval::Result::Status, to_s: status_string_representation)
65
+ end
67
66
 
68
- let(:build_result) { described_class.create(build_name: build_name, status_name: "some status") }
67
+ let(:build_result) do
68
+ described_class.create(build_name: build_name, branch_name: branch_name, status_name: "some status")
69
+ end
69
70
 
70
71
  subject { build_result.to_s }
71
72
 
@@ -75,6 +76,34 @@ describe BuildEval::Result::BuildResult do
75
76
  expect(subject).to include(build_name)
76
77
  end
77
78
 
79
+ context "when a branch name is provided" do
80
+
81
+ let(:branch_name) { "Some branch name" }
82
+
83
+ it "contains the branch name" do
84
+ expect(subject).to include(branch_name)
85
+ end
86
+
87
+ it "separates the build and branch names with a colon" do
88
+ expect(subject).to include("#{build_name}:#{branch_name}")
89
+ end
90
+
91
+ end
92
+
93
+ context "when a branch name is not provided" do
94
+
95
+ let(:branch_name) { nil }
96
+
97
+ it "does not contain a nil" do
98
+ expect(subject).to_not include("nil")
99
+ end
100
+
101
+ it "does not contain a colon separator" do
102
+ expect(subject).to_not include(":")
103
+ end
104
+
105
+ end
106
+
78
107
  it "contains the string representation of the status" do
79
108
  expect(subject).to include(status_string_representation)
80
109
  end
@@ -58,6 +58,7 @@ describe BuildEval::Result::Status do
58
58
  BuildEval::Result::Status::FAILURE,
59
59
  BuildEval::Result::Status::UNKNOWN,
60
60
  BuildEval::Result::Status::INDETERMINATE,
61
+ BuildEval::Result::Status::BUILDING,
61
62
  BuildEval::Result::Status::SUCCESS
62
63
  ]
63
64
  end
@@ -73,6 +74,7 @@ describe BuildEval::Result::Status do
73
74
  let(:statuses) do
74
75
  [
75
76
  BuildEval::Result::Status::SUCCESS,
77
+ BuildEval::Result::Status::BUILDING,
76
78
  BuildEval::Result::Status::UNKNOWN,
77
79
  BuildEval::Result::Status::INDETERMINATE,
78
80
  BuildEval::Result::Status::FAILURE,
@@ -92,12 +94,21 @@ describe BuildEval::Result::Status do
92
94
 
93
95
  subject { status.unsuccessful? }
94
96
 
95
- context "when the status is SUCCESS" do
96
- let(:status) { BuildEval::Result::Status::SUCCESS }
97
+ {
98
+ "SUCCESS" => BuildEval::Result::Status::SUCCESS,
99
+ "BUILDING" => BuildEval::Result::Status::BUILDING
100
+ }.each do |name, status|
101
+
102
+ context "when the status is #{name}" do
103
+
104
+ let(:status) { status }
105
+
106
+ it "returns false" do
107
+ expect(subject).to be(false)
108
+ end
97
109
 
98
- it "returns false" do
99
- expect(subject).to be(false)
100
110
  end
111
+
101
112
  end
102
113
 
103
114
  {
@@ -127,6 +138,7 @@ describe BuildEval::Result::Status do
127
138
 
128
139
  {
129
140
  SUCCESS: :success!,
141
+ BUILDING: :building!,
130
142
  UNKNOWN: :warning!,
131
143
  INDETERMINATE: :warning!,
132
144
  FAILURE: :failure!,
@@ -137,7 +149,7 @@ describe BuildEval::Result::Status do
137
149
 
138
150
  let(:status) { BuildEval::Result::Status.const_get(name) }
139
151
 
140
- it "returns success!" do
152
+ it "returns #{expected_symbol}" do
141
153
  expect(subject).to eql(expected_symbol)
142
154
  end
143
155
 
@@ -153,6 +165,7 @@ describe BuildEval::Result::Status do
153
165
 
154
166
  {
155
167
  SUCCESS: "succeeded",
168
+ BUILDING: "building",
156
169
  UNKNOWN: "unknown",
157
170
  INDETERMINATE: "indeterminate",
158
171
  FAILURE: "failed",
@@ -163,7 +176,7 @@ describe BuildEval::Result::Status do
163
176
 
164
177
  let(:status) { BuildEval::Result::Status.const_get(name) }
165
178
 
166
- it "returns success!" do
179
+ it "returns #{expected_string}" do
167
180
  expect(subject).to eql(expected_string)
168
181
  end
169
182
 
@@ -6,12 +6,13 @@ describe BuildEval::Server::Decorator do
6
6
 
7
7
  describe "#build_result" do
8
8
 
9
- let(:build_name) { "some build name" }
9
+ let(:build_name) { "some build name" }
10
+ let(:branch_name) { "some branch name" }
10
11
 
11
- subject { decorator.build_result(build_name) }
12
+ subject { decorator.build_result(build_name, branch_name) }
12
13
 
13
14
  it "delegates to the decorated server" do
14
- expect(server).to receive(:build_result).with(build_name)
15
+ expect(server).to receive(:build_result).with(build_name, branch_name)
15
16
 
16
17
  subject
17
18
  end
@@ -33,7 +34,9 @@ describe BuildEval::Server::Decorator do
33
34
  before(:example) { allow(server).to receive(:build_result).and_raise("Forced error") }
34
35
 
35
36
  it "creates an indeterminate result" do
36
- expect(BuildEval::Result::BuildResult).to receive(:indeterminate).with(build_name)
37
+ expect(BuildEval::Result::BuildResult).to(
38
+ receive(:indeterminate).with(build_name: build_name, branch_name: branch_name)
39
+ )
37
40
 
38
41
  subject
39
42
  end
@@ -51,9 +54,9 @@ describe BuildEval::Server::Decorator do
51
54
 
52
55
  describe "#monitor" do
53
56
 
54
- let(:build_names) { (1..3).map { |i| "build##{i}" } }
57
+ let(:build_configurations) { (1..3).map { |i| "monitor##{i}" } }
55
58
 
56
- subject { decorator.monitor(*build_names) }
59
+ subject { decorator.monitor(*build_configurations) }
57
60
 
58
61
  it "creates a server monitor for the decorated server" do
59
62
  expect(BuildEval::Monitor::Server).to receive(:new).with(hash_including(server: server))
@@ -68,24 +71,28 @@ describe BuildEval::Server::Decorator do
68
71
  expect(subject).to eql(monitor)
69
72
  end
70
73
 
71
- context "when an array of build names is provided" do
74
+ context "when an array of build configurations is provided" do
72
75
 
73
- subject { decorator.monitor(build_names) }
76
+ subject { decorator.monitor(build_configurations) }
74
77
 
75
- it "creates a server monitor for the provided build names" do
76
- expect(BuildEval::Monitor::Server).to receive(:new).with(hash_including(build_names: build_names))
78
+ it "creates a server monitor for the provided build configurations" do
79
+ expect(BuildEval::Monitor::Server).to(
80
+ receive(:new).with(hash_including(build_configurations: build_configurations))
81
+ )
77
82
 
78
83
  subject
79
84
  end
80
85
 
81
86
  end
82
87
 
83
- context "when variable argument list of build names is provided" do
88
+ context "when variable argument list build configurations is provided" do
84
89
 
85
- subject { decorator.monitor(*build_names) }
90
+ subject { decorator.monitor(*build_configurations) }
86
91
 
87
- it "creates a server monitor for the provided build names" do
88
- expect(BuildEval::Monitor::Server).to receive(:new).with(hash_including(build_names: build_names))
92
+ it "creates a server monitor for the provided build configurations" do
93
+ expect(BuildEval::Monitor::Server).to(
94
+ receive(:new).with(hash_including(build_configurations: build_configurations))
95
+ )
89
96
 
90
97
  subject
91
98
  end
@@ -7,10 +7,11 @@ describe BuildEval::Server::Jenkins, "integrating with a response parser", integ
7
7
 
8
8
  describe "#build_result" do
9
9
 
10
- let(:build_name) { "some_build_name" }
11
- let(:response) { instance_double(Net::HTTPResponse, body: response_body) }
10
+ let(:build_name) { "some_build_name" }
11
+ let(:branch_name) { nil }
12
+ let(:response) { instance_double(Net::HTTPResponse, body: response_body) }
12
13
 
13
- subject { jenkins.build_result(build_name) }
14
+ subject { jenkins.build_result(build_name, branch_name) }
14
15
 
15
16
  before(:example) { allow(http).to receive(:get).and_return(response) }
16
17