vagrant-rspec-ci 0.0.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +24 -0
- data/lib/vagrant-rspec-ci.rb +2 -30
- data/lib/vagrant-rspec-ci/command.rb +92 -81
- data/lib/vagrant-rspec-ci/command.rb~ +111 -0
- data/lib/vagrant-rspec-ci/config.rb +49 -54
- data/lib/vagrant-rspec-ci/config.rb~ +58 -0
- data/lib/vagrant-rspec-ci/plugin.rb +18 -0
- data/lib/vagrant-rspec-ci/plugin.rb~ +19 -0
- data/lib/vagrant-rspec-ci/version.rb +21 -0
- data/lib/vagrant-rspec-ci/version.rb~ +20 -0
- metadata +16 -11
- data/lib/vagrant_init.rb +0 -1
data/LICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2013, OmniTI Computer Consulting, Inc.
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
* Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
* Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
* Neither the name of OmniTI Computer Consulting, Inc. nor the
|
12
|
+
names of its contributors may be used to endorse or promote products
|
13
|
+
derived from this software without specific prior written permission.
|
14
|
+
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
16
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
19
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
22
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
23
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
24
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/lib/vagrant-rspec-ci.rb
CHANGED
@@ -1,30 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require "vagrant"
|
4
|
-
require "vagrant/util/subprocess"
|
5
|
-
require "vagrant-rspec-ci/config"
|
6
|
-
require "vagrant-rspec-ci/command"
|
7
|
-
|
8
|
-
|
9
|
-
module VagrantRspecCI
|
10
|
-
|
11
|
-
NAME = "vagrant-rspec-ci"
|
12
|
-
VERSION = "0.0.3"
|
13
|
-
AUTHOR = "Clinton Wolfe"
|
14
|
-
AUTHOR_EMAIL = "clintoncwolfe [at] gmail [dot] com"
|
15
|
-
DESCRIPTION = "vagrant-rspec-ci is a Vagrant plugin for running tests against your VMs, derived from vagrant-test"
|
16
|
-
URL = "http://github.com/clintoncwolfe/vagrant-rspec-ci"
|
17
|
-
|
18
|
-
V_ROOT = "/vagrant"
|
19
|
-
|
20
|
-
|
21
|
-
DEFAULT_RSPEC_BIN_PATH = "rspec"
|
22
|
-
DEFAULT_REPORTS_DIR = "rspec_reports"
|
23
|
-
DEFAULT_DIRS = [ "combined/spec_ext", "spec" ]
|
24
|
-
DEFAULT_TESTS = [ "*spec.rb" ]
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
Vagrant.config_keys.register(:rspec) { VagrantRspecCI::Config }
|
30
|
-
Vagrant.commands.register(:rspec) { VagrantRspecCI::Command }
|
1
|
+
require_relative "vagrant-rspec-ci/version"
|
2
|
+
require_relative "vagrant-rspec-ci/plugin"
|
@@ -1,106 +1,117 @@
|
|
1
|
-
module VagrantRspecCI
|
2
1
|
|
3
|
-
|
2
|
+
require "vagrant/util/subprocess" # TODO verify under vagrant 1.1
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
module VagrantPlugins
|
5
|
+
module VagrantRspecCI
|
6
|
+
class Command < Vagrant.plugin("2", "command")
|
7
|
+
|
8
|
+
def execute
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: vagrant rpsec [vm-name]"
|
11
|
+
end
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
13
|
+
argv = parse_options(opts)
|
14
|
+
return if !argv
|
15
|
+
|
16
|
+
with_target_vms(argv[0]) do |vm|
|
17
|
+
# vm.env.action_runner.run(Vagrant::Action::General::Validate, {:vm=>vm, :ui=>vm.ui})
|
18
|
+
|
19
|
+
s = vm.state.short_description
|
20
|
+
|
21
|
+
# TODO - VBox-specific machine state name?
|
22
|
+
if s != 'running'
|
23
|
+
vm.ui.error("VM not running. Not running tests.")
|
24
|
+
else
|
25
|
+
|
26
|
+
# If rpsec isn't explicitly mentioned in the Vagrantfile, the config will get initted but
|
27
|
+
# not finalized. Need to finalize to get defaults. Harmless to re-finalize anyway.
|
28
|
+
vm.config.rspec.finalize!
|
29
|
+
|
30
|
+
tests = expand_test_list(vm.config.rspec)
|
31
|
+
cmd = rspec_command(vm)
|
32
|
+
tests.each do |testfile|
|
33
|
+
vm.ui.info("Running rspec test: #{testfile}")
|
34
|
+
cmd = "#{cmd} #{testfile}"
|
35
|
+
env = prep_env(vm)
|
36
|
+
#puts("Command: #{cmd}")
|
37
|
+
#puts("Environment: #{env.inspect()}")
|
38
|
+
system(env, cmd)
|
39
|
+
result = $?
|
40
|
+
# rspec exits 0 if all passed, 1 if some failed - and system gives nil if there was a problem starting the process
|
41
|
+
if result.nil? then
|
42
|
+
vm.ui.error "Unable to execute rspec command: #{$!} \n #{cmd}"
|
43
|
+
elsif result.exitstatus == 1 then
|
44
|
+
vm.ui.warn "Rspec test #{testfile} has at least one failure - see report output for details"
|
45
|
+
elsif result.exitstatus == 0 then
|
46
|
+
vm.ui.success "Rspec test #{testfile} passed"
|
47
|
+
else
|
48
|
+
vm.ui.error "Unrecognized exit code from rspec: #{result.exitstatus}\nfor:#{cmd}"
|
49
|
+
end
|
39
50
|
end
|
40
|
-
end
|
41
51
|
|
42
|
-
|
43
|
-
|
44
|
-
|
52
|
+
if tests.empty?
|
53
|
+
vm.ui.info("No rspec tests found.")
|
54
|
+
end
|
45
55
|
|
56
|
+
end
|
46
57
|
end
|
47
58
|
end
|
48
|
-
end
|
49
59
|
|
50
|
-
|
60
|
+
private
|
51
61
|
|
52
|
-
|
53
|
-
|
54
|
-
|
62
|
+
def prep_env(vm)
|
63
|
+
env = {}
|
64
|
+
env["CI_REPORTS"] = vm.config.rspec.reports_dir
|
55
65
|
|
56
|
-
|
57
|
-
|
66
|
+
# Needed so vagrant-gemmed bins (like rspec) can find ruby_noexec_wrapper
|
67
|
+
env["PATH"] = ::Gem.bindir + ':' + ENV["PATH"]
|
58
68
|
|
59
|
-
|
60
|
-
|
69
|
+
env
|
70
|
+
end
|
61
71
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
72
|
+
def expand_test_list (rspec_config)
|
73
|
+
tests = rspec_config.tests.map { |filespec|
|
74
|
+
rspec_config.dirs.find_all { |dir| File.directory?(dir) }.map { |dir|
|
75
|
+
Dir.glob(File.join(dir, filespec))
|
76
|
+
}
|
77
|
+
}.flatten.uniq
|
78
|
+
end
|
69
79
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
80
|
+
def rspec_command (vm)
|
81
|
+
# Use gemset provided by Vagrant
|
82
|
+
# Cribbed from https://github.com/mitchellh/vagrant/blob/1-0-stable/lib/vagrant/command/gem.rb
|
83
|
+
ENV['GEM_HOME'] = vm.env.gems_path.to_s
|
84
|
+
::Gem.clear_paths
|
75
85
|
|
76
|
-
|
86
|
+
use_cir = vm.config.rspec.enable_ci_reporter
|
77
87
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
88
|
+
# Find ci_reporter rspec hook
|
89
|
+
if use_cir then
|
90
|
+
ci_hook_candidates = ::Gem.find_files('ci/reporter/rake/rspec_loader')
|
91
|
+
|
92
|
+
# TODO - bad assumption here, but if we find more than one, let's assume we can sort them and use the latest version.
|
93
|
+
ci_hook_path = (ci_hook_candidates.sort)[-1]
|
84
94
|
|
85
|
-
|
86
|
-
|
95
|
+
unless ci_hook_path then
|
96
|
+
raise "Could not find ci_reporter rspec hook - I expect ci_reporter to be installed as a gem under vagrant!"
|
97
|
+
end
|
87
98
|
end
|
88
|
-
end
|
89
99
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
100
|
+
# Find rspec
|
101
|
+
# TODO - even when you install it as a vagrant gem, it is not present in ::Gem.bindir :(
|
102
|
+
# Cross fingers?
|
103
|
+
rspec_path = vm.config.rspec.rspec_bin_path
|
104
|
+
|
105
|
+
cmd = ""
|
106
|
+
cmd << rspec_path
|
107
|
+
cmd << (use_cir ? " --require " + ci_hook_path + " --format CI::Reporter::RSpec" : "")
|
108
|
+
cmd << (use_cir && vm.config.rspec.suppress_ci_stdout ? " -o /dev/null " : "")
|
109
|
+
cmd << vm.config.rspec.dirs.map{ |d| " -I #{d}" }.join('')
|
94
110
|
|
95
|
-
|
96
|
-
|
97
|
-
cmd << (use_cir ? " --require " + ci_hook_path + " --format CI::Reporter::RSpec" : "")
|
98
|
-
cmd << (use_cir && vm.config.rspec.suppress_ci_stdout ? " -o /dev/null " : "")
|
99
|
-
cmd << vm.config.rspec.dirs.map{ |d| " -I #{d}" }.join('')
|
111
|
+
cmd
|
112
|
+
end
|
100
113
|
|
101
|
-
cmd
|
102
114
|
end
|
103
115
|
|
104
116
|
end
|
105
|
-
|
106
117
|
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
|
2
|
+
require "vagrant/util/subprocess" # TODO verify under vagrant 1.1
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module VagrantRspecCI
|
6
|
+
|
7
|
+
class Command < Vagrant::Command::Base
|
8
|
+
|
9
|
+
def execute
|
10
|
+
opts = OptionParser.new do |opts|
|
11
|
+
opts.banner = "Usage: vagrant rpsec [vm-name]"
|
12
|
+
end
|
13
|
+
|
14
|
+
argv = parse_options(opts)
|
15
|
+
return if !argv
|
16
|
+
|
17
|
+
with_target_vms(argv[0]) do |vm|
|
18
|
+
vm.env.action_runner.run(Vagrant::Action::General::Validate, {:vm=>vm, :ui=>vm.ui})
|
19
|
+
|
20
|
+
if !vm.created? || vm.state != :running
|
21
|
+
vm.ui.error("VM not running. Not running tests.")
|
22
|
+
else
|
23
|
+
|
24
|
+
tests = expand_test_list(vm.config.rspec)
|
25
|
+
cmd = rspec_command(vm)
|
26
|
+
tests.each do |testfile|
|
27
|
+
vm.ui.info("Running rspec test: #{testfile}")
|
28
|
+
cmd = "#{cmd} #{testfile}"
|
29
|
+
env = prep_env(vm)
|
30
|
+
@logger.debug("Command: #{cmd}")
|
31
|
+
@logger.debug("Environment: #{env.inspect()}")
|
32
|
+
system(env, cmd)
|
33
|
+
result = $?
|
34
|
+
# rspec exits 0 if all passed, 1 if some failed - and system gives nil if there was a problem starting the process
|
35
|
+
if result.nil? then
|
36
|
+
vm.ui.error "Unable to execute rspec command: #{$!} \n #{cmd}"
|
37
|
+
elsif result.exitstatus == 1 then
|
38
|
+
vm.ui.warn "Rspec test #{testfile} has at least one failure - see report output for details"
|
39
|
+
elsif result.exitstatus == 0 then
|
40
|
+
vm.ui.success "Rspec test #{testfile} passed"
|
41
|
+
else
|
42
|
+
vm.ui.error "Unrecognized exit code from rspec: #{result.exitstatus}\nfor:#{cmd}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
if tests.empty?
|
47
|
+
vm.ui.info("No rspec tests found.")
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def prep_env(vm)
|
57
|
+
env = {}
|
58
|
+
env["CI_REPORTS"] = vm.config.rspec.reports_dir
|
59
|
+
|
60
|
+
# Needed so vagrant-gemmed bins (like rspec) can find ruby_noexec_wrapper
|
61
|
+
env["PATH"] = ::Gem.bindir + ':' + ENV["PATH"]
|
62
|
+
|
63
|
+
env
|
64
|
+
end
|
65
|
+
|
66
|
+
def expand_test_list (rspec_config)
|
67
|
+
tests = rspec_config.tests.map { |filespec|
|
68
|
+
rspec_config.dirs.find_all { |dir| File.directory?(dir) }.map { |dir|
|
69
|
+
Dir.glob(File.join(dir, filespec))
|
70
|
+
}
|
71
|
+
}.flatten.uniq
|
72
|
+
end
|
73
|
+
|
74
|
+
def rspec_command (vm)
|
75
|
+
# Use gemset provided by Vagrant
|
76
|
+
# Cribbed from https://github.com/mitchellh/vagrant/blob/1-0-stable/lib/vagrant/command/gem.rb
|
77
|
+
ENV['GEM_HOME'] = vm.env.gems_path.to_s
|
78
|
+
::Gem.clear_paths
|
79
|
+
|
80
|
+
use_cir = vm.config.rspec.enable_ci_reporter
|
81
|
+
|
82
|
+
# Find ci_reporter rspec hook
|
83
|
+
if use_cir then
|
84
|
+
ci_hook_candidates = ::Gem.find_files('ci/reporter/rake/rspec_loader')
|
85
|
+
|
86
|
+
# TODO - bad assumption here, but if we find more than one, let's assume we can sort them and use the latest version.
|
87
|
+
ci_hook_path = (ci_hook_candidates.sort)[-1]
|
88
|
+
|
89
|
+
unless ci_hook_path then
|
90
|
+
raise "Could not find ci_reporter rspec hook - I expect ci_reporter to be installed as a gem under vagrant!"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Find rspec
|
95
|
+
# TODO - even when you install it as a vagrant gem, it is not present in ::Gem.bindir :(
|
96
|
+
# Cross fingers?
|
97
|
+
rspec_path = vm.config.rspec.rspec_bin_path
|
98
|
+
|
99
|
+
cmd = ""
|
100
|
+
cmd << rspec_path
|
101
|
+
cmd << (use_cir ? " --require " + ci_hook_path + " --format CI::Reporter::RSpec" : "")
|
102
|
+
cmd << (use_cir && vm.config.rspec.suppress_ci_stdout ? " -o /dev/null " : "")
|
103
|
+
cmd << vm.config.rspec.dirs.map{ |d| " -I #{d}" }.join('')
|
104
|
+
|
105
|
+
cmd
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
@@ -1,63 +1,58 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def rspec_bin_path
|
21
|
-
if @rpsec_bin_path then
|
22
|
-
return @rpsec_bin_path
|
23
|
-
else
|
24
|
-
guess = File.join(::Gem.bindir, 'rspec')
|
25
|
-
return File.exists?(guess) ? guess : DEFAULT_RSPEC_BIN_PATH
|
1
|
+
module VagrantPlugins
|
2
|
+
module VagrantRspecCI
|
3
|
+
|
4
|
+
class Config < Vagrant.plugin(2, :config)
|
5
|
+
|
6
|
+
attr_accessor :enable_ci_reporter,
|
7
|
+
:suppress_ci_stdout,
|
8
|
+
:rspec_bin_path,
|
9
|
+
:reports_dir,
|
10
|
+
:dirs,
|
11
|
+
:tests
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@enable_ci_reporter = UNSET_VALUE
|
15
|
+
@suppress_ci_stdout = UNSET_VALUE
|
16
|
+
@rspec_bin_path = UNSET_VALUE
|
17
|
+
@reports_dir = UNSET_VALUE
|
18
|
+
@dirs = UNSET_VALUE
|
19
|
+
@tests = UNSET_VALUE
|
26
20
|
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def reports_dir
|
30
|
-
@reports_dir || DEFAULT_REPORTS_DIR
|
31
|
-
end
|
32
|
-
|
33
|
-
def dirs
|
34
|
-
@dirs || DEFAULT_DIRS
|
35
|
-
end
|
36
21
|
|
37
|
-
|
38
|
-
|
39
|
-
|
22
|
+
def finalize!
|
23
|
+
# Set defaults if unset
|
24
|
+
@enable_ci_reporter = true if @enable_ci_reporter == UNSET_VALUE
|
25
|
+
@suppress_ci_stdout = true if @suppress_ci_stdout == UNSET_VALUE
|
26
|
+
@reports_dir = DEFAULT_REPORTS_DIR if @reports_dir == UNSET_VALUE
|
27
|
+
@dirs = DEFAULT_DIRS if @dirs == UNSET_VALUE
|
28
|
+
@tests = DEFAULT_TESTS if @tests == UNSET_VALUE
|
29
|
+
|
30
|
+
if @rspec_bin_path == UNSET_VALUE then
|
31
|
+
guess = File.join(::Gem.bindir, 'rspec')
|
32
|
+
@rspec_bin_path = File.exists?(guess) ? guess : DEFAULT_RSPEC_BIN_PATH
|
33
|
+
end
|
34
|
+
end
|
40
35
|
|
41
|
-
def validate(env, errors)
|
42
36
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
37
|
+
# TODO check args to this
|
38
|
+
def validate(machine)
|
39
|
+
errors = { "vagrant-rspec-ci" => [] }
|
40
|
+
|
41
|
+
[
|
42
|
+
:dirs,
|
43
|
+
:tests,
|
44
|
+
].each do |thing_sym|
|
45
|
+
# Each of these should be an array or enumerable.
|
46
|
+
value = self.send(thing_sym)
|
47
|
+
unless value.respond_to?(:each) then
|
48
|
+
errors["rspec"].push("config.rspec.#{thing_sym} should be an array")
|
49
|
+
end
|
52
50
|
end
|
51
|
+
|
52
|
+
# Must find at least one of the directory defaults
|
53
|
+
edir = self.dirs.find {|d| File.directory?(d) }
|
54
|
+
errors["rspec"].push("No test directory found - candidates: #{self.dirs.join(',')}") unless edir
|
53
55
|
end
|
54
|
-
|
55
|
-
# Must find at least one of the directory defaults
|
56
|
-
edir = self.dirs.find {|d| File.directory?(d) }
|
57
|
-
errors.add("No test directory found - candidates: #{self.dirs.join(',')}") unless edir
|
58
|
-
|
59
56
|
end
|
60
|
-
|
61
57
|
end
|
62
|
-
|
63
58
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module VagrantRspecCI
|
3
|
+
|
4
|
+
class Config < Vagrant.plugin(2, :config)
|
5
|
+
|
6
|
+
attr_accessor :enable_ci_reporter,
|
7
|
+
:suppress_ci_stdout,
|
8
|
+
:rspec_bin_path,
|
9
|
+
:reports_dir,
|
10
|
+
:dirs,
|
11
|
+
:tests
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@enable_ci_reporter = UNSET_VALUE
|
15
|
+
@suppress_ci_stdout = UNSET_VALUE
|
16
|
+
@rspec_bin_path = UNSET_VALUE
|
17
|
+
@reports_dir = UNSET_VALUE
|
18
|
+
@dirs = UNSET_VALUE
|
19
|
+
@tests = UNSET_VALUE
|
20
|
+
end
|
21
|
+
|
22
|
+
def finalize!
|
23
|
+
# Set defaults if unset
|
24
|
+
@enable_ci_reporter = true if @enable_ci_reporter == UNSET_VALUE
|
25
|
+
@suppress_ci_stdout = true if @suppress_ci_stdout == UNSET_VALUE
|
26
|
+
@reports_dir = DEFAULT_REPORTS_DIR if @reports_dirs == UNSET_VALUE
|
27
|
+
@dirs = DEFAULT_DIRS if @dirs == UNSET_VALUE
|
28
|
+
@tests = DEFAULT_TESTS if @tests == UNSET_VALUE
|
29
|
+
|
30
|
+
if @rpsec_bin_path == UNSET_VALUE then
|
31
|
+
guess = File.join(::Gem.bindir, 'rspec')
|
32
|
+
@rspec_bin_path = File.exists?(guess) ? guess : DEFAULT_RSPEC_BIN_PATH
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
# TODO check args to this
|
38
|
+
def validate(machine)
|
39
|
+
errors = { "vagrant-rspec-ci" => [] }
|
40
|
+
|
41
|
+
[
|
42
|
+
:dirs,
|
43
|
+
:tests,
|
44
|
+
].each do |thing_sym|
|
45
|
+
# Each of these should be an array or enumerable.
|
46
|
+
value = self.send(thing_sym)
|
47
|
+
unless value.respond_to?(:each) then
|
48
|
+
errors["rspec"].push("config.rspec.#{thing_sym} should be an array")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Must find at least one of the directory defaults
|
53
|
+
edir = self.dirs.find {|d| File.directory?(d) }
|
54
|
+
errors["rspec"].push("No test directory found - candidates: #{self.dirs.join(',')}") unless edir
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module VagrantRspecCI
|
3
|
+
class Plugin < Vagrant.plugin("2")
|
4
|
+
name "Run rspec tests against a VM, with jUnit output"
|
5
|
+
|
6
|
+
command "rspec" do
|
7
|
+
require_relative "command"
|
8
|
+
VagrantPlugins::VagrantRspecCI::Command
|
9
|
+
end
|
10
|
+
|
11
|
+
config "rspec" do
|
12
|
+
require_relative "config"
|
13
|
+
VagrantPlugins::VagrantRspecCI::Config
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module VagrantRspecCI
|
3
|
+
class Plugin < Vagrant.plugin("2")
|
4
|
+
name "Run rspec tests against a VM, with jUnit output"
|
5
|
+
|
6
|
+
#command "rspec" do
|
7
|
+
# require_relative "command"
|
8
|
+
# VagrantPlugins::VagrantRspecCI::Command
|
9
|
+
#end
|
10
|
+
|
11
|
+
config "rspec" do
|
12
|
+
puts ">>>>> in rspec config loader hook"
|
13
|
+
require_relative "config"
|
14
|
+
VagrantPlugins::VagrantRspecCI::Config
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module VagrantRspecCI
|
3
|
+
|
4
|
+
NAME = "vagrant-rspec-ci"
|
5
|
+
VERSION = "1.0.0"
|
6
|
+
AUTHOR = "Clinton Wolfe"
|
7
|
+
AUTHOR_EMAIL = "clintoncwolfe [at] gmail [dot] com"
|
8
|
+
DESCRIPTION = "vagrant-rspec-ci is a Vagrant 1.2.x plugin for running tests against your VMs, derived from vagrant-test"
|
9
|
+
SUMMARY = "Run rspec tests against a Vagrant VM test subject"
|
10
|
+
URL = "http://github.com/clintoncwolfe/vagrant-rspec-ci"
|
11
|
+
|
12
|
+
V_ROOT = "/vagrant"
|
13
|
+
|
14
|
+
|
15
|
+
DEFAULT_RSPEC_BIN_PATH = "rspec"
|
16
|
+
DEFAULT_REPORTS_DIR = "rspec_reports"
|
17
|
+
DEFAULT_DIRS = [ "combined/spec_ext", "spec" ]
|
18
|
+
DEFAULT_TESTS = [ "*spec.rb" ]
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module VagrantRspecCI
|
3
|
+
|
4
|
+
NAME = "vagrant-rspec-ci"
|
5
|
+
VERSION = "0.1.0"
|
6
|
+
AUTHOR = "Clinton Wolfe"
|
7
|
+
AUTHOR_EMAIL = "clintoncwolfe [at] gmail [dot] com"
|
8
|
+
DESCRIPTION = "vagrant-rspec-ci is a Vagrant plugin for running tests against your VMs, derived from vagrant-test"
|
9
|
+
URL = "http://github.com/clintoncwolfe/vagrant-rspec-ci"
|
10
|
+
|
11
|
+
V_ROOT = "/vagrant"
|
12
|
+
|
13
|
+
|
14
|
+
DEFAULT_RSPEC_BIN_PATH = "rspec"
|
15
|
+
DEFAULT_REPORTS_DIR = "rspec_reports"
|
16
|
+
DEFAULT_DIRS = [ "combined/spec_ext", "spec" ]
|
17
|
+
DEFAULT_TESTS = [ "*spec.rb" ]
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-rspec-ci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,16 +9,16 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: rspec
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0
|
21
|
+
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,9 +26,9 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0
|
29
|
+
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: ci_reporter
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
@@ -43,17 +43,23 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
-
description: vagrant-rspec-ci is a Vagrant plugin for running tests against
|
47
|
-
derived from vagrant-test
|
46
|
+
description: vagrant-rspec-ci is a Vagrant 1.2.x plugin for running tests against
|
47
|
+
your VMs, derived from vagrant-test
|
48
48
|
email: clintoncwolfe [at] gmail [dot] com
|
49
49
|
executables: []
|
50
50
|
extensions: []
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
53
|
- README.md
|
54
|
-
-
|
54
|
+
- LICENSE
|
55
55
|
- lib/vagrant-rspec-ci/command.rb
|
56
|
+
- lib/vagrant-rspec-ci/command.rb~
|
57
|
+
- lib/vagrant-rspec-ci/version.rb~
|
56
58
|
- lib/vagrant-rspec-ci/config.rb
|
59
|
+
- lib/vagrant-rspec-ci/plugin.rb
|
60
|
+
- lib/vagrant-rspec-ci/version.rb
|
61
|
+
- lib/vagrant-rspec-ci/config.rb~
|
62
|
+
- lib/vagrant-rspec-ci/plugin.rb~
|
57
63
|
- lib/vagrant-rspec-ci.rb
|
58
64
|
homepage: http://github.com/clintoncwolfe/vagrant-rspec-ci
|
59
65
|
licenses: []
|
@@ -78,6 +84,5 @@ rubyforge_project: vagrant-rspec-ci
|
|
78
84
|
rubygems_version: 1.8.24
|
79
85
|
signing_key:
|
80
86
|
specification_version: 3
|
81
|
-
summary:
|
82
|
-
derived from vagrant-test
|
87
|
+
summary: Run rspec tests against a Vagrant VM test subject
|
83
88
|
test_files: []
|
data/lib/vagrant_init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "vagrant-rspec-ci"
|