cucumber-puppet 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.
- data/VERSION.yml +3 -3
- data/bin/cucumber-puppet +99 -12
- data/bin/cucumber-puppet-gen +18 -13
- data/lib/cucumber-puppet/helper.rb +65 -0
- data/lib/cucumber-puppet/puppet.rb +1 -2
- data/lib/cucumber-puppet/rake/task.rb +48 -0
- metadata +12 -10
data/VERSION.yml
CHANGED
data/bin/cucumber-puppet
CHANGED
@@ -1,20 +1,107 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require 'rubygems'
|
4
|
+
require 'cucumber-puppet'
|
5
|
+
require 'cucumber-puppet/helper'
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
include CucumberPuppet::Helper
|
9
|
+
|
10
|
+
options = []
|
11
|
+
opts = OptionParser.new do |o|
|
12
|
+
o.banner = "Usage: cucumber-puppet [options] <feature> [<feature> ...]"
|
13
|
+
|
14
|
+
o.on('-b', '--backtrace', 'Show full backtrace for all errors') do
|
15
|
+
options << "--backtrace "
|
16
|
+
end
|
17
|
+
|
18
|
+
o.on('-e', '--exclude PATTERN',
|
19
|
+
'Exclude files matching PATTERN') do |pattern|
|
20
|
+
options << "--exclude #{pattern}"
|
21
|
+
end
|
22
|
+
|
23
|
+
o.on('-f', '--format FORMAT',
|
24
|
+
'How to format features (default: pretty)',
|
25
|
+
' see "cucumber --help" for details') do |format|
|
26
|
+
options << "--format #{format}"
|
27
|
+
end
|
28
|
+
|
29
|
+
o.on('-h', '--help', 'Show this message') do
|
30
|
+
puts opts
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
|
34
|
+
o.on('-n', '--name NAME',
|
35
|
+
'Only run matching feature elements',
|
36
|
+
' see "cucumber --help" for details') do |n|
|
37
|
+
options << "--name #{n}"
|
38
|
+
end
|
39
|
+
|
40
|
+
o.on('-o', '--out FILE|DIR',
|
41
|
+
'Write output to file/directory',
|
42
|
+
' see "cucumber --help" for details') do |f|
|
43
|
+
options << "--out #{f}"
|
44
|
+
end
|
45
|
+
|
46
|
+
o.on('-t', '--tags TAG_EXPRESSION',
|
47
|
+
'Only run features/scenarios matching expr',
|
48
|
+
' see "cucumber --help" for details') do |t|
|
49
|
+
options << "--tags #{t}"
|
50
|
+
end
|
51
|
+
|
52
|
+
o.on('-v', '--verbose', 'Show files and features loaded') do
|
53
|
+
options << "--verbose"
|
54
|
+
end
|
55
|
+
|
56
|
+
o.on('--version', 'Show version number') do
|
57
|
+
puts CucumberPuppet::VERSION
|
58
|
+
exit
|
59
|
+
end
|
60
|
+
|
61
|
+
o.on('-x', '--expand', 'Expand Scenario Outline Tables in output') do
|
62
|
+
options << "--expand"
|
63
|
+
end
|
6
64
|
end
|
7
65
|
|
8
|
-
|
9
|
-
|
10
|
-
|
66
|
+
begin
|
67
|
+
opts.parse!
|
68
|
+
rescue OptionParser::InvalidOption
|
69
|
+
puts opts
|
70
|
+
exit 1
|
71
|
+
end
|
11
72
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
command << "--require #{features_dir} "
|
73
|
+
unless ARGV[0]
|
74
|
+
puts opts
|
75
|
+
exit 1
|
16
76
|
end
|
17
77
|
|
18
|
-
command
|
78
|
+
command = []
|
79
|
+
command << "cucumber --strict"
|
80
|
+
|
81
|
+
cwd = Dir.getwd
|
82
|
+
root = find_root(cwd)
|
83
|
+
command << "--require #{root}/features"
|
84
|
+
command << options
|
85
|
+
|
86
|
+
abs_root = File.expand_path(root)
|
87
|
+
ARGV.each do |f|
|
88
|
+
if not File.exists?(f)
|
89
|
+
puts "No such file or directory: #{f}"
|
90
|
+
exit 1
|
91
|
+
end
|
92
|
+
|
93
|
+
abs_f = File.expand_path(f).split('/')
|
94
|
+
until abs_f.empty?
|
95
|
+
if abs_f.last == 'features'
|
96
|
+
command << "--require " + abs_f.join('/')
|
97
|
+
break
|
98
|
+
elsif abs_f.join('/') == abs_root
|
99
|
+
break
|
100
|
+
end
|
101
|
+
abs_f.pop
|
102
|
+
end
|
103
|
+
|
104
|
+
command << f
|
105
|
+
end
|
19
106
|
|
20
|
-
system(command) ? exit(0) : exit(1)
|
107
|
+
system(command.join(' ')) ? exit(0) : exit(1)
|
data/bin/cucumber-puppet-gen
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'cucumber-puppet'
|
5
|
+
require 'cucumber-puppet/helper'
|
5
6
|
require 'templater'
|
6
7
|
|
7
8
|
module CucumberPuppetGenerators
|
@@ -9,12 +10,14 @@ module CucumberPuppetGenerators
|
|
9
10
|
extend Templater::Manifold
|
10
11
|
|
11
12
|
class FeatureGenerator < Templater::Generator
|
13
|
+
include CucumberPuppet::Helper
|
14
|
+
|
12
15
|
def source_root
|
13
16
|
File.join(File.dirname(__FILE__), '..', 'lib', 'generators', 'feature')
|
14
17
|
end
|
15
18
|
|
16
19
|
desc <<-DESC
|
17
|
-
Generate a cucumber feature
|
20
|
+
Generate a cucumber feature
|
18
21
|
cucumber-puppet-gen feature <module-name> <feature-name>
|
19
22
|
DESC
|
20
23
|
|
@@ -22,24 +25,29 @@ module CucumberPuppetGenerators
|
|
22
25
|
second_argument :feature, :required => true, :desc => "Feature name"
|
23
26
|
|
24
27
|
template :feature do |template|
|
28
|
+
destdir = find_destdir(mod)
|
29
|
+
|
25
30
|
template.source = "%feature_name%.feature"
|
26
|
-
template.destination = "
|
31
|
+
template.destination = "#{destdir}/#{feature}.feature"
|
27
32
|
end
|
28
33
|
end
|
29
34
|
|
30
35
|
class TestcaseGenerator < Templater::Generator
|
36
|
+
extend CucumberPuppet::Helper
|
37
|
+
|
31
38
|
def source_root
|
32
39
|
File.join(File.dirname(__FILE__), '..', 'lib', 'generators', 'testcase')
|
33
40
|
end
|
34
41
|
|
35
42
|
desc <<-DESC
|
36
|
-
Generate a test case for
|
43
|
+
Generate a test case for the test suite
|
37
44
|
cucumber-puppet-gen testcase
|
38
45
|
DESC
|
39
46
|
|
40
|
-
|
41
|
-
file('testcase.
|
42
|
-
file('
|
47
|
+
destdir = find_destdir('testcase')
|
48
|
+
file('testcase.feature', 'testcase.feature', "#{destdir}/testcase.feature")
|
49
|
+
file('testcase.rb', 'testcase.rb', "#{destdir}/support/testcase.rb")
|
50
|
+
file('site.pp', 'site.pp', "#{destdir}/site.pp")
|
43
51
|
end
|
44
52
|
|
45
53
|
class WorldGenerator < Templater::Generator
|
@@ -47,12 +55,9 @@ module CucumberPuppetGenerators
|
|
47
55
|
File.join(File.dirname(__FILE__), '..', 'lib', 'generators', 'world')
|
48
56
|
end
|
49
57
|
|
50
|
-
def destination_root
|
51
|
-
File.join(@destination_root, 'features')
|
52
|
-
end
|
53
58
|
|
54
59
|
desc <<-DESC
|
55
|
-
Generate cucumber step and support files
|
60
|
+
Generate cucumber step and support files
|
56
61
|
cucumber-puppet-gen world
|
57
62
|
DESC
|
58
63
|
|
@@ -60,11 +65,11 @@ module CucumberPuppetGenerators
|
|
60
65
|
|
61
66
|
template :version do |template|
|
62
67
|
template.source = "support/world.rb"
|
63
|
-
template.destination = "support/world.rb"
|
68
|
+
template.destination = "features/support/world.rb"
|
64
69
|
end
|
65
70
|
|
66
|
-
directory('steps', 'steps')
|
67
|
-
file('support/hooks.rb', 'support/hooks.rb')
|
71
|
+
directory('steps', 'steps', 'features/steps')
|
72
|
+
file('hooks.rb', 'support/hooks.rb', 'features/support/hooks.rb')
|
68
73
|
end
|
69
74
|
|
70
75
|
desc "Generators for cucumber-puppet"
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'cucumber-puppet'
|
2
|
+
|
3
|
+
module CucumberPuppet::Helper
|
4
|
+
# Finds the root of the puppet directory tree according to puppet's
|
5
|
+
# directory naming convention. Relevant sub-trees are:
|
6
|
+
# - <puppetdir>/features/modules/$module
|
7
|
+
# - <puppetdir>/modules/$module/features
|
8
|
+
# In case no tree is identified, assumes cwd is <puppetdir>.
|
9
|
+
def find_root(cwd)
|
10
|
+
path = cwd.split('/')
|
11
|
+
|
12
|
+
if cwd.match('features$') and not cwd.match("modules/")
|
13
|
+
# <puppetdir>/features
|
14
|
+
path.pop
|
15
|
+
elsif cwd.match('features/modules$')
|
16
|
+
# <puppetdir>/features/modules
|
17
|
+
path.pop(2)
|
18
|
+
elsif cwd.match('features/modules/[^/]*$')
|
19
|
+
# <puppetdir>/features/modules/$module
|
20
|
+
path.pop(3)
|
21
|
+
elsif cwd.match('modules$')
|
22
|
+
# <puppetdir>/modules
|
23
|
+
path.pop
|
24
|
+
elsif cwd.match('/modules/[^/]*$')
|
25
|
+
# <puppetdir>/modules/$module
|
26
|
+
path.pop(2)
|
27
|
+
elsif cwd.match('/modules/[^/]*/features$')
|
28
|
+
# <puppetdir>/modules/$module/features
|
29
|
+
path.pop(3)
|
30
|
+
end
|
31
|
+
|
32
|
+
path.join('/')
|
33
|
+
end
|
34
|
+
|
35
|
+
# Finds the destination path for feature files to install according to
|
36
|
+
# puppet's directory naming convention.
|
37
|
+
def find_destdir(mod)
|
38
|
+
cwd = Dir.getwd
|
39
|
+
|
40
|
+
if cwd.match("features$") and not cwd.match("modules/")
|
41
|
+
# <puppetdir>/features
|
42
|
+
destdir = "modules/#{mod}"
|
43
|
+
elsif cwd.match("features/modules$")
|
44
|
+
# <puppetdir>/features/modules
|
45
|
+
destdir = mod
|
46
|
+
elsif cwd.match("features/modules/#{mod}$")
|
47
|
+
# <puppetdir>/features/modules/$mod
|
48
|
+
destdir = "."
|
49
|
+
elsif cwd.match("modules$")
|
50
|
+
# <puppetdir>/modules
|
51
|
+
destdir = "#{mod}/features"
|
52
|
+
elsif cwd.match("modules/#{mod}$")
|
53
|
+
# <puppetdir>/modules/$mod
|
54
|
+
destdir = "features"
|
55
|
+
elsif cwd.match("modules/#{mod}/features$")
|
56
|
+
# <puppetdir>/modules/$mod/features
|
57
|
+
destdir = "."
|
58
|
+
else
|
59
|
+
# <puppetdir>
|
60
|
+
destdir = "features/modules/#{mod}"
|
61
|
+
end
|
62
|
+
|
63
|
+
destdir
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Defines a Rake task for running cucumber-puppet features.
|
2
|
+
#
|
3
|
+
# To create the basic task, call:
|
4
|
+
#
|
5
|
+
# CucumberPuppetRakeTask.new
|
6
|
+
#
|
7
|
+
# This defines a task 'cucumber_puppet' that will run features in 'features'
|
8
|
+
# and 'modules/**/features'.
|
9
|
+
#
|
10
|
+
# To further configure the task, you can pass a block:
|
11
|
+
#
|
12
|
+
# CucumberPuppetRakeTask.new do |t|
|
13
|
+
# t.cucumber_opts = %w{--format progress}
|
14
|
+
# end
|
15
|
+
|
16
|
+
class CucumberPuppetRakeTask
|
17
|
+
# extra options to pass to cucumber
|
18
|
+
attr_accessor :cucumber_opts
|
19
|
+
|
20
|
+
# an Array is preferred, so convert if String
|
21
|
+
def cucumber_opts=(opts)
|
22
|
+
@cucumber_opts = String === opts ? opts.split(' ') : opts
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
# define CucumberPuppet Rake task
|
27
|
+
def initialize(task_name = 'cucumber_puppet',
|
28
|
+
desc = 'Run cucumber-puppet features')
|
29
|
+
@task_name = task_name
|
30
|
+
@desc = desc
|
31
|
+
|
32
|
+
yield self if block_given?
|
33
|
+
|
34
|
+
define_task
|
35
|
+
end
|
36
|
+
|
37
|
+
def define_task
|
38
|
+
desc @desc
|
39
|
+
task @task_name do
|
40
|
+
command = []
|
41
|
+
command << "cucumber-puppet"
|
42
|
+
command << cucumber_opts
|
43
|
+
command << "features"
|
44
|
+
command << Dir.glob("modules/*/features")
|
45
|
+
exit 1 unless system(command.join(' '))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nikolay Sturm
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-25 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -57,18 +57,20 @@ files:
|
|
57
57
|
- bin/cucumber-puppet
|
58
58
|
- bin/cucumber-puppet-gen
|
59
59
|
- lib/cucumber-puppet.rb
|
60
|
+
- lib/cucumber-puppet/helper.rb
|
60
61
|
- lib/cucumber-puppet/puppet.rb
|
62
|
+
- lib/cucumber-puppet/rake/task.rb
|
61
63
|
- lib/generators/feature/%feature_name%.feature
|
64
|
+
- VERSION.yml
|
65
|
+
- lib/generators/world/support/world.rb
|
66
|
+
- lib/generators/world/support/hooks.rb
|
67
|
+
- lib/generators/world/steps/user.rb
|
68
|
+
- lib/generators/world/steps/puppet.rb
|
62
69
|
- lib/generators/world/steps/cron.rb
|
70
|
+
- lib/generators/world/steps/service.rb
|
71
|
+
- lib/generators/world/steps/package.rb
|
63
72
|
- lib/generators/world/steps/exec.rb
|
64
73
|
- lib/generators/world/steps/file.rb
|
65
|
-
- lib/generators/world/steps/package.rb
|
66
|
-
- lib/generators/world/steps/puppet.rb
|
67
|
-
- lib/generators/world/steps/service.rb
|
68
|
-
- lib/generators/world/steps/user.rb
|
69
|
-
- lib/generators/world/support/hooks.rb
|
70
|
-
- lib/generators/world/support/world.rb
|
71
|
-
- VERSION.yml
|
72
74
|
has_rdoc: true
|
73
75
|
homepage: http://github.com/nistude/cucumber-puppet/
|
74
76
|
licenses: []
|