ci_in_a_can 0.0.4 → 0.0.5
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/.gitignore +2 -0
- data/bin/ciinacan +1 -1
- data/ci_in_a_can.gemspec +2 -0
- data/lib/ci_in_a_can.rb +7 -1
- data/lib/ci_in_a_can/app.rb +17 -11
- data/lib/ci_in_a_can/bash.rb +10 -1
- data/lib/ci_in_a_can/bash_result.rb +13 -0
- data/lib/ci_in_a_can/build.rb +1 -0
- data/lib/ci_in_a_can/github.rb +11 -0
- data/lib/ci_in_a_can/persistence.rb +25 -0
- data/lib/ci_in_a_can/runner.rb +1 -1
- data/lib/ci_in_a_can/test_result.rb +16 -1
- data/lib/ci_in_a_can/test_result_notifier.rb +1 -1
- data/lib/ci_in_a_can/test_runner.rb +5 -3
- data/lib/ci_in_a_can/version.rb +1 -1
- data/lib/ci_in_a_can/watcher.rb +2 -1
- data/spec/ci_in_a_can/bash_result_spec.rb +21 -0
- data/spec/ci_in_a_can/bash_spec.rb +20 -6
- data/spec/ci_in_a_can/github_spec.rb +105 -6
- data/spec/ci_in_a_can/runner_spec.rb +2 -4
- data/spec/ci_in_a_can/test_result_notifier_spec.rb +2 -20
- data/spec/ci_in_a_can/test_result_spec.rb +65 -0
- data/spec/ci_in_a_can/test_runner_spec.rb +21 -5
- data/spec/ci_in_a_can/watcher_spec.rb +2 -1
- data/spec/spec_helper.rb +5 -0
- data/spec/temp/.gitkeep +0 -0
- metadata +38 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b92800dac2342b781a87421b1a3aeae065283a56
|
4
|
+
data.tar.gz: 423e1a4a194de2e97328ccaadeddb3ab387773df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf241c4c38390532c1dd4aaee778fe77dccc122d37d8ad22b19cca4181da1d8b7125f195837a1d64379653a487c53c3755f08045b0368fc0664e981491c1df0e
|
7
|
+
data.tar.gz: c289b390e5edc5fb0de5d9fb3605fc1a59e652ca2aa7f7f83c8b247fab0cdddc93b2603d9212d4397aa3a043790e54aad856b4b29ab2dd8d6fef80b22b773d13
|
data/.gitignore
CHANGED
data/bin/ciinacan
CHANGED
@@ -61,7 +61,7 @@ when 'create'
|
|
61
61
|
|
62
62
|
root = "#{Dir.pwd}/#{ARGV[1]}"
|
63
63
|
|
64
|
-
directories_to_create = [root, "#{root}/jobs", "#{root}/repos", "#{root}/web", "#{root}/service"]
|
64
|
+
directories_to_create = [root, "#{root}/jobs", "#{root}/repos", "#{root}/web", "#{root}/service", "#{root}/results"]
|
65
65
|
|
66
66
|
directories_to_create.each { |d| Dir.mkdir(d) unless File.exists?(d) }
|
67
67
|
|
data/ci_in_a_can.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "mocha"
|
23
23
|
spec.add_development_dependency "subtle"
|
24
|
+
spec.add_development_dependency "contrast"
|
24
25
|
|
25
26
|
spec.add_runtime_dependency "rake"
|
26
27
|
spec.add_runtime_dependency "sinatra"
|
@@ -29,4 +30,5 @@ Gem::Specification.new do |spec|
|
|
29
30
|
spec.add_runtime_dependency "listen"
|
30
31
|
spec.add_runtime_dependency "octokit"
|
31
32
|
spec.add_runtime_dependency "daemons"
|
33
|
+
spec.add_runtime_dependency "subtle"
|
32
34
|
end
|
data/lib/ci_in_a_can.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
+
require 'subtle'
|
2
|
+
|
1
3
|
require_relative "ci_in_a_can/version"
|
2
4
|
Dir[File.dirname(__FILE__) + '/ci_in_a_can/*.rb'].each { |file| require file }
|
3
5
|
|
4
6
|
module CiInACan
|
5
|
-
|
7
|
+
|
8
|
+
def self.results_location
|
9
|
+
File.expand_path(File.dirname(__FILE__) + '/../../results')
|
10
|
+
end
|
11
|
+
|
6
12
|
end
|
data/lib/ci_in_a_can/app.rb
CHANGED
@@ -10,19 +10,25 @@ module CiInACan
|
|
10
10
|
attr_accessor :jobs_location
|
11
11
|
end
|
12
12
|
|
13
|
-
get '/
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
get '/' do
|
14
|
+
<<EOF
|
15
|
+
<html>
|
16
|
+
<head>
|
17
|
+
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">
|
18
|
+
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap-theme.min.css">
|
19
|
+
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
|
20
|
+
</head>
|
21
|
+
<body>
|
22
|
+
<table class="table table-bordered">
|
23
|
+
<tbody>
|
24
|
+
</tbody>
|
25
|
+
</table>
|
26
|
+
</body>
|
27
|
+
</html>
|
28
|
+
EOF
|
23
29
|
end
|
24
30
|
|
25
|
-
|
31
|
+
post '/' do
|
26
32
|
write_a_file_with params
|
27
33
|
end
|
28
34
|
|
data/lib/ci_in_a_can/bash.rb
CHANGED
@@ -3,9 +3,18 @@ module CiInACan
|
|
3
3
|
module Bash
|
4
4
|
|
5
5
|
def self.run command
|
6
|
+
result = CiInACan::BashResult.new
|
7
|
+
result.output = backtick command
|
8
|
+
result.exit_code = the_exit_code
|
9
|
+
result
|
10
|
+
end
|
6
11
|
|
7
|
-
|
12
|
+
def self.backtick command
|
13
|
+
`#{command}`
|
14
|
+
end
|
8
15
|
|
16
|
+
def self.the_exit_code
|
17
|
+
$?.to_i
|
9
18
|
end
|
10
19
|
|
11
20
|
end
|
data/lib/ci_in_a_can/build.rb
CHANGED
data/lib/ci_in_a_can/github.rb
CHANGED
@@ -9,9 +9,20 @@ module CiInACan
|
|
9
9
|
attr_accessor :access_token
|
10
10
|
|
11
11
|
def client
|
12
|
+
return nil if access_token.to_s == ''
|
12
13
|
Octokit::Client.new access_token: access_token
|
13
14
|
end
|
14
15
|
|
16
|
+
def report_pending_status_for build
|
17
|
+
return nil unless client
|
18
|
+
client.create_status build.repo, build.sha, 'pending'
|
19
|
+
end
|
20
|
+
|
21
|
+
def report_complete_status_for build, test_result
|
22
|
+
return nil unless client
|
23
|
+
client.create_status build.repo, build.sha, (test_result.passed ? 'success' : 'failure')
|
24
|
+
end
|
25
|
+
|
15
26
|
end
|
16
27
|
|
17
28
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'yaml/store'
|
2
|
+
|
3
|
+
module CiInACan
|
4
|
+
|
5
|
+
module Persistence
|
6
|
+
|
7
|
+
def self.save type, id, value
|
8
|
+
store = store_for(type)
|
9
|
+
store.transaction { store[id] = value }
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.find type, id
|
13
|
+
store = store_for(type)
|
14
|
+
store.transaction(true) { store[id] }
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def self.store_for type
|
20
|
+
YAML::Store.new("#{CiInACan.results_location}/#{type}.yml")
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/lib/ci_in_a_can/runner.rb
CHANGED
@@ -3,7 +3,7 @@ module CiInACan
|
|
3
3
|
module Runner
|
4
4
|
|
5
5
|
def self.run build
|
6
|
-
CiInACan::Github.
|
6
|
+
CiInACan::Github.report_pending_status_for build
|
7
7
|
CiInACan::Cloner.clone_a_local_copy_for build
|
8
8
|
test_results = CiInACan::TestRunner.run_tests_for build
|
9
9
|
CiInACan::TestResultNotifier.send_for build, test_results
|
@@ -1,5 +1,20 @@
|
|
1
|
+
require 'subtle'
|
2
|
+
|
1
3
|
module CiInACan
|
2
4
|
class TestResult
|
3
|
-
|
5
|
+
params_constructor
|
6
|
+
attr_accessor :id
|
7
|
+
attr_accessor :passed, :output
|
8
|
+
|
9
|
+
def self.create values
|
10
|
+
test_result = self.new values
|
11
|
+
test_result.id = UUID.new.generate
|
12
|
+
CiInACan::Persistence.save "test_result", test_result.id, test_result
|
13
|
+
test_result
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.find id
|
17
|
+
CiInACan::Persistence.find "test_result", id
|
18
|
+
end
|
4
19
|
end
|
5
20
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module CiInACan
|
2
2
|
module TestResultNotifier
|
3
3
|
def self.send_for build, test_result
|
4
|
-
CiInACan::Github.
|
4
|
+
CiInACan::Github.report_complete_status_for build, test_result
|
5
5
|
end
|
6
6
|
end
|
7
7
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
module CiInACan
|
2
2
|
module TestRunner
|
3
3
|
def self.run_tests_for build
|
4
|
-
test_result = CiInACan::TestResult.new
|
5
4
|
commands = ["cd #{build.local_location}", "bundle install"]
|
6
5
|
build.pre_test_commands.each { |c| commands << c }
|
7
6
|
commands << "bundle exec rake"
|
8
|
-
|
9
|
-
|
7
|
+
|
8
|
+
bash_result = CiInACan::Bash.run commands.join('; ')
|
9
|
+
|
10
|
+
CiInACan::TestResult.create( { passed: bash_result.successful,
|
11
|
+
output: bash_result.output } )
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
data/lib/ci_in_a_can/version.rb
CHANGED
data/lib/ci_in_a_can/watcher.rb
CHANGED
@@ -23,7 +23,8 @@ module CiInACan
|
|
23
23
|
next unless added.count > 0
|
24
24
|
|
25
25
|
build = CiInACan::Build.parse File.read(added.first)
|
26
|
-
build.
|
26
|
+
build.id = UUID.new.generate
|
27
|
+
build.local_location = "#{working_location}/#{build.id}"
|
27
28
|
|
28
29
|
Runner.run build
|
29
30
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe CiInACan::BashResult do
|
4
|
+
|
5
|
+
describe "successful" do
|
6
|
+
|
7
|
+
let(:bash_result) { CiInACan::BashResult.new }
|
8
|
+
|
9
|
+
it "should return true if the exit code is 0" do
|
10
|
+
bash_result.exit_code = 0
|
11
|
+
bash_result.successful.must_equal true
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return false if the exit code is not 0" do
|
15
|
+
bash_result.exit_code = 1
|
16
|
+
bash_result.successful.must_equal false
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -4,17 +4,31 @@ describe CiInACan::Bash do
|
|
4
4
|
|
5
5
|
describe "run" do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
command = Object.new
|
7
|
+
let(:command) { Object.new }
|
8
|
+
let(:output) { Object.new }
|
9
|
+
let(:exit_code) { Object.new }
|
11
10
|
|
12
|
-
|
11
|
+
before do
|
12
|
+
CiInACan::Bash.stubs(:backtick).with(command).returns output
|
13
|
+
CiInACan::Bash.stubs(:the_exit_code).returns exit_code
|
14
|
+
end
|
13
15
|
|
14
|
-
|
16
|
+
it "should return a BashResult" do
|
17
|
+
result = CiInACan::Bash.run command
|
18
|
+
result.is_a?(CiInACan::BashResult).must_equal true
|
19
|
+
end
|
15
20
|
|
21
|
+
it "should return the output" do
|
22
|
+
result = CiInACan::Bash.run command
|
23
|
+
result.output.must_be_same_as output
|
16
24
|
end
|
17
25
|
|
26
|
+
it "should return the exit code" do
|
27
|
+
result = CiInACan::Bash.run command
|
28
|
+
result.exit_code.must_be_same_as exit_code
|
29
|
+
end
|
30
|
+
|
31
|
+
|
18
32
|
end
|
19
33
|
|
20
34
|
end
|
@@ -4,15 +4,114 @@ describe CiInACan::Github do
|
|
4
4
|
|
5
5
|
describe "client" do
|
6
6
|
|
7
|
-
|
8
|
-
access_token = Object.new
|
9
|
-
client = Object.new
|
7
|
+
describe "when an access token was provided" do
|
10
8
|
|
11
|
-
|
9
|
+
let(:access_token) { Object.new }
|
12
10
|
|
13
|
-
Octokit
|
11
|
+
it "should create an Octokit client with the access token" do
|
12
|
+
client = Object.new
|
14
13
|
|
15
|
-
|
14
|
+
CiInACan::Github.access_token = access_token
|
15
|
+
|
16
|
+
Octokit::Client.expects(:new).with(access_token: access_token).returns client
|
17
|
+
|
18
|
+
CiInACan::Github.client.must_be_same_as client
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
[nil, ''].each do |access_token|
|
24
|
+
|
25
|
+
describe "when an access token was not provided" do
|
26
|
+
|
27
|
+
it "should return nothing" do
|
28
|
+
CiInACan::Github.access_token = access_token
|
29
|
+
|
30
|
+
Octokit::Client.expects(:new).never
|
31
|
+
|
32
|
+
CiInACan::Github.client.nil?.must_equal true
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "report_pending_status" do
|
42
|
+
|
43
|
+
it "should report a pending status to the github client" do
|
44
|
+
|
45
|
+
build = CiInACan::Build.new
|
46
|
+
build.sha = Object.new
|
47
|
+
build.repo = Object.new
|
48
|
+
|
49
|
+
client = Object.new
|
50
|
+
CiInACan::Github.stubs(:client).returns client
|
51
|
+
|
52
|
+
client.expects(:create_status).with build.repo, build.sha, 'pending'
|
53
|
+
|
54
|
+
CiInACan::Github.report_pending_status_for build
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should not fail if there is no github client" do
|
58
|
+
CiInACan::Github.stubs(:client).returns nil
|
59
|
+
CiInACan::Github.report_pending_status_for CiInACan::Build.new
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "report_complete_status" do
|
65
|
+
|
66
|
+
describe "a successful test result" do
|
67
|
+
|
68
|
+
let(:test_result) do
|
69
|
+
test_result = Object.new
|
70
|
+
test_result.stubs(:passed).returns true
|
71
|
+
test_result
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should report a success status to the github client" do
|
75
|
+
build = CiInACan::Build.new
|
76
|
+
build.sha = Object.new
|
77
|
+
build.repo = Object.new
|
78
|
+
|
79
|
+
client = Object.new
|
80
|
+
CiInACan::Github.stubs(:client).returns client
|
81
|
+
|
82
|
+
client.expects(:create_status).with build.repo, build.sha, 'success'
|
83
|
+
|
84
|
+
CiInACan::Github.report_complete_status_for build, test_result
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "a failed test result" do
|
90
|
+
|
91
|
+
let(:test_result) do
|
92
|
+
test_result = Object.new
|
93
|
+
test_result.stubs(:passed).returns false
|
94
|
+
test_result
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should report a success status to the github client" do
|
98
|
+
build = CiInACan::Build.new
|
99
|
+
build.sha = Object.new
|
100
|
+
build.repo = Object.new
|
101
|
+
|
102
|
+
client = Object.new
|
103
|
+
CiInACan::Github.stubs(:client).returns client
|
104
|
+
|
105
|
+
client.expects(:create_status).with build.repo, build.sha, 'failure'
|
106
|
+
|
107
|
+
CiInACan::Github.report_complete_status_for build, test_result
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should not fail if there is no github client" do
|
113
|
+
CiInACan::Github.stubs(:client).returns nil
|
114
|
+
CiInACan::Github.report_complete_status_for CiInACan::Build.new, Object.new
|
16
115
|
end
|
17
116
|
|
18
117
|
end
|
@@ -5,11 +5,9 @@ describe CiInACan::Runner do
|
|
5
5
|
describe "run" do
|
6
6
|
|
7
7
|
let(:build) { CiInACan::Build.new }
|
8
|
-
let(:client) { Object.new }
|
9
8
|
|
10
9
|
before do
|
11
|
-
|
12
|
-
CiInACan::Github.stubs(:client).returns client
|
10
|
+
CiInACan::Github.stubs(:report_pending_status_for)
|
13
11
|
CiInACan::Cloner.stubs(:clone_a_local_copy_for)
|
14
12
|
CiInACan::TestRunner.stubs(:run_tests_for)
|
15
13
|
CiInACan::TestResultNotifier.stubs(:send_for)
|
@@ -46,7 +44,7 @@ describe CiInACan::Runner do
|
|
46
44
|
|
47
45
|
build.repo = Object.new
|
48
46
|
build.sha = Object.new
|
49
|
-
|
47
|
+
CiInACan::Github.expects(:report_pending_status_for).with build
|
50
48
|
|
51
49
|
CiInACan::Runner.run build
|
52
50
|
end
|
@@ -7,32 +7,14 @@ describe CiInACan::TestResultNotifier do
|
|
7
7
|
let(:build) { CiInACan::Build.new }
|
8
8
|
let(:test_result) { CiInACan::TestResult.new }
|
9
9
|
|
10
|
-
it "should mark
|
10
|
+
it "should mark the results in github" do
|
11
11
|
|
12
12
|
test_result.passed = true
|
13
13
|
|
14
14
|
build.sha = Object.new
|
15
15
|
build.repo = Object.new
|
16
16
|
|
17
|
-
|
18
|
-
CiInACan::Github.stubs(:client).returns client
|
19
|
-
|
20
|
-
client.expects(:create_status).with(build.repo, build.sha, "success")
|
21
|
-
|
22
|
-
CiInACan::TestResultNotifier.send_for build, test_result
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should mark failing tests as failure in github" do
|
26
|
-
|
27
|
-
test_result.passed = false
|
28
|
-
|
29
|
-
build.sha = Object.new
|
30
|
-
build.repo = Object.new
|
31
|
-
|
32
|
-
client = Object.new
|
33
|
-
CiInACan::Github.stubs(:client).returns client
|
34
|
-
|
35
|
-
client.expects(:create_status).with(build.repo, build.sha, "failure")
|
17
|
+
CiInACan::Github.expects(:report_complete_status_for).with build, test_result
|
36
18
|
|
37
19
|
CiInACan::TestResultNotifier.send_for build, test_result
|
38
20
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe CiInACan::TestRunner do
|
4
|
+
|
5
|
+
describe "create" do
|
6
|
+
it "should set a unique id" do
|
7
|
+
id = Object.new
|
8
|
+
uuid = Object.new
|
9
|
+
|
10
|
+
UUID.stubs(:new).returns uuid
|
11
|
+
uuid.expects(:generate).returns id
|
12
|
+
|
13
|
+
test_result = CiInACan::TestResult.create({})
|
14
|
+
|
15
|
+
test_result.id.must_be_same_as id
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "create and find" do
|
20
|
+
|
21
|
+
describe "a simple example" do
|
22
|
+
|
23
|
+
it "should be able to store and retrieve a result" do
|
24
|
+
|
25
|
+
original_test_result = CiInACan::TestResult.create({})
|
26
|
+
retrieved_test_result = CiInACan::TestResult.find original_test_result.id
|
27
|
+
|
28
|
+
original_test_result.id.must_equal retrieved_test_result.id
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should be persist values" do
|
33
|
+
|
34
|
+
values = { passed: true, output: 'some output' }
|
35
|
+
original_test_result = CiInACan::TestResult.create(values)
|
36
|
+
retrieved_test_result = CiInACan::TestResult.find original_test_result.id
|
37
|
+
|
38
|
+
retrieved_test_result.contrast_with! values
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "a more complicated example" do
|
45
|
+
|
46
|
+
it "should be able to store and retrieve a result" do
|
47
|
+
|
48
|
+
# save more records
|
49
|
+
CiInACan::TestResult.create({})
|
50
|
+
CiInACan::TestResult.create({})
|
51
|
+
original_test_result = CiInACan::TestResult.create({})
|
52
|
+
CiInACan::TestResult.create({})
|
53
|
+
CiInACan::TestResult.create({})
|
54
|
+
|
55
|
+
retrieved_test_result = CiInACan::TestResult.find original_test_result.id
|
56
|
+
|
57
|
+
original_test_result.id.must_equal retrieved_test_result.id
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -11,8 +11,10 @@ describe CiInACan::TestRunner do
|
|
11
11
|
|
12
12
|
let(:build) { CiInACan::Build.new }
|
13
13
|
|
14
|
+
let(:bash_result) { CiInACan::BashResult.new }
|
15
|
+
|
14
16
|
before do
|
15
|
-
CiInACan::Bash.stubs(:run)
|
17
|
+
CiInACan::Bash.stubs(:run).returns bash_result
|
16
18
|
end
|
17
19
|
|
18
20
|
describe "when no special commands exist" do
|
@@ -20,7 +22,7 @@ describe CiInACan::TestRunner do
|
|
20
22
|
it "should cd into the local directory and run the default rake task" do
|
21
23
|
build.local_location = test.local_location
|
22
24
|
|
23
|
-
CiInACan::Bash.expects(:run).with("cd #{test.local_location}; bundle install; bundle exec rake")
|
25
|
+
CiInACan::Bash.expects(:run).with("cd #{test.local_location}; bundle install; bundle exec rake").returns bash_result
|
24
26
|
|
25
27
|
CiInACan::TestRunner.run_tests_for build
|
26
28
|
end
|
@@ -30,14 +32,28 @@ describe CiInACan::TestRunner do
|
|
30
32
|
result.is_a?(CiInACan::TestResult).must_equal true
|
31
33
|
end
|
32
34
|
|
35
|
+
it "should use the create method to create the TestResult" do
|
36
|
+
|
37
|
+
CiInACan::TestResult.expects(:new).never
|
38
|
+
CiInACan::TestResult.expects(:create).with { |v| true }.once
|
39
|
+
CiInACan::TestRunner.run_tests_for build
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should pass the output value from the bash result" do
|
43
|
+
output = Object.new
|
44
|
+
bash_result.stubs(:output).returns output
|
45
|
+
result = CiInACan::TestRunner.run_tests_for build
|
46
|
+
result.output.must_be_same_as output
|
47
|
+
end
|
48
|
+
|
33
49
|
it "should return a passed test result if the command returns true" do
|
34
|
-
|
50
|
+
bash_result.stubs(:successful).returns true
|
35
51
|
result = CiInACan::TestRunner.run_tests_for build
|
36
52
|
result.passed.must_equal true
|
37
53
|
end
|
38
54
|
|
39
55
|
it "should return a failed test result if the command returns true" do
|
40
|
-
|
56
|
+
bash_result.stubs(:successful).returns false
|
41
57
|
result = CiInACan::TestRunner.run_tests_for build
|
42
58
|
result.passed.must_equal false
|
43
59
|
end
|
@@ -51,7 +67,7 @@ describe CiInACan::TestRunner do
|
|
51
67
|
|
52
68
|
build.pre_test_commands = ["1", "2"]
|
53
69
|
|
54
|
-
CiInACan::Bash.expects(:run).with("cd #{test.local_location}; bundle install; 1; 2; bundle exec rake")
|
70
|
+
CiInACan::Bash.expects(:run).with("cd #{test.local_location}; bundle install; 1; 2; bundle exec rake").returns bash_result
|
55
71
|
|
56
72
|
CiInACan::TestRunner.run_tests_for build
|
57
73
|
end
|
@@ -86,7 +86,7 @@ describe CiInACan::Watcher do
|
|
86
86
|
|
87
87
|
describe "setting the local location" do
|
88
88
|
|
89
|
-
it "should assign the local location on the build" do
|
89
|
+
it "should assign the local location on the build, and the id" do
|
90
90
|
|
91
91
|
CiInACan::Runner.stubs(:wl).returns test.working_location
|
92
92
|
|
@@ -96,6 +96,7 @@ describe CiInACan::Watcher do
|
|
96
96
|
|
97
97
|
CiInACan::Runner.expects(:run).with do |b|
|
98
98
|
b.local_location.must_equal "#{test.working_location}/#{test.random_string}"
|
99
|
+
b.id.must_equal test.random_string
|
99
100
|
true
|
100
101
|
end
|
101
102
|
|
data/spec/spec_helper.rb
CHANGED
data/spec/temp/.gitkeep
ADDED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci_in_a_can
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Cauthon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: contrast
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +164,20 @@ dependencies:
|
|
150
164
|
- - '>='
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: subtle
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
153
181
|
description: Fast CI. Still a WIP.
|
154
182
|
email:
|
155
183
|
- darren@cauthon.com
|
@@ -169,10 +197,12 @@ files:
|
|
169
197
|
- lib/ci_in_a_can.rb
|
170
198
|
- lib/ci_in_a_can/app.rb
|
171
199
|
- lib/ci_in_a_can/bash.rb
|
200
|
+
- lib/ci_in_a_can/bash_result.rb
|
172
201
|
- lib/ci_in_a_can/build.rb
|
173
202
|
- lib/ci_in_a_can/cloner.rb
|
174
203
|
- lib/ci_in_a_can/daemon.rb
|
175
204
|
- lib/ci_in_a_can/github.rb
|
205
|
+
- lib/ci_in_a_can/persistence.rb
|
176
206
|
- lib/ci_in_a_can/runner.rb
|
177
207
|
- lib/ci_in_a_can/test_result.rb
|
178
208
|
- lib/ci_in_a_can/test_result_notifier.rb
|
@@ -180,15 +210,18 @@ files:
|
|
180
210
|
- lib/ci_in_a_can/version.rb
|
181
211
|
- lib/ci_in_a_can/watcher.rb
|
182
212
|
- sample.json
|
213
|
+
- spec/ci_in_a_can/bash_result_spec.rb
|
183
214
|
- spec/ci_in_a_can/bash_spec.rb
|
184
215
|
- spec/ci_in_a_can/build_spec.rb
|
185
216
|
- spec/ci_in_a_can/cloner_spec.rb
|
186
217
|
- spec/ci_in_a_can/github_spec.rb
|
187
218
|
- spec/ci_in_a_can/runner_spec.rb
|
188
219
|
- spec/ci_in_a_can/test_result_notifier_spec.rb
|
220
|
+
- spec/ci_in_a_can/test_result_spec.rb
|
189
221
|
- spec/ci_in_a_can/test_runner_spec.rb
|
190
222
|
- spec/ci_in_a_can/watcher_spec.rb
|
191
223
|
- spec/spec_helper.rb
|
224
|
+
- spec/temp/.gitkeep
|
192
225
|
homepage: ''
|
193
226
|
licenses:
|
194
227
|
- MIT
|
@@ -214,12 +247,15 @@ signing_key:
|
|
214
247
|
specification_version: 4
|
215
248
|
summary: Fast CI. Still a WIP.
|
216
249
|
test_files:
|
250
|
+
- spec/ci_in_a_can/bash_result_spec.rb
|
217
251
|
- spec/ci_in_a_can/bash_spec.rb
|
218
252
|
- spec/ci_in_a_can/build_spec.rb
|
219
253
|
- spec/ci_in_a_can/cloner_spec.rb
|
220
254
|
- spec/ci_in_a_can/github_spec.rb
|
221
255
|
- spec/ci_in_a_can/runner_spec.rb
|
222
256
|
- spec/ci_in_a_can/test_result_notifier_spec.rb
|
257
|
+
- spec/ci_in_a_can/test_result_spec.rb
|
223
258
|
- spec/ci_in_a_can/test_runner_spec.rb
|
224
259
|
- spec/ci_in_a_can/watcher_spec.rb
|
225
260
|
- spec/spec_helper.rb
|
261
|
+
- spec/temp/.gitkeep
|