fuci-travis 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +25 -8
- data/fuci-travis.gemspec +1 -1
- data/lib/fuci/travis/build/generic.rb +18 -0
- data/lib/fuci/travis/build/master.rb +5 -5
- data/lib/fuci/travis/build/pull_request.rb +27 -0
- data/lib/fuci/travis/build/sha_detectable.rb +21 -0
- data/lib/fuci/travis/build.rb +19 -17
- data/lib/fuci/travis/cli_options.rb +18 -0
- data/lib/fuci/travis/version.rb +1 -1
- data/spec/lib/fuci/travis/build/generic_spec.rb +46 -0
- data/spec/lib/fuci/travis/build/master_spec.rb +6 -7
- data/spec/lib/fuci/travis/build/pull_request_spec.rb +77 -0
- data/spec/lib/fuci/travis/build/sha_detectable_spec.rb +22 -0
- data/spec/lib/fuci/travis/build_spec.rb +44 -31
- data/spec/lib/fuci/travis/cli_options_spec.rb +39 -0
- metadata +13 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47d7a6b11a3f4dcb7fdad0853c725288dd0aa2e6
|
4
|
+
data.tar.gz: 06f5cf889bbf21478e558c77c711de73a9277ed3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a58239b15c1713dd5c31f3f0b1e129b8e24f493191475897aee546edb1cea2ad7d2ef4019d4318293e421295d0df1f6f60b6366b5a36bfab40884f454c7dfb3e
|
7
|
+
data.tar.gz: 6ec84669542d9ab524275abd31e9b6be828f1c6835b9fcd38f504a301ca8527659cd86a2e0d0e3337e03f598b87076406d185e0025a75924e89290de74a5185b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
### version 0.3.0 *August 5, 2013*
|
2
|
+
* Update Fuci to v0.3.0 which adds some git helpers
|
3
|
+
* Adds `--pull-request`/`-p` option, which runs failures from the last
|
4
|
+
build triggered by a pull request. Running it with a branch name as an
|
5
|
+
argument will run failures from the last build triggered by a pull
|
6
|
+
request on that branch name.
|
7
|
+
|
1
8
|
### version 0.2.0 *July 31, 2013*
|
2
9
|
* Updates to Fuci 0.2.0 which adds `--last`/`-l` option
|
3
10
|
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Run Travis failures locally. A [Fuci](https://github.com/davejachimiak/fuci) ser
|
|
7
7
|
|
8
8
|
Add this line to your application's Gemfile:
|
9
9
|
|
10
|
-
gem 'fuci-travis', '~> 0.
|
10
|
+
gem 'fuci-travis', '~> 0.3'
|
11
11
|
|
12
12
|
And then execute:
|
13
13
|
|
@@ -120,17 +120,35 @@ Run your latest ci failures locally:
|
|
120
120
|
$ fuci
|
121
121
|
```
|
122
122
|
`fuci` will fetch the CI failures from the default branch declared in
|
123
|
-
your configuration. If no default branch is declared
|
124
|
-
|
125
|
-
|
123
|
+
your configuration. If no default branch is declared , `fuci` will fetch
|
124
|
+
the CI failures from the branch of the same name as your current local
|
125
|
+
branch.
|
126
126
|
|
127
|
-
|
128
|
-
For example, this will run the failures from the latest master
|
129
|
-
on your local code:
|
127
|
+
Call `fuci` with a branch name to run a specific branch's failures
|
128
|
+
branch. For example, this will run the failures from the latest master
|
129
|
+
build on your local code:
|
130
130
|
```sh
|
131
131
|
$ fuci master
|
132
132
|
```
|
133
133
|
|
134
|
+
Run failures from your last pull-request-triggered build:
|
135
|
+
|
136
|
+
```sh
|
137
|
+
$ fuci --pull-request
|
138
|
+
$ # or
|
139
|
+
$ fuci -p
|
140
|
+
```
|
141
|
+
|
142
|
+
Those will find the latest build triggered by a pull request from the
|
143
|
+
remote branch of the same name as your current local branch. Use a
|
144
|
+
branch name as an argument to run failures specific branch's pull
|
145
|
+
request:
|
146
|
+
|
147
|
+
```sh
|
148
|
+
$ git checkout another_branch
|
149
|
+
$ fuci -p my_feature_branch_that_breaks_things
|
150
|
+
```
|
151
|
+
|
134
152
|
## Known incompatibilities/weirdnesses
|
135
153
|
* Build configurations with more than one job. Multiple jobs typically
|
136
154
|
mean test runs in different environments. Switching between these
|
@@ -138,7 +156,6 @@ environments locally and automatically can be tricky and may not even
|
|
138
156
|
be desirable.
|
139
157
|
|
140
158
|
## TODO
|
141
|
-
* Run failed tests from last pull request with some command-line option.
|
142
159
|
* Rake task that bootstraps project with gitignore'd config file,
|
143
160
|
complete with access_token and pro flag
|
144
161
|
* Support for multiple jobs per build (?)
|
data/fuci-travis.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency 'fuci', '~> 0.
|
21
|
+
spec.add_dependency 'fuci', '~> 0.3'
|
22
22
|
spec.add_dependency 'travis', '~> 1.4'
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
spec.add_development_dependency "minitest-spec-expect", "~> 0.1"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fuci
|
2
|
+
module Travis
|
3
|
+
class Build
|
4
|
+
class Generic < Build
|
5
|
+
def build_branch
|
6
|
+
puts "Fetching #{branch_name} branch..."
|
7
|
+
if branch = repo.branches[branch_name]
|
8
|
+
puts "Using #{branch_name} branch."
|
9
|
+
branch
|
10
|
+
else
|
11
|
+
puts "#{branch_name} branch not found on Travis."
|
12
|
+
exit
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
|
1
|
+
require 'fuci/travis/build/sha_detectable'
|
2
2
|
|
3
3
|
module Fuci
|
4
4
|
module Travis
|
5
5
|
class Build
|
6
|
-
class Master <
|
6
|
+
class Master < Build
|
7
|
+
include ShaDetectable
|
8
|
+
|
7
9
|
def initialize; end;
|
8
10
|
|
9
11
|
def build_branch
|
10
|
-
|
11
|
-
build.commit.sha == remote_master_sha
|
12
|
-
end
|
12
|
+
detect_build_with_sha remote_master_sha
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'fuci/travis/build/sha_detectable'
|
2
|
+
|
3
|
+
module Fuci
|
4
|
+
module Travis
|
5
|
+
class Build
|
6
|
+
class PullRequest < Build
|
7
|
+
include ShaDetectable
|
8
|
+
|
9
|
+
def build_branch
|
10
|
+
sha = begin
|
11
|
+
pull_merge_sha_from branch_name
|
12
|
+
rescue Fuci::Git::NoPullError
|
13
|
+
puts "No pull request was detected for #{branch_name}."
|
14
|
+
return exit
|
15
|
+
end
|
16
|
+
|
17
|
+
if branch = detect_build_with_sha(sha)
|
18
|
+
branch
|
19
|
+
else
|
20
|
+
puts "No build was detected for pull request from #{branch_name}."
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fuci
|
2
|
+
module Travis
|
3
|
+
class Build
|
4
|
+
module ShaDetectable
|
5
|
+
def detect_build_with_sha sha
|
6
|
+
repo_builds.detect { |build| commit(build).sha == sha }
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def repo_builds
|
12
|
+
repo.builds
|
13
|
+
end
|
14
|
+
|
15
|
+
def commit build
|
16
|
+
build.commit
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/fuci/travis/build.rb
CHANGED
@@ -2,6 +2,8 @@ require 'forwardable'
|
|
2
2
|
require 'fuci/git'
|
3
3
|
require 'fuci/travis/cli_options'
|
4
4
|
require 'fuci/travis/build/master'
|
5
|
+
require 'fuci/travis/build/generic'
|
6
|
+
require 'fuci/travis/build/pull_request'
|
5
7
|
|
6
8
|
module Fuci
|
7
9
|
module Travis
|
@@ -19,10 +21,6 @@ module Fuci
|
|
19
21
|
@branch_name = branch_name
|
20
22
|
end
|
21
23
|
|
22
|
-
def branch
|
23
|
-
@branch ||= build_branch
|
24
|
-
end
|
25
|
-
|
26
24
|
def status
|
27
25
|
case state
|
28
26
|
when FAILED
|
@@ -38,7 +36,22 @@ module Fuci
|
|
38
36
|
jobs.first.log.body
|
39
37
|
end
|
40
38
|
|
39
|
+
def branch
|
40
|
+
@branch ||= build_branch
|
41
|
+
end
|
42
|
+
|
43
|
+
def build_branch
|
44
|
+
raise NotImplementedError
|
45
|
+
end
|
46
|
+
|
41
47
|
def self.create
|
48
|
+
if Fuci::Travis::CliOptions.pull_request?
|
49
|
+
branch_name =
|
50
|
+
Fuci::Travis::CliOptions.pull_request_branch || current_branch_name
|
51
|
+
|
52
|
+
return PullRequest.new branch_name
|
53
|
+
end
|
54
|
+
|
42
55
|
branch_name =
|
43
56
|
Fuci::Travis::CliOptions.branch ||
|
44
57
|
Fuci::Travis.default_branch ||
|
@@ -49,25 +62,14 @@ module Fuci
|
|
49
62
|
|
50
63
|
def self.from_branch_name branch_name
|
51
64
|
if branch_name == 'master'
|
52
|
-
|
65
|
+
Master.new
|
53
66
|
else
|
54
|
-
new branch_name
|
67
|
+
Generic.new branch_name
|
55
68
|
end
|
56
69
|
end
|
57
70
|
|
58
71
|
private
|
59
72
|
|
60
|
-
def build_branch
|
61
|
-
puts "Fetching #{branch_name} branch..."
|
62
|
-
if branch = repo.branches[branch_name]
|
63
|
-
puts "Using #{branch_name} branch."
|
64
|
-
branch
|
65
|
-
else
|
66
|
-
puts "#{branch_name} branch not found on Travis."
|
67
|
-
exit
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
73
|
def repo
|
72
74
|
Fuci::Travis.repo
|
73
75
|
end
|
@@ -1,10 +1,28 @@
|
|
1
1
|
module Fuci
|
2
2
|
module Travis
|
3
3
|
class CliOptions
|
4
|
+
PULL_REQUEST_INDICATORS = ['--pull-request', '-p']
|
5
|
+
|
4
6
|
def self.branch
|
5
7
|
argv.first
|
6
8
|
end
|
7
9
|
|
10
|
+
def self.pull_request?
|
11
|
+
(argv & PULL_REQUEST_INDICATORS).any?
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.pull_request_branch
|
15
|
+
branch = nil
|
16
|
+
|
17
|
+
argv.each_with_index do |arg, index|
|
18
|
+
if PULL_REQUEST_INDICATORS.include? arg
|
19
|
+
branch = argv[index+1]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
branch
|
24
|
+
end
|
25
|
+
|
8
26
|
private
|
9
27
|
|
10
28
|
def self.argv
|
data/lib/fuci/travis/version.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative '../../../../spec_helper'
|
2
|
+
require_relative '../../../../../lib/fuci/travis/build'
|
3
|
+
require_relative '../../../../../lib/fuci/travis/build/generic'
|
4
|
+
|
5
|
+
describe Fuci::Travis::Build::Generic do
|
6
|
+
describe 'composition' do
|
7
|
+
it 'inherits from Build' do
|
8
|
+
generic = Fuci::Travis::Build::Generic.new 'branch'
|
9
|
+
expect(generic).to_be_kind_of Fuci::Travis::Build
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#build_branch' do
|
14
|
+
before do
|
15
|
+
@branch_name = 'my-ci'
|
16
|
+
@build = mock
|
17
|
+
Fuci::Travis.stubs(:repo).returns @repo = mock
|
18
|
+
@build_wrapper = Fuci::Travis::Build::Generic.new @branch_name
|
19
|
+
@build_wrapper.expects(:puts).with "Fetching #{@branch_name} branch..."
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'when the branch is found' do
|
23
|
+
before do
|
24
|
+
@repo.stubs(:branches).returns branches = { @branch_name => @build }
|
25
|
+
@build_wrapper.expects(:puts).with "Using #{@branch_name} branch."
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'logs fetching and calls branch hash with the branch_name on the repo' do
|
29
|
+
expect(@build_wrapper.send :build_branch ).to_equal @build
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'when branch is not found' do
|
34
|
+
before do
|
35
|
+
@repo.stubs(:branches).returns branches = {}
|
36
|
+
@build_wrapper.expects(:puts).
|
37
|
+
with "#{@branch_name} branch not found on Travis."
|
38
|
+
@build_wrapper.expects :exit
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'logs that the branch could not be found and exits' do
|
42
|
+
@build_wrapper.send :build_branch
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative '../../../../spec_helper'
|
2
|
+
require_relative '../../../../../lib/fuci/travis/build'
|
2
3
|
require_relative '../../../../../lib/fuci/travis/build/master'
|
3
4
|
|
4
5
|
describe Fuci::Travis::Build::Master do
|
@@ -14,13 +15,11 @@ describe Fuci::Travis::Build::Master do
|
|
14
15
|
|
15
16
|
describe '#build_branch' do
|
16
17
|
it 'detects the build branch' do
|
17
|
-
|
18
|
-
|
19
|
-
@master.stubs(:
|
20
|
-
|
21
|
-
|
22
|
-
repo.stubs(:builds).returns [build]
|
23
|
-
|
18
|
+
@master.stubs(:remote_master_sha).
|
19
|
+
returns remote_master_sha = mock
|
20
|
+
@master.stubs(:detect_build_with_sha).
|
21
|
+
with(remote_master_sha).
|
22
|
+
returns build = mock
|
24
23
|
expect(@master.build_branch).to_equal build
|
25
24
|
end
|
26
25
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require_relative '../../../../spec_helper'
|
2
|
+
require_relative '../../../../../lib/fuci/travis/build'
|
3
|
+
require_relative '../../../../../lib/fuci/travis/build/pull_request'
|
4
|
+
|
5
|
+
module Fuci
|
6
|
+
module Git
|
7
|
+
class NoPullError < StandardError
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe Fuci::Travis::Build::PullRequest do
|
13
|
+
before do
|
14
|
+
@branch_name = 'branch'
|
15
|
+
@pull_request = Fuci::Travis::Build::PullRequest.new @branch_name
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'composition' do
|
19
|
+
it 'inherits from Build' do
|
20
|
+
expect(@pull_request).to_be_kind_of Fuci::Travis::Build
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#build_branch' do
|
25
|
+
before do
|
26
|
+
@pull_merge_sha_from = @pull_request.
|
27
|
+
stubs(:pull_merge_sha_from).
|
28
|
+
with @branch_name
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'there is no pull request for the branch' do
|
32
|
+
before do
|
33
|
+
@pull_merge_sha_from.raises Fuci::Git::NoPullError
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'logs that no pull request was detected for the branch and exits' do
|
37
|
+
@pull_request.expects(:puts).
|
38
|
+
with "No pull request was detected for #{@branch_name}."
|
39
|
+
@pull_request.expects(:exit)
|
40
|
+
|
41
|
+
@pull_request.build_branch
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'there is a pull request for the branch' do
|
46
|
+
before do
|
47
|
+
@pull_merge_sha_from.returns @sha = '23iadf89wro'
|
48
|
+
@detect_build_with_sha = @pull_request.
|
49
|
+
stubs(:detect_build_with_sha).with @sha
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'a build was not detected for the pull request' do
|
53
|
+
before do
|
54
|
+
@detect_build_with_sha.with(@sha).returns nil
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'logs that no build was detected with pull request and exits' do
|
58
|
+
@pull_request.expects(:puts).
|
59
|
+
with "No build was detected for pull request from #{@branch_name}."
|
60
|
+
@pull_request.expects(:exit)
|
61
|
+
|
62
|
+
@pull_request.build_branch
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe 'a build was detected for the pull request' do
|
67
|
+
before do
|
68
|
+
@detect_build_with_sha.returns @build = mock
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns the build' do
|
72
|
+
expect(@pull_request.build_branch).to_equal @build
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../../../../spec_helper'
|
2
|
+
require_relative '../../../../../lib/fuci/travis/build/sha_detectable'
|
3
|
+
|
4
|
+
stub_class 'SomeBuild'
|
5
|
+
|
6
|
+
describe Fuci::Travis::Build::ShaDetectable do
|
7
|
+
before { @build = SomeBuild.new.extend Fuci::Travis::Build::ShaDetectable }
|
8
|
+
|
9
|
+
describe '#detect_build_with_sha' do
|
10
|
+
it 'returns the build with the same sha as the one passed in' do
|
11
|
+
sha = mock
|
12
|
+
commit = OpenStruct.new sha: sha
|
13
|
+
build = OpenStruct.new commit: commit
|
14
|
+
builds = [build]
|
15
|
+
repo = OpenStruct.new builds: builds
|
16
|
+
|
17
|
+
@build.stubs(:repo).returns repo
|
18
|
+
|
19
|
+
expect(@build.detect_build_with_sha(sha)).to_equal build
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -2,6 +2,7 @@ require_relative '../../../spec_helper'
|
|
2
2
|
require_relative '../../../../lib/fuci/travis/build'
|
3
3
|
|
4
4
|
stub_class 'Fuci::Travis::Build::Master'
|
5
|
+
stub_class 'Fuci::Travis::Build::PullRequest'
|
5
6
|
stub_class 'Fuci::Travis::CliOptions' do
|
6
7
|
public
|
7
8
|
def branch; end;
|
@@ -76,10 +77,49 @@ describe Fuci::Travis::Build do
|
|
76
77
|
|
77
78
|
describe '.create' do
|
78
79
|
before do
|
80
|
+
@pull_request = Fuci::Travis::CliOptions.stubs :pull_request?
|
79
81
|
@branch_from_cli = Fuci::Travis::CliOptions.stubs :branch
|
80
82
|
@expect_from_branch_name = Fuci::Travis::Build.expects :from_branch_name
|
81
83
|
end
|
82
84
|
|
85
|
+
describe 'a pull request option is declared from the command line' do
|
86
|
+
before do
|
87
|
+
@pull_request.returns true
|
88
|
+
@expect_from_branch_name.never
|
89
|
+
@pull_request_branch =
|
90
|
+
Fuci::Travis::CliOptions.stubs :pull_request_branch
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'when a pull request branch is declared' do
|
94
|
+
before do
|
95
|
+
@branch_name = 'branch_name'
|
96
|
+
@pull_request_branch.returns @branch_name
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'instantiates pull request build with the branch' do
|
100
|
+
Fuci::Travis::Build::PullRequest.expects(:new).
|
101
|
+
with @branch_name
|
102
|
+
|
103
|
+
Fuci::Travis::Build.create
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe 'when a pull request branch is not declared' do
|
108
|
+
before do
|
109
|
+
@pull_request_branch.returns nil
|
110
|
+
Fuci::Travis::Build.stubs(:current_branch_name).
|
111
|
+
returns @current_branch_name = 'current_branch_name'
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'instantiates a pull request build with the current branch name' do
|
115
|
+
Fuci::Travis::Build::PullRequest.expects(:new).
|
116
|
+
with @current_branch_name
|
117
|
+
|
118
|
+
Fuci::Travis::Build.create
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
83
123
|
describe 'a branch option is declared from the command line' do
|
84
124
|
before do
|
85
125
|
@branch = 'master'
|
@@ -134,7 +174,7 @@ describe Fuci::Travis::Build do
|
|
134
174
|
before { @branch_name = 'limb' }
|
135
175
|
|
136
176
|
it 'creates a new generic build' do
|
137
|
-
Fuci::Travis::Build.stubs(:new).with(@branch_name).
|
177
|
+
Fuci::Travis::Build::Generic.stubs(:new).with(@branch_name).
|
138
178
|
returns generic_build = mock
|
139
179
|
build = Fuci::Travis::Build.from_branch_name @branch_name
|
140
180
|
expect(build).to_equal generic_build
|
@@ -143,36 +183,9 @@ describe Fuci::Travis::Build do
|
|
143
183
|
end
|
144
184
|
|
145
185
|
describe '#build_branch' do
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
Fuci::Travis.stubs(:repo).returns @repo = mock
|
150
|
-
@build_wrapper = Fuci::Travis::Build.new @branch_name
|
151
|
-
@build_wrapper.expects(:puts).with "Fetching #{@branch_name} branch..."
|
152
|
-
end
|
153
|
-
|
154
|
-
describe 'when the branch is found' do
|
155
|
-
before do
|
156
|
-
@repo.stubs(:branches).returns branches = { @branch_name => @build }
|
157
|
-
@build_wrapper.expects(:puts).with "Using #{@branch_name} branch."
|
158
|
-
end
|
159
|
-
|
160
|
-
it 'logs fetching and calls branch hash with the branch_name on the repo' do
|
161
|
-
expect(@build_wrapper.send :build_branch ).to_equal @build
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
describe 'when branch is not found' do
|
166
|
-
before do
|
167
|
-
@repo.stubs(:branches).returns branches = {}
|
168
|
-
@build_wrapper.expects(:puts).
|
169
|
-
with "#{@branch_name} branch not found on Travis."
|
170
|
-
@build_wrapper.expects :exit
|
171
|
-
end
|
172
|
-
|
173
|
-
it 'logs that the branch could not be found and exits' do
|
174
|
-
@build_wrapper.send :build_branch
|
175
|
-
end
|
186
|
+
it 'raises not implemented' do
|
187
|
+
build = Fuci::Travis::Build.new 'branch'
|
188
|
+
expect { build.build_branch }.to_raise NotImplementedError
|
176
189
|
end
|
177
190
|
end
|
178
191
|
end
|
@@ -17,6 +17,45 @@ describe Fuci::Travis::CliOptions do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
describe '.pull_request?' do
|
21
|
+
describe 'when --pull-request is passed in' do
|
22
|
+
it 'returns true' do
|
23
|
+
Fuci::Travis::CliOptions.stubs(:argv).returns ['--pull-request']
|
24
|
+
expect(Fuci::Travis::CliOptions.pull_request?).to_equal true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'when -p is passed in' do
|
29
|
+
it 'returns true' do
|
30
|
+
Fuci::Travis::CliOptions.stubs(:argv).returns ['-p']
|
31
|
+
expect(Fuci::Travis::CliOptions.pull_request?).to_equal true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'when neither are passed in' do
|
36
|
+
it 'returns false' do
|
37
|
+
Fuci::Travis::CliOptions.stubs(:argv).returns []
|
38
|
+
expect(Fuci::Travis::CliOptions.pull_request?).to_equal false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '.pull_request_branch' do
|
44
|
+
describe 'when a branch arg is passed in' do
|
45
|
+
it 'returns the next argument after the pull request indicator' do
|
46
|
+
Fuci::Travis::CliOptions.stubs(:argv).returns ['-p', branch = 'branch']
|
47
|
+
expect(Fuci::Travis::CliOptions.pull_request_branch).to_equal branch
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'when a branch arg is not passed in' do
|
52
|
+
it 'returns nil' do
|
53
|
+
Fuci::Travis::CliOptions.stubs(:argv).returns ['-p']
|
54
|
+
expect(Fuci::Travis::CliOptions.pull_request_branch).to_equal nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
20
59
|
describe '.argv' do
|
21
60
|
it 'delegates to Fuci::CliOptions' do
|
22
61
|
Fuci::CliOptions.stubs(:argv).returns argv = mock
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fuci-travis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Jachimiak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fuci
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: travis
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,11 +112,17 @@ files:
|
|
112
112
|
- fuci-travis.gemspec
|
113
113
|
- lib/fuci/travis.rb
|
114
114
|
- lib/fuci/travis/build.rb
|
115
|
+
- lib/fuci/travis/build/generic.rb
|
115
116
|
- lib/fuci/travis/build/master.rb
|
117
|
+
- lib/fuci/travis/build/pull_request.rb
|
118
|
+
- lib/fuci/travis/build/sha_detectable.rb
|
116
119
|
- lib/fuci/travis/cli_options.rb
|
117
120
|
- lib/fuci/travis/server.rb
|
118
121
|
- lib/fuci/travis/version.rb
|
122
|
+
- spec/lib/fuci/travis/build/generic_spec.rb
|
119
123
|
- spec/lib/fuci/travis/build/master_spec.rb
|
124
|
+
- spec/lib/fuci/travis/build/pull_request_spec.rb
|
125
|
+
- spec/lib/fuci/travis/build/sha_detectable_spec.rb
|
120
126
|
- spec/lib/fuci/travis/build_spec.rb
|
121
127
|
- spec/lib/fuci/travis/cli_options_spec.rb
|
122
128
|
- spec/lib/fuci/travis/server_spec.rb
|
@@ -147,7 +153,10 @@ signing_key:
|
|
147
153
|
specification_version: 4
|
148
154
|
summary: Run failures from your recent Travis builds locally.
|
149
155
|
test_files:
|
156
|
+
- spec/lib/fuci/travis/build/generic_spec.rb
|
150
157
|
- spec/lib/fuci/travis/build/master_spec.rb
|
158
|
+
- spec/lib/fuci/travis/build/pull_request_spec.rb
|
159
|
+
- spec/lib/fuci/travis/build/sha_detectable_spec.rb
|
151
160
|
- spec/lib/fuci/travis/build_spec.rb
|
152
161
|
- spec/lib/fuci/travis/cli_options_spec.rb
|
153
162
|
- spec/lib/fuci/travis/server_spec.rb
|