puppet-retrospec 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +281 -49
- data/VERSION +1 -1
- data/lib/retrospec/helpers.rb +8 -11
- data/lib/retrospec/puppet_module.rb +10 -2
- data/lib/retrospec/templates/acceptance_spec_test.erb +1 -1
- data/lib/retrospec/templates/{fixtures_file.erb → module_files/.fixtures.yml} +0 -0
- data/lib/retrospec/templates/module_files/.gitignore.erb +8 -0
- data/lib/retrospec/templates/{travis.yml.erb → module_files/.travis.yml} +0 -0
- data/lib/retrospec/templates/module_files/Gemfile +29 -0
- data/lib/retrospec/templates/{rakefile.erb → module_files/Rakefile} +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/centos-59-x64.yml +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/centos-64-x64-pe.yml +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/centos-64-x64.yml +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/centos-66-x64.yml +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/debian-607-x64.yml +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/debian-70rc1-x64.yml +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/debian-73-i386.yml +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/debian-73-x64.yml +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/default.yml +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/fedora-18-x64.yml +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/sles-11sp1-x64.yml +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/ubuntu-server-10044-x64.yml +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/ubuntu-server-12042-x64.yml +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/ubuntu-server-1310-x64.yml +0 -0
- data/lib/retrospec/templates/{nodesets → module_files/spec/acceptance/nodesets}/ubuntu-server-1404-x64.yml +0 -0
- data/lib/retrospec/templates/{shared_context.erb → module_files/spec/shared_contexts.rb} +2 -1
- data/lib/retrospec/templates/{spec_helper_file.erb → module_files/spec/spec_helper.rb} +1 -1
- data/lib/retrospec/templates/{spec_helper_acceptance.rb.erb → module_files/spec/spec_helper_acceptance.rb} +0 -0
- data/lib/retrospec/templates/resource_spec_file.erb +1 -1
- data/lib/retrospec.rb +25 -49
- data/puppet-retrospec.gemspec +28 -26
- data/spec/unit/puppet-retrospec_spec.rb +60 -41
- metadata +54 -52
- data/lib/retrospec/templates/gemfile.erb +0 -29
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require 'shared_contexts'
|
3
3
|
|
4
4
|
describe '<%= @type.name -%>' do
|
5
|
-
# by default the hiera integration uses
|
5
|
+
# by default the hiera integration uses hiera data from the shared_contexts.rb file
|
6
6
|
# but basically to mock hiera you first need to add a key/value pair
|
7
7
|
# to the specific context in the spec/shared_contexts.rb file
|
8
8
|
# Note: you can only use a single hiera context per describe/context block
|
data/lib/retrospec.rb
CHANGED
@@ -39,14 +39,7 @@ class Retrospec
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def create_files
|
42
|
-
|
43
|
-
safe_create_fixtures_file
|
44
|
-
safe_create_gemfile
|
45
|
-
safe_create_rakefile
|
46
|
-
safe_make_shared_context
|
47
|
-
safe_create_ci_file
|
48
|
-
safe_create_acceptance_spec_helper if spec_object.enable_beaker_tests?
|
49
|
-
safe_create_node_sets if spec_object.enable_beaker_tests?
|
42
|
+
safe_create_module_files
|
50
43
|
# a Type is nothing more than a defined type or puppet class
|
51
44
|
# we could have named this manifest but there could be multiple types
|
52
45
|
# in a manifest.
|
@@ -60,59 +53,42 @@ class Retrospec
|
|
60
53
|
true
|
61
54
|
end
|
62
55
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
56
|
+
# creates any file that is contained in the templates/modules_files directory structure
|
57
|
+
# loops through the directory looking for erb files, all other files are ignored.
|
58
|
+
# strips the erb extension and renders the template to the current module path
|
59
|
+
# filenames must named how they would appear in the normal module path. The directory
|
60
|
+
# structure where the file is contained
|
61
|
+
def safe_create_module_files
|
62
|
+
templates = Dir.glob(File.join(template_dir,'module_files', '**', '{*,.*}')).find_all {|t| File.file?(t)}
|
63
|
+
templates.each do |template|
|
64
|
+
# need to remove the erb extension and rework the destination path
|
65
|
+
if template =~ /nodesets|spec_helper_acceptance/ and !spec_object.enable_beaker_tests?
|
66
|
+
next
|
67
|
+
else
|
68
|
+
dest = template.gsub(File.join(template_dir,'module_files'), module_path).gsub('.erb', '')
|
69
|
+
safe_create_template_file(dest, template)
|
70
|
+
end
|
68
71
|
end
|
69
72
|
end
|
70
73
|
|
71
|
-
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
def safe_create_acceptance_spec_helper(template='spec_helper_acceptance.rb.erb')
|
76
|
-
safe_create_template_file(File.join('spec', 'spec_helper_acceptance.rb'), template)
|
77
|
-
end
|
78
|
-
|
79
|
-
def safe_create_rakefile(template='rakefile.erb')
|
80
|
-
safe_create_template_file('Rakefile', template)
|
81
|
-
end
|
82
|
-
|
83
|
-
def safe_make_shared_context(template='shared_context.erb')
|
84
|
-
safe_create_template_file(File.join('spec','shared_contexts.rb'), template)
|
85
|
-
end
|
86
|
-
|
87
|
-
def safe_create_fixtures_file(template='fixtures_file.erb')
|
88
|
-
safe_create_template_file('.fixtures.yml', template)
|
89
|
-
end
|
90
|
-
|
91
|
-
def safe_create_spec_helper(template='spec_helper_file.erb')
|
92
|
-
safe_create_template_file(File.join('spec','spec_helper.rb'), template)
|
93
|
-
end
|
94
|
-
|
95
|
-
def safe_create_gemfile(template='gemfile.erb')
|
96
|
-
safe_create_template_file('Gemfile', template)
|
97
|
-
end
|
98
|
-
|
74
|
+
# path is the full path of the file to create
|
75
|
+
# template is the full path to the template file
|
99
76
|
def safe_create_template_file(path, template)
|
100
77
|
# check to ensure parent directory exists
|
101
|
-
file_dir_path = File.expand_path(File.
|
78
|
+
file_dir_path = File.expand_path(File.dirname(path))
|
102
79
|
if ! File.exists?(file_dir_path)
|
103
80
|
Helpers.safe_mkdir(file_dir_path)
|
104
81
|
end
|
105
|
-
|
106
|
-
File.open(template_path) do |file|
|
82
|
+
File.open(template) do |file|
|
107
83
|
renderer = ERB.new(file.read, 0, '-')
|
108
84
|
content = renderer.result spec_object.get_binding
|
109
|
-
dest_path = File.expand_path(
|
85
|
+
dest_path = File.expand_path(path)
|
110
86
|
Helpers.safe_create_file(dest_path, content)
|
111
87
|
end
|
112
88
|
end
|
113
89
|
|
114
90
|
# Creates an associated spec file for each type and even creates the subfolders for nested classes one::two::three
|
115
|
-
def safe_create_resource_spec_files(type,template='resource_spec_file.erb')
|
91
|
+
def safe_create_resource_spec_files(type,template=File.join(template_dir,'resource_spec_file.erb'))
|
116
92
|
spec_object.parameters = type.arguments
|
117
93
|
spec_object.type = type
|
118
94
|
VariableStore.populate(type)
|
@@ -120,15 +96,15 @@ class Retrospec
|
|
120
96
|
# pass the type to the variable store and it will discover all the variables and try to resolve them.
|
121
97
|
# this does not get deep nested conditional blocks
|
122
98
|
spec_object.resources += Conditional.all(type)
|
123
|
-
file_path = generate_file_path(type, false)
|
99
|
+
file_path = File.join(module_path,generate_file_path(type, false))
|
124
100
|
safe_create_template_file(file_path, template)
|
125
101
|
file_path
|
126
102
|
end
|
127
103
|
|
128
|
-
def safe_create_acceptance_tests(type,template='acceptance_spec_test.erb')
|
104
|
+
def safe_create_acceptance_tests(type,template=File.join(template_dir,'acceptance_spec_test.erb'))
|
129
105
|
@parameters = type.arguments
|
130
106
|
@type = type
|
131
|
-
file_path = generate_file_path(type, true)
|
107
|
+
file_path = File.join(module_path,generate_file_path(type, true))
|
132
108
|
safe_create_template_file(file_path, template)
|
133
109
|
file_path
|
134
110
|
end
|
data/puppet-retrospec.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: puppet-retrospec 0.6.
|
5
|
+
# stub: puppet-retrospec 0.6.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "puppet-retrospec"
|
9
|
-
s.version = "0.6.
|
9
|
+
s.version = "0.6.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Corey Osman"]
|
14
|
-
s.date = "2015-03-
|
14
|
+
s.date = "2015-03-27"
|
15
15
|
s.description = "Retrofits and generates valid puppet rspec test code to existing modules"
|
16
16
|
s.email = "corey@logicminds.biz"
|
17
17
|
s.executables = ["retrospec"]
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
".document",
|
24
24
|
".rspec",
|
25
25
|
".travis.yml",
|
26
|
+
"CHANGELOG.md",
|
26
27
|
"Gemfile",
|
27
28
|
"LICENSE",
|
28
29
|
"README.md",
|
@@ -37,29 +38,30 @@ Gem::Specification.new do |s|
|
|
37
38
|
"lib/retrospec/resource.rb",
|
38
39
|
"lib/retrospec/spec_object.rb",
|
39
40
|
"lib/retrospec/templates/acceptance_spec_test.erb",
|
40
|
-
"lib/retrospec/templates/
|
41
|
-
"lib/retrospec/templates/
|
42
|
-
"lib/retrospec/templates/
|
43
|
-
"lib/retrospec/templates/
|
44
|
-
"lib/retrospec/templates/
|
45
|
-
"lib/retrospec/templates/nodesets/centos-
|
46
|
-
"lib/retrospec/templates/nodesets/
|
47
|
-
"lib/retrospec/templates/nodesets/
|
48
|
-
"lib/retrospec/templates/nodesets/
|
49
|
-
"lib/retrospec/templates/nodesets/debian-
|
50
|
-
"lib/retrospec/templates/nodesets/
|
51
|
-
"lib/retrospec/templates/nodesets/
|
52
|
-
"lib/retrospec/templates/nodesets/
|
53
|
-
"lib/retrospec/templates/nodesets/
|
54
|
-
"lib/retrospec/templates/nodesets/
|
55
|
-
"lib/retrospec/templates/nodesets/
|
56
|
-
"lib/retrospec/templates/nodesets/ubuntu-server-
|
57
|
-
"lib/retrospec/templates/
|
41
|
+
"lib/retrospec/templates/module_files/.fixtures.yml",
|
42
|
+
"lib/retrospec/templates/module_files/.gitignore.erb",
|
43
|
+
"lib/retrospec/templates/module_files/.travis.yml",
|
44
|
+
"lib/retrospec/templates/module_files/Gemfile",
|
45
|
+
"lib/retrospec/templates/module_files/Rakefile",
|
46
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/centos-59-x64.yml",
|
47
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/centos-64-x64-pe.yml",
|
48
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/centos-64-x64.yml",
|
49
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/centos-66-x64.yml",
|
50
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/debian-607-x64.yml",
|
51
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/debian-70rc1-x64.yml",
|
52
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/debian-73-i386.yml",
|
53
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/debian-73-x64.yml",
|
54
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/default.yml",
|
55
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/fedora-18-x64.yml",
|
56
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/sles-11sp1-x64.yml",
|
57
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml",
|
58
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml",
|
59
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/ubuntu-server-1310-x64.yml",
|
60
|
+
"lib/retrospec/templates/module_files/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml",
|
61
|
+
"lib/retrospec/templates/module_files/spec/shared_contexts.rb",
|
62
|
+
"lib/retrospec/templates/module_files/spec/spec_helper.rb",
|
63
|
+
"lib/retrospec/templates/module_files/spec/spec_helper_acceptance.rb",
|
58
64
|
"lib/retrospec/templates/resource_spec_file.erb",
|
59
|
-
"lib/retrospec/templates/shared_context.erb",
|
60
|
-
"lib/retrospec/templates/spec_helper_acceptance.rb.erb",
|
61
|
-
"lib/retrospec/templates/spec_helper_file.erb",
|
62
|
-
"lib/retrospec/templates/travis.yml.erb",
|
63
65
|
"lib/retrospec/type_code.rb",
|
64
66
|
"lib/retrospec/variable_store.rb",
|
65
67
|
"lib/retrospec/version.rb",
|
@@ -83,7 +85,7 @@ Gem::Specification.new do |s|
|
|
83
85
|
]
|
84
86
|
s.homepage = "http://github.com/logicminds/puppet-retrospec"
|
85
87
|
s.licenses = ["MIT"]
|
86
|
-
s.rubygems_version = "2.4.
|
88
|
+
s.rubygems_version = "2.4.5"
|
87
89
|
s.summary = "Generates puppet rspec test code based on the classes and defines inside the manifests directory. Aims to reduce some of the boilerplate coding with default test patterns."
|
88
90
|
|
89
91
|
if s.respond_to? :specification_version then
|
@@ -30,9 +30,11 @@ describe "puppet-retrospec" do
|
|
30
30
|
|
31
31
|
it 'should create files without error' do
|
32
32
|
tomcat = Retrospec.new(@opts[:module_path], @opts)
|
33
|
-
|
33
|
+
tomcat.create_files
|
34
34
|
expect(File.exists?(File.join(@path, 'Gemfile'))).to eq(true)
|
35
35
|
expect(File.exists?(File.join(@path, 'Rakefile'))).to eq(true)
|
36
|
+
expect(File.exists?(File.join(@path, 'spec','spec_helper.rb'))).to eq(true)
|
37
|
+
expect(File.exists?(File.join(@path, '.travis.yml'))).to eq(true)
|
36
38
|
expect(File.exists?(File.join(@path, 'spec', 'shared_contexts.rb'))).to eq(true)
|
37
39
|
expect(File.exists?(File.join(@path, '.fixtures.yml'))).to eq(true)
|
38
40
|
expect(File.exists?(File.join(@path, 'spec','classes','tomcat_spec.rb'))).to eq(true)
|
@@ -68,54 +70,58 @@ describe "puppet-retrospec" do
|
|
68
70
|
@opts[:enable_user_templates] = true
|
69
71
|
FakeFS do
|
70
72
|
user_directory = Helpers.default_user_template_dir
|
71
|
-
FileUtils.mkdir_p(Helpers.gem_template_dir)
|
72
|
-
FileUtils.touch(File.join(Helpers.gem_template_dir, '
|
73
|
+
FileUtils.mkdir_p(File.join(Helpers.gem_template_dir, 'module_files', 'spec', 'acceptance','nodesets'))
|
74
|
+
FileUtils.touch(File.join(Helpers.gem_template_dir, 'module_files', '.fixtures.yml'))
|
73
75
|
FileUtils.touch(File.join(Helpers.gem_template_dir, 'resource_spec_file.erb'))
|
74
|
-
FileUtils.touch(File.join(Helpers.gem_template_dir, '
|
75
|
-
FileUtils.touch(File.join(Helpers.gem_template_dir, '
|
76
|
-
FileUtils.touch(File.join(Helpers.gem_template_dir, '
|
77
|
-
FileUtils.
|
78
|
-
FileUtils.touch(File.join(Helpers.gem_template_dir, 'nodesets', 'default.yml'))
|
76
|
+
FileUtils.touch(File.join(Helpers.gem_template_dir, 'module_files', 'spec','shared_contexts.rb'))
|
77
|
+
FileUtils.touch(File.join(Helpers.gem_template_dir, 'module_files', 'spec','spec_helper.rb'))
|
78
|
+
FileUtils.touch(File.join(Helpers.gem_template_dir, 'module_files','Gemfile'))
|
79
|
+
FileUtils.touch(File.join(Helpers.gem_template_dir, 'module_files','Rakefile'))
|
80
|
+
FileUtils.touch(File.join(Helpers.gem_template_dir, 'module_files', 'spec', 'acceptance','nodesets', 'default.yml'))
|
79
81
|
FileUtils.mkdir_p('/modules/tomcat/manifests')
|
80
|
-
FileUtils.
|
82
|
+
#FileUtils.open('/modules/tomcat/manifests/init.pp', 'w') {|f| f.write("class tomcat(){}")}
|
81
83
|
@opts[:module_path] = '/modules/tomcat'
|
82
84
|
Retrospec.new(@opts[:module_path], @opts)
|
83
85
|
expect(File.exists?(user_directory)).to eq(true)
|
84
|
-
expect(File.exists?(File.join(user_directory, '
|
85
|
-
expect(File.exists?(File.join(user_directory, '
|
86
|
+
expect(File.exists?(File.join(user_directory, 'module_files', '.fixtures.yml'))).to eq(true)
|
87
|
+
expect(File.exists?(File.join(user_directory, 'module_files','Gemfile'))).to eq(true)
|
86
88
|
expect(File.exists?(File.join(user_directory, 'resource_spec_file.erb'))).to eq(true)
|
87
|
-
expect(File.exists?(File.join(user_directory, '
|
88
|
-
expect(File.exists?(File.join(user_directory, '
|
89
|
-
expect(File.exists?(File.join(user_directory, 'nodesets'))).to eq(true)
|
90
|
-
expect(File.exists?(File.join(user_directory, 'nodesets',
|
89
|
+
expect(File.exists?(File.join(user_directory, 'module_files','spec','shared_contexts.rb'))).to eq(true)
|
90
|
+
expect(File.exists?(File.join(user_directory, 'module_files','spec','spec_helper.rb'))).to eq(true)
|
91
|
+
expect(File.exists?(File.join(user_directory, 'module_files','spec','acceptance','nodesets'))).to eq(true)
|
92
|
+
expect(File.exists?(File.join(user_directory, 'module_files','spec','acceptance','nodesets','default.yml'))).to eq(true)
|
93
|
+
expect(File.exists?(File.join(user_directory, 'module_files','Rakefile'))).to eq(true)
|
94
|
+
|
91
95
|
end
|
92
96
|
end
|
93
97
|
|
94
98
|
it 'should create the user supplied templates directory when variable is set' do
|
95
99
|
@opts[:template_dir] = '/tmp/my_templates'
|
96
100
|
FakeFS do
|
97
|
-
FileUtils.mkdir_p(Helpers.gem_template_dir)
|
98
|
-
FileUtils.touch(File.join(Helpers.gem_template_dir, '
|
101
|
+
FileUtils.mkdir_p(File.join(Helpers.gem_template_dir, 'module_files', 'spec', 'acceptance','nodesets'))
|
102
|
+
FileUtils.touch(File.join(Helpers.gem_template_dir, 'module_files', '.fixtures.yml'))
|
99
103
|
FileUtils.touch(File.join(Helpers.gem_template_dir, 'resource_spec_file.erb'))
|
100
|
-
FileUtils.touch(File.join(Helpers.gem_template_dir, '
|
101
|
-
FileUtils.touch(File.join(Helpers.gem_template_dir, '
|
102
|
-
FileUtils.touch(File.join(Helpers.gem_template_dir, '
|
103
|
-
FileUtils.
|
104
|
-
FileUtils.touch(File.join(Helpers.gem_template_dir, 'nodesets', 'default.yml'))
|
104
|
+
FileUtils.touch(File.join(Helpers.gem_template_dir, 'module_files', 'spec','shared_contexts.rb'))
|
105
|
+
FileUtils.touch(File.join(Helpers.gem_template_dir, 'module_files', 'spec','spec_helper.rb'))
|
106
|
+
FileUtils.touch(File.join(Helpers.gem_template_dir, 'module_files','Gemfile'))
|
107
|
+
FileUtils.touch(File.join(Helpers.gem_template_dir, 'module_files','Rakefile'))
|
108
|
+
FileUtils.touch(File.join(Helpers.gem_template_dir, 'module_files', 'spec', 'acceptance','nodesets', 'default.yml'))
|
105
109
|
FileUtils.mkdir_p('/modules/tomcat/manifests')
|
106
|
-
FileUtils.
|
110
|
+
#FileUtils.open('/modules/tomcat/manifests/init.pp', 'w') {|f| f.write("class tomcat(){}")}
|
107
111
|
@opts[:module_path] = '/modules/tomcat'
|
108
112
|
r = Retrospec.new(@opts[:module_path], @opts)
|
109
113
|
user_directory = r.template_dir
|
110
114
|
expect(user_directory).to eq('/tmp/my_templates')
|
111
115
|
expect(File.exists?(user_directory)).to eq(true)
|
112
|
-
expect(File.exists?(File.join(user_directory, '
|
113
|
-
expect(File.exists?(File.join(user_directory, '
|
116
|
+
expect(File.exists?(File.join(user_directory, 'module_files', '.fixtures.yml'))).to eq(true)
|
117
|
+
expect(File.exists?(File.join(user_directory, 'module_files','Gemfile'))).to eq(true)
|
114
118
|
expect(File.exists?(File.join(user_directory, 'resource_spec_file.erb'))).to eq(true)
|
115
|
-
expect(File.exists?(File.join(user_directory, '
|
116
|
-
expect(File.exists?(File.join(user_directory, '
|
117
|
-
expect(File.exists?(File.join(user_directory, 'nodesets'))).to eq(true)
|
118
|
-
expect(File.exists?(File.join(user_directory, 'nodesets',
|
119
|
+
expect(File.exists?(File.join(user_directory, 'module_files','spec','shared_contexts.rb'))).to eq(true)
|
120
|
+
expect(File.exists?(File.join(user_directory, 'module_files','spec','spec_helper.rb'))).to eq(true)
|
121
|
+
expect(File.exists?(File.join(user_directory, 'module_files','spec','acceptance','nodesets'))).to eq(true)
|
122
|
+
expect(File.exists?(File.join(user_directory, 'module_files','spec','acceptance','nodesets','default.yml'))).to eq(true)
|
123
|
+
expect(File.exists?(File.join(user_directory, 'module_files','Rakefile'))).to eq(true)
|
124
|
+
|
119
125
|
end
|
120
126
|
|
121
127
|
end
|
@@ -123,45 +129,58 @@ describe "puppet-retrospec" do
|
|
123
129
|
it 'should create proper spec helper file' do
|
124
130
|
tomcat = Retrospec.new(@opts[:module_path], @opts)
|
125
131
|
filepath = File.expand_path(File.join(@path, 'spec', 'spec_helper.rb'))
|
132
|
+
tomcat.safe_create_module_files
|
126
133
|
path = tomcat.module_path
|
127
|
-
tomcat.safe_create_spec_helper
|
128
134
|
expect(File.exists?(filepath)).to eq(true)
|
129
135
|
end
|
130
136
|
|
131
137
|
it 'should create proper shared context file' do
|
132
138
|
tomcat = Retrospec.new(@opts[:module_path], @opts)
|
133
139
|
filepath = File.expand_path(File.join(@path, 'spec', 'shared_contexts.rb'))
|
140
|
+
tomcat.safe_create_module_files
|
134
141
|
path = tomcat.module_path
|
135
|
-
tomcat.safe_make_shared_context
|
136
142
|
expect(File.exists?(filepath)).to eq(true)
|
137
143
|
end
|
138
144
|
|
139
145
|
it 'should create acceptance spec helper file' do
|
140
|
-
|
146
|
+
opts = {:module_path => @path, :enable_beaker_tests => true,
|
147
|
+
:enable_user_templates => false, :template_dir => nil }
|
148
|
+
tomcat = Retrospec.new(@opts[:module_path], opts)
|
141
149
|
filepath = File.expand_path(File.join(@path, 'spec', 'spec_helper_acceptance.rb'))
|
142
|
-
tomcat.
|
150
|
+
tomcat.safe_create_module_files
|
143
151
|
expect(File.exists?(filepath)).to eq(true)
|
144
152
|
end
|
145
153
|
|
154
|
+
it 'should not create acceptance spec helper file' do
|
155
|
+
opts = {:module_path => @path, :enable_beaker_tests => false,
|
156
|
+
:enable_user_templates => false, :template_dir => nil }
|
157
|
+
filepath = File.expand_path(File.join(@path, 'spec', 'spec_helper_acceptance.rb'))
|
158
|
+
tomcat = Retrospec.new(@opts[:module_path], opts)
|
159
|
+
tomcat.safe_create_module_files
|
160
|
+
expect(File.exists?(filepath)).to eq(false)
|
161
|
+
end
|
162
|
+
|
146
163
|
it 'should create 15 nodesets' do
|
147
|
-
|
164
|
+
opts = {:module_path => @path, :enable_beaker_tests => true,
|
165
|
+
:enable_user_templates => false, :template_dir => nil }
|
166
|
+
tomcat = Retrospec.new(@opts[:module_path], opts)
|
148
167
|
filepath = File.expand_path(File.join(@path, 'spec', 'acceptance', 'nodesets', 'default.yml'))
|
149
|
-
tomcat.
|
168
|
+
tomcat.safe_create_module_files
|
150
169
|
expect(File.exists?(filepath)).to eq(true)
|
151
|
-
expect(Dir.glob(File.expand_path(File.join(@path, 'spec', 'acceptance', 'nodesets', '*.yml'))).length).to eq
|
170
|
+
expect(Dir.glob(File.expand_path(File.join(@path, 'spec', 'acceptance', 'nodesets', '*.yml'))).length).to eq 15
|
152
171
|
end
|
153
172
|
|
154
173
|
it 'should create Gemfile file' do
|
155
174
|
tomcat = Retrospec.new(@opts[:module_path], @opts)
|
156
175
|
filepath = File.expand_path(File.join(@path, 'Gemfile'))
|
157
|
-
tomcat.
|
176
|
+
tomcat.safe_create_module_files
|
158
177
|
expect(File.exists?(filepath)).to eq(true)
|
159
178
|
end
|
160
179
|
|
161
180
|
it 'should create Rakefile file' do
|
162
181
|
tomcat = Retrospec.new(@opts[:module_path], @opts)
|
163
182
|
filepath = File.expand_path(File.join(@path, 'Rakefile'))
|
164
|
-
tomcat.
|
183
|
+
tomcat.safe_create_module_files
|
165
184
|
expect(File.exists?(filepath)).to eq(true)
|
166
185
|
end
|
167
186
|
|
@@ -169,7 +188,7 @@ describe "puppet-retrospec" do
|
|
169
188
|
filepath = File.expand_path(File.join(@path,'.fixtures.yml'))
|
170
189
|
FileUtils.rm_f(filepath) # ensure we have a clean state
|
171
190
|
tomcat = Retrospec.new(@opts[:module_path], @opts)
|
172
|
-
tomcat.
|
191
|
+
tomcat.safe_create_module_files
|
173
192
|
expect(File.exists?(filepath)).to eq(true)
|
174
193
|
end
|
175
194
|
|
@@ -181,8 +200,9 @@ describe "puppet-retrospec" do
|
|
181
200
|
|
182
201
|
it 'should create a file from a template' do
|
183
202
|
tomcat = Retrospec.new(@opts[:module_path], @opts)
|
184
|
-
tomcat.safe_create_template_file('.fixtures.yml', 'fixtures_file.erb')
|
185
203
|
file_path = File.join(@path,'.fixtures.yml')
|
204
|
+
template_file = File.join(tomcat.template_dir,'module_files','.fixtures.yml')
|
205
|
+
tomcat.safe_create_template_file(file_path, template_file)
|
186
206
|
expect(File.exists?(file_path)).to eq(true)
|
187
207
|
end
|
188
208
|
|
@@ -230,5 +250,4 @@ describe "puppet-retrospec" do
|
|
230
250
|
expect(tomcat.generate_file_name('tomcat')).to eq('tomcat_spec.rb')
|
231
251
|
expect(tomcat.generate_file_name('tomcat::config')).to eq('config_spec.rb')
|
232
252
|
end
|
233
|
-
|
234
253
|
end
|