-
Notifications
You must be signed in to change notification settings - Fork 19
/
Guardfile
70 lines (62 loc) · 1.78 KB
/
Guardfile
1
2
3
4
5
6
7
8
9
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# development testsuite
group 'bdd' do
guard 'cucumber', :cli => '--profile guard' do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { 'features/' }
watch(%r{^features/steps/(.+)\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features/' }
end
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| Dir["spec/#{m[1]}_spec.rb"][0] || 'spec/' }
watch('spec/spec_helper.rb') { 'spec/' }
end
end
# puppet step testsuite
require 'guard/guard'
require 'tmpdir'
module ::Guard
class Testsuite < ::Guard::Guard
def start
@basedir = File.dirname(__FILE__)
@testsuite = Dir.mktmpdir
Dir.chdir(@testsuite)
system "ruby -I#{@basedir}/lib #{@basedir}/bin/cucumber-puppet-gen world"
run_all
end
def stop
FileUtils.remove_entry_secure @testsuite
end
def reload
stop
start
end
def run_all
run_on_change('features')
end
def run_on_change(paths)
if paths[0] == 'reload'
reload
else
Dir.chdir(@testsuite)
system "ruby -I#{@basedir}/lib #{@basedir}/bin/cucumber-puppet-gen testsuite --force"
system "ruby -I#{@basedir}/lib #{@basedir}/bin/cucumber-puppet --format progress #{paths}"
end
end
end
end
group :puppet do
guard :testsuite do
watch(%r{^lib/generators/world/.+\.rb$}) { 'reload' }
watch(%r{^lib/generators/testsuite/(.+)\.feature$}) do |m|
"#{m[1]}.feature"
end
watch(%r{^lib/generators/testsuite/classes/(.+)\.pp$}) do |m|
feature = Dir[File.join("lib/generators/testsuite/**/#{m[1]}.feature")][0]
if feature
feature.gsub('lib/generators/testsuite/')
else
'features'
end
end
end
end