fuci 0.0.1 → 0.1.0
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 +4 -4
- data/.travis.yml +8 -0
- data/README.md +8 -14
- data/Rakefile +9 -0
- data/fuci.gemspec +8 -2
- data/lib/fuci.rb +49 -2
- data/lib/fuci/configurable.rb +13 -0
- data/lib/fuci/git.rb +40 -0
- data/lib/fuci/rspec.rb +27 -0
- data/lib/fuci/runner.rb +56 -0
- data/lib/fuci/server.rb +25 -0
- data/lib/fuci/tester.rb +18 -0
- data/lib/fuci/version.rb +1 -1
- data/spec/lib/fuci/configurable_spec.rb +18 -0
- data/spec/lib/fuci/git_spec.rb +70 -0
- data/spec/lib/fuci/rspec_spec.rb +43 -0
- data/spec/lib/fuci/runner_spec.rb +114 -0
- data/spec/lib/fuci/server_spec.rb +30 -0
- data/spec/lib/fuci/tester_spec.rb +18 -0
- data/spec/lib/fuci_spec.rb +112 -0
- data/spec/spec_helper.rb +28 -0
- metadata +59 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c51a2d0ad456cb773cc634a1e33cebcbd1c03af5
|
4
|
+
data.tar.gz: 80ad9fb11b2b88c86f3de73f27b57baa8e29c216
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e17548470e39a72f4e81fe41f8fcb5f96db0446f5b044f8b30d0eb53021d52a0fc33d4816092a13442dac5be26c6dc81da7f276088bda1e5ecc71c507c2c304
|
7
|
+
data.tar.gz: 1fe119206c7956c8f0f7e965bd54aa0377b38ad1c98349e304d9a52aa9d68114a6daa7b51dc66e30256b66fbd9a687ead75f7a9c6a3dfd700f821995e33ea5d4
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,25 +1,19 @@
|
|
1
1
|
# Fuci
|
2
|
+
[](https://travis-ci.org/davejachimiak/fuci)
|
2
3
|
|
3
|
-
|
4
|
+
Run failed tests from your last build on the command line.
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
7
|
-
Add this line to your
|
8
|
+
Add this line to your fuci extension's Gemspec:
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install fuci
|
10
|
+
.add_dependency 'fuci', '~> 0.1'
|
18
11
|
|
19
12
|
## Usage
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
### Server extensions
|
14
|
+
Coming soon...
|
15
|
+
### Tester extensions
|
16
|
+
Coming soon...
|
23
17
|
## Contributing
|
24
18
|
|
25
19
|
1. Fork it
|
data/Rakefile
CHANGED
data/fuci.gemspec
CHANGED
@@ -9,8 +9,12 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Dave Jachimiak"]
|
10
10
|
spec.email = ["dave.jachimiak@gmail.com"]
|
11
11
|
spec.description = %q{FUCK YOU CI}
|
12
|
-
spec.summary =
|
13
|
-
|
12
|
+
spec.summary =
|
13
|
+
%q{Fuci is a library that covers the general case for running
|
14
|
+
recent failures from recent CI (continuous integration) builds
|
15
|
+
locally. It includes interfaces for server (e.g. Travis,
|
16
|
+
TeamCity) and tester (e.g. RSpec, Cucumber) extensions.}
|
17
|
+
spec.homepage = "https://github.com/davejachimiak/fuci"
|
14
18
|
spec.license = "MIT"
|
15
19
|
|
16
20
|
spec.files = `git ls-files`.split($/)
|
@@ -18,6 +22,8 @@ Gem::Specification.new do |spec|
|
|
18
22
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
23
|
spec.require_paths = ["lib"]
|
20
24
|
|
25
|
+
spec.add_development_dependency "minitest-spec-expect", "~> 0.1"
|
21
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
|
+
spec.add_development_dependency "mocha", "~> 0.14"
|
22
28
|
spec.add_development_dependency "rake"
|
23
29
|
end
|
data/lib/fuci.rb
CHANGED
@@ -1,5 +1,52 @@
|
|
1
|
-
require
|
1
|
+
require 'fuci/runner'
|
2
|
+
require 'fuci/rspec'
|
3
|
+
require 'fuci/configurable'
|
2
4
|
|
3
5
|
module Fuci
|
4
|
-
|
6
|
+
include Configurable
|
7
|
+
|
8
|
+
DEFAULT_TESTERS = [Fuci::RSpec]
|
9
|
+
|
10
|
+
class << self
|
11
|
+
attr_accessor :server
|
12
|
+
attr_writer :options
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.options
|
16
|
+
@options ||= {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.run
|
20
|
+
Fuci::Runner.new.run
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.add_testers *testers
|
24
|
+
@testers += testers.flatten
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.testers
|
28
|
+
@testers ||= default_testers
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.default_testers
|
32
|
+
DEFAULT_TESTERS
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.initialize_server!
|
36
|
+
self.server = initialize_server
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.initialize_testers!
|
40
|
+
@testers = initialize_testers
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def self.initialize_server
|
46
|
+
server.new
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.initialize_testers
|
50
|
+
testers.map { |tester| tester.new }
|
51
|
+
end
|
5
52
|
end
|
data/lib/fuci/git.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Fuci
|
2
|
+
module Git
|
3
|
+
CURRENT_BRANCH_COMMAND = "git branch | sed -n '/\* /s///p'"
|
4
|
+
REMOTE_MASTER_SHA_COMMAND = "git rev-parse origin/master"
|
5
|
+
REMOTE_REPO_COMMAND =
|
6
|
+
"git remote -v | grep origin | grep push | awk 'match($0, /:\(.*)\.git/) { print substr($0, RSTART+1, RLENGTH-5) }'"
|
7
|
+
|
8
|
+
def current_branch_name
|
9
|
+
with_popen current_branch_command
|
10
|
+
end
|
11
|
+
|
12
|
+
def remote_repo_name
|
13
|
+
with_popen remote_repo_command
|
14
|
+
end
|
15
|
+
|
16
|
+
def remote_master_sha
|
17
|
+
with_popen remote_master_sha_command
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def with_popen command
|
23
|
+
IO.popen command do |io|
|
24
|
+
io.first.chomp
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def current_branch_command
|
29
|
+
CURRENT_BRANCH_COMMAND
|
30
|
+
end
|
31
|
+
|
32
|
+
def remote_repo_command
|
33
|
+
REMOTE_REPO_COMMAND
|
34
|
+
end
|
35
|
+
|
36
|
+
def remote_master_sha_command
|
37
|
+
REMOTE_MASTER_SHA_COMMAND
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/fuci/rspec.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'fuci/tester'
|
2
|
+
|
3
|
+
module Fuci
|
4
|
+
class RSpec < Fuci::Tester
|
5
|
+
FAILURE_INDICATOR = 'Failed examples:'
|
6
|
+
BASE_COMMAND = 'rspec --tty'
|
7
|
+
FAIL_FILE_CAPTURE = /rspec (.*) #/
|
8
|
+
|
9
|
+
def indicates_failure? log
|
10
|
+
log.include? FAILURE_INDICATOR
|
11
|
+
end
|
12
|
+
|
13
|
+
def command log
|
14
|
+
"#{base_command} #{failures log }"
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def base_command
|
20
|
+
BASE_COMMAND
|
21
|
+
end
|
22
|
+
|
23
|
+
def failures log
|
24
|
+
log.scan(FAIL_FILE_CAPTURE).join ' '
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/fuci/runner.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module Fuci
|
4
|
+
class Runner
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
def_delegators :Fuci, :server, :testers, :initialize_server!,
|
8
|
+
:initialize_testers!
|
9
|
+
def_delegator :server, :build_status
|
10
|
+
attr_accessor :log, :detected_tester, :failures
|
11
|
+
|
12
|
+
def run
|
13
|
+
initialize_server!
|
14
|
+
initialize_testers!
|
15
|
+
check_build
|
16
|
+
fetch_log
|
17
|
+
detect_tester_failure
|
18
|
+
run_failures
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def check_build
|
24
|
+
case build_status
|
25
|
+
when :green
|
26
|
+
puts_with_exit 'Build is green.'
|
27
|
+
when :yellow
|
28
|
+
puts_with_exit 'Build has errored. Check build for more info.'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def fetch_log
|
33
|
+
puts "Fetching log from build..."
|
34
|
+
self.log = server.fetch_log
|
35
|
+
end
|
36
|
+
|
37
|
+
def detect_tester_failure
|
38
|
+
self.detected_tester = testers.detect do |tester|
|
39
|
+
tester.indicates_failure? log
|
40
|
+
end
|
41
|
+
puts "Failure detected: #{detected_tester.class.name.split('::').last}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def run_failures
|
45
|
+
IO.popen detected_tester.command(log) do |io|
|
46
|
+
puts 'Running failed specs...'
|
47
|
+
io.each { |string| puts string }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def puts_with_exit string
|
52
|
+
puts string
|
53
|
+
exit
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/fuci/server.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Fuci
|
2
|
+
class Server
|
3
|
+
|
4
|
+
# must return either of the following
|
5
|
+
# symbols:
|
6
|
+
# :red (failure),
|
7
|
+
# :yellow (errored),
|
8
|
+
# :green (passing)
|
9
|
+
def build_status
|
10
|
+
raise NotImplementedError
|
11
|
+
end
|
12
|
+
|
13
|
+
# must return a string with characters
|
14
|
+
# denoting ascii color removed
|
15
|
+
def fetch_log
|
16
|
+
raise NotImplementedError
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def remove_ascii_color_chars string
|
22
|
+
string.gsub /\e\[(\d+)m/, ""
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/fuci/tester.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fuci
|
2
|
+
class Tester
|
3
|
+
|
4
|
+
# must return a boolean telling whether the
|
5
|
+
# log passed in indicates a failure made by
|
6
|
+
# the tester
|
7
|
+
def indicates_failure? log
|
8
|
+
raise NotImplementedError
|
9
|
+
end
|
10
|
+
|
11
|
+
# must return a command string to be executed
|
12
|
+
# by the system, e.g.
|
13
|
+
# "rspec ./spec/features/it_is_cool_spec.rb"
|
14
|
+
def command log
|
15
|
+
raise NotImplementedError
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/fuci/version.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/fuci/configurable'
|
3
|
+
|
4
|
+
describe Fuci::Configurable do
|
5
|
+
describe '.configure' do
|
6
|
+
it 'yields the block to self' do
|
7
|
+
module TestMod
|
8
|
+
include Fuci::Configurable
|
9
|
+
end
|
10
|
+
|
11
|
+
test_string = 'configuring!'
|
12
|
+
TestMod.expects(:puts).with test_string
|
13
|
+
TestMod.configure do |f|
|
14
|
+
f.send :puts, test_string
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/fuci/git'
|
3
|
+
|
4
|
+
class TestClass
|
5
|
+
include Fuci::Git
|
6
|
+
end
|
7
|
+
|
8
|
+
describe Fuci::Git do
|
9
|
+
before { @test_class = TestClass.new }
|
10
|
+
|
11
|
+
describe '#current_branch_name' do
|
12
|
+
it 'returns the current branch' do
|
13
|
+
@test_class.stubs(:current_branch_command).
|
14
|
+
returns current_branch_command = mock
|
15
|
+
@test_class.expects(:with_popen).with current_branch_command
|
16
|
+
|
17
|
+
@test_class.current_branch_name
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#remote_repo_name' do
|
22
|
+
it 'returns the remote repo name' do
|
23
|
+
@test_class.stubs(:remote_repo_command).
|
24
|
+
returns remote_repo_command = mock
|
25
|
+
@test_class.expects(:with_popen).with remote_repo_command
|
26
|
+
|
27
|
+
@test_class.remote_repo_name
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#remote_master_sha' do
|
32
|
+
it 'returns the remote master sha' do
|
33
|
+
@test_class.stubs(:remote_master_sha_command).
|
34
|
+
returns remote_master_sha_command = mock
|
35
|
+
@test_class.expects(:with_popen).with remote_master_sha_command
|
36
|
+
|
37
|
+
@test_class.remote_master_sha
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#with_popen' do
|
42
|
+
it 'runs the command with popen' do
|
43
|
+
current_branch = 'current_branch'
|
44
|
+
result = @test_class.send :with_popen, "echo #{current_branch}"
|
45
|
+
|
46
|
+
expect(result).to_equal current_branch
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#current_branch_command' do
|
51
|
+
it 'returns the git/unix command to returnt the current branch' do
|
52
|
+
current_branch_command = @test_class.send :current_branch_command
|
53
|
+
expect(current_branch_command).to_equal "git branch | sed -n '/\* /s///p'"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#remote_repo_command' do
|
58
|
+
it 'returns the git/unix command to return the remote owner/repo' do
|
59
|
+
command = "git remote -v | grep origin | grep push | awk 'match($0, /:\(.*)\.git/) { print substr($0, RSTART+1, RLENGTH-5) }'"
|
60
|
+
expect(@test_class.send :remote_repo_command).to_equal command
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#remote_master_sha_command' do
|
65
|
+
it 'returns the git/unix command to return the remote master sha' do
|
66
|
+
current_branch_command = @test_class.send :remote_master_sha_command
|
67
|
+
expect(current_branch_command).to_equal "git rev-parse origin/master"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
stub_class 'Fuci::Tester'
|
3
|
+
require_relative '../../../lib/fuci/rspec'
|
4
|
+
|
5
|
+
describe Fuci::RSpec do
|
6
|
+
before { @rspec = Fuci::RSpec.new }
|
7
|
+
describe 'composition' do
|
8
|
+
it 'inherits from Fuci::Tester' do
|
9
|
+
expect(@rspec).to_be_kind_of Fuci::Tester
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#indicates_failure?' do
|
14
|
+
describe 'when the log passed in has "Failed examples:"' do
|
15
|
+
before { @log = "irjioerijoijoaf;joia;ijoawfeFailed examples:" }
|
16
|
+
|
17
|
+
it 'returns true' do
|
18
|
+
expect(@rspec.indicates_failure?(@log)).to_equal true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'when the log passed in has no "Failed examples:"' do
|
23
|
+
before { @log = "irjioerijoijpoop: " }
|
24
|
+
|
25
|
+
it 'returns false' do
|
26
|
+
expect(@rspec.indicates_failure?(@log)).to_equal false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#command' do
|
32
|
+
it 'returns "rspec <failure string>"' do
|
33
|
+
log = """
|
34
|
+
rspec is #ljasdfois\nrspec ok #jcicisj\nrspec for #ie
|
35
|
+
iejfasdi\nrspec testing #iiiirrpepwpqapc
|
36
|
+
"""
|
37
|
+
|
38
|
+
command = @rspec.command log
|
39
|
+
|
40
|
+
expect(command).to_equal 'rspec --tty is ok for testing'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/fuci/runner'
|
3
|
+
|
4
|
+
stub_class 'IO'
|
5
|
+
|
6
|
+
describe Fuci::Runner do
|
7
|
+
before { @runner = Fuci::Runner.new }
|
8
|
+
|
9
|
+
describe '.run' do
|
10
|
+
before do
|
11
|
+
@runner.expects :initialize_server!
|
12
|
+
@runner.expects :initialize_testers!
|
13
|
+
@runner.expects :check_build
|
14
|
+
@runner.expects :fetch_log
|
15
|
+
@runner.expects :detect_tester_failure
|
16
|
+
@runner.expects :run_failures
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'initializes the testers, ' +
|
20
|
+
'initializes the server, ' +
|
21
|
+
'fetches the log, ' +
|
22
|
+
'detects which tester has the failure, ' +
|
23
|
+
'and runs the failures.' do
|
24
|
+
@runner.run
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.initialize_server' do
|
29
|
+
it 'initializes the server' do
|
30
|
+
Fuci.expects :initialize_server!
|
31
|
+
@runner.send :initialize_server!
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '.initialize_testers' do
|
36
|
+
it 'initializes the testers' do
|
37
|
+
Fuci.expects :initialize_testers!
|
38
|
+
@runner.send :initialize_testers!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.fetch_log' do
|
43
|
+
it 'logs fetching; sets the log with delegation to the server' do
|
44
|
+
@runner.expects(:puts).with "Fetching log from build..."
|
45
|
+
@runner.stubs(:server).returns server = mock
|
46
|
+
server.stubs(:fetch_log).returns log = mock
|
47
|
+
|
48
|
+
@runner.send :fetch_log
|
49
|
+
|
50
|
+
expect(@runner.send :log ).to_equal log
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '.detect_tester_failure' do
|
55
|
+
it 'detects the first tester failure in the log' do
|
56
|
+
rspec, konacha, cucumber = mock, mock, mock
|
57
|
+
@runner.stubs(:log).returns log = mock
|
58
|
+
[rspec, cucumber].each { |t| t.stubs :indicates_failure? }
|
59
|
+
konacha.stubs(:indicates_failure?).with(log).returns true
|
60
|
+
konacha.class.stubs(:name).returns 'Fuci::Konacha'
|
61
|
+
testers = [rspec, konacha, cucumber]
|
62
|
+
@runner.expects(:puts).with 'Failure detected: Konacha'
|
63
|
+
@runner.stubs(:testers).returns testers
|
64
|
+
|
65
|
+
@runner.send :detect_tester_failure
|
66
|
+
|
67
|
+
expect(@runner.send :detected_tester ).to_equal konacha
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '.run_failures' do
|
72
|
+
it 'runs the failrues locally' do
|
73
|
+
@runner.stubs(:detected_tester).returns detected_tester = mock
|
74
|
+
@runner.stubs(:log).returns log = mock
|
75
|
+
detected_tester.
|
76
|
+
stubs(:command).
|
77
|
+
with(log).
|
78
|
+
returns command = mock
|
79
|
+
IO.expects(:popen).with command
|
80
|
+
|
81
|
+
@runner.send :run_failures
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '.check_build' do
|
86
|
+
describe 'status is green' do
|
87
|
+
before { @runner.stubs(:build_status).returns :green }
|
88
|
+
|
89
|
+
it 'prints a message that the lastest build passed and exits' do
|
90
|
+
@runner.expects(:puts).with 'Build is green.'
|
91
|
+
@runner.expects :exit
|
92
|
+
@runner.send :check_build
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe 'status is yellow' do
|
97
|
+
before { @runner.stubs(:build_status).returns :yellow }
|
98
|
+
|
99
|
+
it 'prints a message that the build in question passed is bad and exits' do
|
100
|
+
@runner.expects(:puts).with 'Build has errored. Check build for more info.'
|
101
|
+
@runner.expects :exit
|
102
|
+
@runner.send :check_build
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe 'status is red' do
|
107
|
+
before { @runner.stubs(:build_status).returns :red }
|
108
|
+
|
109
|
+
it 'returns nil' do
|
110
|
+
expect(@runner.send :check_build ).to_be_nil
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/fuci/server'
|
3
|
+
|
4
|
+
describe Fuci::Server do
|
5
|
+
describe '#fetch_log' do
|
6
|
+
it 'raises a NotImplemented error' do
|
7
|
+
server = Fuci::Server.new
|
8
|
+
expect { server.build_status }.to_raise NotImplementedError
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#fetch_log' do
|
13
|
+
it 'raises a NotImplemented error' do
|
14
|
+
server = Fuci::Server.new
|
15
|
+
expect { server.fetch_log }.to_raise NotImplementedError
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#remove_ascii_color_chars' do
|
20
|
+
it 'removes the ascii color characters' do
|
21
|
+
server = Fuci::Server.new
|
22
|
+
string = "\e[33mbody"
|
23
|
+
clean_string = 'body'
|
24
|
+
|
25
|
+
processed_string = server.send :remove_ascii_color_chars, string
|
26
|
+
|
27
|
+
expect(processed_string).to_equal clean_string
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/fuci/tester'
|
3
|
+
|
4
|
+
describe Fuci::Tester do
|
5
|
+
before { @tester = Fuci::Tester.new }
|
6
|
+
|
7
|
+
describe '#indicates_failure?' do
|
8
|
+
it 'raises a NotImplemented error' do
|
9
|
+
expect { @tester.indicates_failure? '' }.to_raise NotImplementedError
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#command' do
|
14
|
+
it 'raises a NotImplemented error' do
|
15
|
+
expect { @tester.command '' }.to_raise NotImplementedError
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
stub_class 'Fuci::Tester'
|
4
|
+
stub_class 'Fuci::Runner'
|
5
|
+
|
6
|
+
require_relative '../../lib/fuci'
|
7
|
+
|
8
|
+
describe Fuci do
|
9
|
+
describe '.run' do
|
10
|
+
it 'calls #run on an instnace on runner' do
|
11
|
+
Fuci::Runner.stubs(:new).returns runner = mock
|
12
|
+
runner.expects :run
|
13
|
+
|
14
|
+
Fuci.run
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.server/=' do
|
19
|
+
it 'is an accessor' do
|
20
|
+
expect(Fuci.server).to_be_nil
|
21
|
+
Fuci.server = server = mock
|
22
|
+
expect(Fuci.server).to_equal server
|
23
|
+
Fuci.server = nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '.options/=' do
|
28
|
+
after { Fuci.options = {} }
|
29
|
+
|
30
|
+
it 'is an accessor' do
|
31
|
+
expect(Fuci.options).to_equal({})
|
32
|
+
Fuci.options = options = { options: :yup }
|
33
|
+
expect(Fuci.options).to_equal options
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '.testers' do
|
38
|
+
after { Fuci.instance_variable_set :@testers, [] }
|
39
|
+
|
40
|
+
it 'is an array accessor' do
|
41
|
+
expect(Fuci.testers).to_be_instance_of Array
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '.add_testers' do
|
46
|
+
before do
|
47
|
+
@rspec, @konacha = mock, mock
|
48
|
+
mocks = [@rspec, @konacha]
|
49
|
+
mocks.each { |m| m.expects :to_ary }
|
50
|
+
Fuci.stubs(:default_testers).returns []
|
51
|
+
end
|
52
|
+
after { Fuci.instance_variable_set :@testers, [] }
|
53
|
+
|
54
|
+
describe 'when one to many args are passed in' do
|
55
|
+
it 'adds the args to testers' do
|
56
|
+
Fuci.add_testers @rspec, @konacha
|
57
|
+
|
58
|
+
testers = Fuci.testers
|
59
|
+
expect(testers).to_equal [@rspec, @konacha]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'when an array is passed in' do
|
64
|
+
it 'adds the args to testers' do
|
65
|
+
Fuci.add_testers [@rspec, @konacha]
|
66
|
+
|
67
|
+
testers = Fuci.testers
|
68
|
+
expect(testers).to_equal [@rspec, @konacha]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '.configure' do
|
74
|
+
after { Fuci.server = nil }
|
75
|
+
|
76
|
+
it 'yields the block with self' do
|
77
|
+
server = :server
|
78
|
+
Fuci.configure do |f|
|
79
|
+
f.server = server
|
80
|
+
end
|
81
|
+
|
82
|
+
expect(Fuci.server).to_equal server
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '.initialize_server!' do
|
87
|
+
after { Fuci.server = nil }
|
88
|
+
|
89
|
+
it 'sets .server to an initialized server' do
|
90
|
+
class Cool; end;
|
91
|
+
Fuci.server = Cool
|
92
|
+
Cool.stubs(:new).returns new_cool = mock
|
93
|
+
|
94
|
+
Fuci.initialize_server!
|
95
|
+
|
96
|
+
expect(Fuci.server).to_equal new_cool
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '.initialize_testers!' do
|
101
|
+
it 'mutates the testers attribute to initialized testers' do
|
102
|
+
class Cool; end;
|
103
|
+
Fuci.instance_variable_set :@testers, [Cool]
|
104
|
+
Cool.stubs(:new).returns new_cool = mock
|
105
|
+
testers = [new_cool]
|
106
|
+
|
107
|
+
Fuci.initialize_testers!
|
108
|
+
|
109
|
+
expect(Fuci.testers).to_equal testers
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'minitest/spec/expect'
|
2
|
+
require 'mocha/setup'
|
3
|
+
|
4
|
+
def stub_class klass
|
5
|
+
objects = klass.split '::'
|
6
|
+
|
7
|
+
klass = objects.inject(Object) do |memo, obj|
|
8
|
+
unless obj == objects.last
|
9
|
+
begin
|
10
|
+
memo.const_get obj
|
11
|
+
rescue
|
12
|
+
memo.const_set obj, Module.new
|
13
|
+
end
|
14
|
+
else
|
15
|
+
begin
|
16
|
+
memo.const_get obj
|
17
|
+
rescue
|
18
|
+
memo.const_set obj, Class.new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
memo.const_get obj
|
23
|
+
end
|
24
|
+
|
25
|
+
klass.class_eval do
|
26
|
+
yield if block_given?
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fuci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.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-07-
|
11
|
+
date: 2013-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest-spec-expect
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +38,20 @@ dependencies:
|
|
24
38
|
- - ~>
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mocha
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.14'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: rake
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -46,14 +74,29 @@ extensions: []
|
|
46
74
|
extra_rdoc_files: []
|
47
75
|
files:
|
48
76
|
- .gitignore
|
77
|
+
- .travis.yml
|
49
78
|
- Gemfile
|
50
79
|
- LICENSE.txt
|
51
80
|
- README.md
|
52
81
|
- Rakefile
|
53
82
|
- fuci.gemspec
|
54
83
|
- lib/fuci.rb
|
84
|
+
- lib/fuci/configurable.rb
|
85
|
+
- lib/fuci/git.rb
|
86
|
+
- lib/fuci/rspec.rb
|
87
|
+
- lib/fuci/runner.rb
|
88
|
+
- lib/fuci/server.rb
|
89
|
+
- lib/fuci/tester.rb
|
55
90
|
- lib/fuci/version.rb
|
56
|
-
|
91
|
+
- spec/lib/fuci/configurable_spec.rb
|
92
|
+
- spec/lib/fuci/git_spec.rb
|
93
|
+
- spec/lib/fuci/rspec_spec.rb
|
94
|
+
- spec/lib/fuci/runner_spec.rb
|
95
|
+
- spec/lib/fuci/server_spec.rb
|
96
|
+
- spec/lib/fuci/tester_spec.rb
|
97
|
+
- spec/lib/fuci_spec.rb
|
98
|
+
- spec/spec_helper.rb
|
99
|
+
homepage: https://github.com/davejachimiak/fuci
|
57
100
|
licenses:
|
58
101
|
- MIT
|
59
102
|
metadata: {}
|
@@ -73,8 +116,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
116
|
version: '0'
|
74
117
|
requirements: []
|
75
118
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.0.
|
119
|
+
rubygems_version: 2.0.6
|
77
120
|
signing_key:
|
78
121
|
specification_version: 4
|
79
|
-
summary:
|
80
|
-
|
122
|
+
summary: Fuci is a library that covers the general case for running recent failures
|
123
|
+
from recent CI (continuous integration) builds locally. It includes interfaces for
|
124
|
+
server (e.g. Travis, TeamCity) and tester (e.g. RSpec, Cucumber) extensions.
|
125
|
+
test_files:
|
126
|
+
- spec/lib/fuci/configurable_spec.rb
|
127
|
+
- spec/lib/fuci/git_spec.rb
|
128
|
+
- spec/lib/fuci/rspec_spec.rb
|
129
|
+
- spec/lib/fuci/runner_spec.rb
|
130
|
+
- spec/lib/fuci/server_spec.rb
|
131
|
+
- spec/lib/fuci/tester_spec.rb
|
132
|
+
- spec/lib/fuci_spec.rb
|
133
|
+
- spec/spec_helper.rb
|