puppet-retrospec 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 027977cdd2e60766923d0d8c013efb9beafcff28
4
- data.tar.gz: 1652ba814a16849574a492e2f06c917829625416
3
+ metadata.gz: 2a2f8b465a1d2884cfff1f96f1d46214c891d27f
4
+ data.tar.gz: b3458e26b5ccdab19bd1fa05c841eb7eb7e3952c
5
5
  SHA512:
6
- metadata.gz: 81ab8cff8a124a17b60d2dfe2c3ea50a467a58fe30aaedc3d10791f23328cb68a32fa31efb93298d699d879cfacb3401bc5de9412b59678ecf6f7f12822b6914
7
- data.tar.gz: 70a98a402f0a993551fd46c81540289955a36427b5cc38804485d5639e3004e7a0344542b54d126ea3f980b63fb3819e798818e6bb43d93bd7ae855d51b8bca5
6
+ metadata.gz: 9d65c5dfb1eb72b5dae00bf6ef11089f08ea9a2100c9641b82d0dab74d288288ecdda6f5fbba0db50c8fbf734692a44853959dfaf6c00ed432e81bce409bb24c
7
+ data.tar.gz: a517170cfcdad5f652805d205f22cae24e06b5db385ea5b2e567af8e23f563a736bd0e3af5c7e9f2b2b647691a5d95fa5db4337bcc369f4202a4c26dc213ddeb
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- puppet-retrospec
1
+ Puppet-Retrospec
2
2
  ================
3
3
 
4
4
  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.
@@ -7,11 +7,12 @@ Retrospec makes it dead simple to get started with puppet unit testing. When yo
7
7
  and actually write some very basic rspec-puppet test code. Thus this gem will retrofit your existing puppet module
8
8
  with everything needed to get going with puppet unit testing.
9
9
 
10
+ The project was named retrospec because there are many times when you need to retrofit your module with spec tests.
10
11
 
11
12
  Build Status
12
13
  ============
13
14
  [![Build Status](https://travis-ci.org/logicminds/puppet-retrospec.png)](https://travis-ci.org/logicminds/puppet-retrospec)
14
-
15
+ [![Gem Version](https://badge.fury.io/rb/puppet-retrospec.svg)](http://badge.fury.io/rb/puppet-retrospec)
15
16
  Install
16
17
  =============
17
18
  `gem install puppet-retrospec`
@@ -38,38 +39,169 @@ Options:
38
39
  --template-dir, -t <s>: Path to templates directory (only for overriding Retrospec templates)
39
40
  --enable-user-templates, -e: Use Retrospec templates from /Users/cosman/.puppet_retrospec_templates
40
41
  --help, -h: Show this message
42
+
43
+ retrospec -m ~/projects/puppet_modules/apache
44
+ ```
45
+
46
+ Example
47
+ ======================
48
+
49
+ Below you can see that it creates files for every resource in the tomcat module in addition to other files
50
+ that you need for unit testing puppet code.
51
+
52
+ ```shell
53
+ $ ls
54
+ CHANGELOG.md CONTRIBUTING.md LICENSE README.md Rakefile checksums.json examples manifests metadata.json
55
+ $ pwd
56
+ /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat
57
+ $ retrospec
58
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/
59
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/spec_helper.rb
60
+ !! /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/.fixtures.yml already exists and differs from template
61
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/Gemfile
62
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/shared_contexts.rb
63
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/classes/
64
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/classes/tomcat_spec.rb
65
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/classes/params_spec.rb
66
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/config/server/
67
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/config/server/connector_spec.rb
68
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/config/server/engine_spec.rb
69
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/config/server/host_spec.rb
70
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/config/server/service_spec.rb
71
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/config/server/valve_spec.rb
72
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/config/server_spec.rb
73
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/instance/
74
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/instance/package_spec.rb
75
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/instance/source_spec.rb
76
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/instance_spec.rb
77
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/service_spec.rb
78
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/setenv/
79
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/setenv/entry_spec.rb
80
+ + /Users/cosman/bodeco/puppet-retrospec/spec/fixtures/modules/tomcat/spec/defines/war_spec.rb
81
+
82
+ ```
83
+
84
+ Looking at the file we can see that it did a lot of work for us.
85
+ Below is the classes/tomcat_spec.rb file
86
+
87
+ ```ruby
88
+ require 'spec_helper'
89
+ require 'shared_contexts'
90
+ describe 'tomcat' do
91
+ # by default the hiera integration is commented out
92
+ # but basically to mock hiera you first need to add a key/value pair
93
+ # to the specific context in the spec/shared_contexts.rb file
94
+ # Note: you can only use a single hiera context per describe/context block
95
+ # rspec-puppet does not allow you to swap out hiera data on a per test block
96
+ #include_context :hiera
97
+ # below is the facts hash that gives you the ability to mock
98
+ # facts on a per describe/context block. If you use a fact in your
99
+ # manifest you should mock the facts below.
100
+ let(:facts) do
101
+ {}
102
+ end
103
+ # below is a list of the resource parameters that you can override
104
+ # by default all non-required parameters are commented out
105
+ # while all required parameters will require you to add a value
106
+ let(:params) do
107
+ {
108
+ #:catalina_home => $::tomcat::params::catalina_home,
109
+ #:user => $::tomcat::params::user,
110
+ #:group => $::tomcat::params::group,
111
+ #:install_from_source => true,
112
+ #:purge_connectors => false,
113
+ #:manage_user => true,
114
+ #:manage_group => true,
115
+ }
116
+ end
117
+ # add these two lines in a single test block to enable puppet and hiera debug mode
118
+ # Puppet::Util::Log.level = :debug
119
+ # Puppet::Util::Log.newdestination(:console)
120
+ it { should compile }
121
+ end
41
122
 
42
123
  ```
43
124
 
125
+ About the test suite
126
+ ======================
127
+ At this time the test suite that is automatically generated is extremely basic. Essentially it just ensures that your
128
+ code will compile correctly. However, one of the major stumbling blocks is just constructing everything in the spec
129
+ directory which retrospec does for you automatically. Its now up to you to further enhance your test suite with more
130
+ tests and conditional logic. For now you will probably want to read up on the following documentation:
131
+
132
+ * [Puppet Rspec](http://rspec-puppet.com)
133
+ * [Puppet spec helper](https://github.com/puppetlabs/puppetlabs_spec_helper/blob/master/README.markdown)
134
+
135
+
44
136
  How Does it do this
45
137
  =======================
46
- Basically Retrospec uses the puppet lexer to scan your code in order to fill out some basic templates that will retrofit
138
+ Basically Retrospec uses the puppet lexer and parser to scan your code in order to fill out some basic templates that will retrofit
47
139
  your puppet module with unit tests.
48
140
 
49
141
  Overriding the templates
50
142
  =======================
51
143
  There may be a time when you want to override the default templates used to generate the rspec related files.
52
- To override these templates just set the following environment variables. Once one of the variables is set
53
- the first run will copy over the templates from the gem location. If you have already created the file, then
54
- puppet-retrospec will not overwrite the file. You can set multiple template path if you use them for
55
- different projects so just be sure the set the correctly template path.
144
+ To override these templates just set **one** of the following environment variables.
145
+
146
+ ```shell
147
+ RETROSPEC_ENABLE_LOCAL_TEMPLATES=true
148
+ RETROSPEC_TEMPLATES_PATH=~/my_templates
149
+
150
+ ```
151
+
152
+ Once one of the variables is set the retrospec will copy over all the templates from the gem location to the default
153
+ or specified override templates path.
154
+ If you have already created the a erb file in the templates location, then puppet-retrospec will not overwrite the file.
155
+ You can set multiple template paths if you use them for different projects so just be sure the set the correctly
156
+ template path environment variable when running retrospec.
56
157
 
57
158
  Setting the `RETROSPEC_ENABLE_LOCAL_TEMPLATES=true` Environment variable will tell retrospec to use the default user template location.
58
159
 
59
- The default override location for the templates is ~/.puppet_retrospec_templates
160
+ The default location for the templates when using this variable is ~/.puppet_retrospec_templates
60
161
 
61
- If you wish to override the default template location you can use the following environment variable RETROSPEC_TEMPLATES_PATH.
162
+ If you wish to override ~/.puppet_retrospec_templates location you can use the following environment variable
163
+ RETROSPEC_TEMPLATES_PATH.
62
164
  If you set this variable you are not required set RETROSPEC_ENABLE_LOCAL_TEMPLATES.
63
165
 
64
166
  `RETROSPEC_TEMPLATES_PATH=~/my_templates`
65
167
 
168
+ Troubleshooting
169
+ ===============
170
+ If you see the following, this error means that you need to add a fixture to the fixtures file.
171
+ At this time I have no idea what your module requires. So just add the module that this class belongs to
172
+ in the .fixtures file.
173
+
174
+ See [fixtures doc](https://github.com/puppetlabs/puppetlabs_spec_helper#using-fixtures) for more information
175
+
176
+ ```shell
177
+ 8) tomcat::instance::source
178
+ Failure/Error: it { should compile }
179
+ Puppet::Error:
180
+ Could not find class staging for coreys-macbook-pro-2.local on node coreys-macbook-pro-2.local
181
+ # ./spec/defines/instance/source_spec.rb:34:in `block (2 levels) in <top (required)>'
182
+ ```
183
+
184
+ Running Tests
185
+ =============
186
+ Puppet-retrospec tests its code against real modules downloaded directly from puppet forge.
187
+ We also do a little mocking as well but for the majority of the tests we download are 'fixtures'.
188
+
189
+ To run a clean test suite and re-download you must run with environment variable set
190
+ ```
191
+ RETROSPEC_CLEAN_UP_TEST_MODULES=true bundle exec rake spec
192
+ ```
193
+
194
+ Otherwise to save time we skip the removal of test puppet modules therefore we don't re-download
195
+ ```
196
+ bundle exec rake spec
197
+ ```
198
+
66
199
  Todo
67
200
  ============
68
- - Add support to fill out the params in unit tests automatically
69
201
  - Add support to fill out used facts in the unit tests automatically
70
202
  - Add describe blocks around conditions in test code that change the catalog compilation
71
203
  - Auto add dependicies to fixtures file
72
204
 
73
205
  Support
74
206
  ============
75
- Currently this library only supports ruby >= 1.9.3. There is currently a bug with ruby version 1.8.7.
207
+ Currently this library only supports ruby >= 1.9.3. It might work on 1.8.7 but I won't support if it fails.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
data/lib/helpers.rb CHANGED
@@ -2,37 +2,6 @@ require 'fileutils'
2
2
 
3
3
  class Helpers
4
4
 
5
-
6
- def self.run(module_name=nil)
7
- unless is_module_dir?
8
- $stderr.puts "Does not appear to be a Puppet module. Aborting"
9
- return false
10
- end
11
-
12
- if module_name.nil?
13
- module_name = get_module_name
14
- if module_name.nil?
15
- $stderr.puts "Unable to determine module name. Aborting"
16
- return false
17
- end
18
- end
19
-
20
- [
21
- 'spec',
22
- 'spec/classes',
23
- 'spec/defines',
24
- 'spec/functions',
25
- 'spec/unit', 'spec/unit/facter', 'spec/unit/puppet', 'spec/unit/puppet/type', 'spec/unit/puppet/provider',
26
- 'spec/hosts',
27
- ].each { |dir| safe_mkdir(dir) }
28
-
29
-
30
- safe_create_spec_helper
31
- safe_create_fixtures_file
32
- safe_create_resource_spec_files
33
- safe_make_shared_context
34
- end
35
-
36
5
  def self.get_module_name
37
6
  module_name = nil
38
7
  Dir["manifests/*.pp"].entries.each do |manifest|
@@ -56,8 +25,8 @@ class Helpers
56
25
  module_name
57
26
  end
58
27
 
59
- def self.is_module_dir?
60
- Dir["*"].entries.include? "manifests"
28
+ def self.is_module_dir?(dir)
29
+ Dir[File.join(dir,"*")].entries.include? "manifests"
61
30
  end
62
31
 
63
32
  def self.safe_mkdir(dir)
@@ -98,10 +67,10 @@ class Helpers
98
67
  # creates and syncs the specifed user template diretory
99
68
  # returns: user_template_dir
100
69
  def self.setup_user_template_dir(user_template_directory=nil)
101
- if user_template_directory.nil?
102
- user_template_directory = default_user_template_dir
103
- end
104
- sync_user_template_dir(create_user_template_dir(user_template_directory))
70
+ if user_template_directory.nil?
71
+ user_template_directory = default_user_template_dir
72
+ end
73
+ sync_user_template_dir(create_user_template_dir(user_template_directory))
105
74
  end
106
75
 
107
76
  def self.default_user_template_dir
@@ -5,35 +5,102 @@ require 'fileutils'
5
5
 
6
6
  class Retrospec
7
7
  attr_reader :included_declarations
8
- attr_reader :classes_and_defines
9
- attr_reader :module_name
10
- attr_reader :modules_included
11
- attr_accessor :default_path
12
- attr_accessor :manifest_files
8
+ attr_reader :module_path
9
+ attr_reader :tmp_module_path
13
10
  attr_accessor :default_modules
14
- attr_accessor :template_dir
15
-
11
+ attr_accessor :facts_used
16
12
 
13
+ # module path is the relative or absolute path to the module that should retro fitted
17
14
  def initialize(path=nil, default_template_dir=ENV['RETROSPEC_TEMPLATES_PATH'])
18
15
  # user supplied a template path or user wants to use local templates
19
16
  if not default_template_dir.nil? or ENV['RETROSPEC_ENABLE_LOCAL_TEMPLATES'] =~ /true/i
20
17
  default_template_dir = Helpers.setup_user_template_dir(default_template_dir)
21
18
  end
22
- @default_path = path
23
- @default_modules = ['stdlib']
19
+ @module_path = validate_module_dir(path)
24
20
  @template_dir = default_template_dir
25
- module_name
26
- modules_included
21
+ tmp_module_path
22
+ end
23
+
24
+ def default_modules
25
+ @default_modules ||= ['stdlib']
27
26
  end
28
27
 
29
28
  def create_files
30
29
  safe_create_spec_helper
31
30
  safe_create_fixtures_file
32
31
  safe_create_gemfile
33
- manifest_files.each do |file|
34
- safe_create_resource_spec_files(file)
35
- end
32
+ safe_create_rakefile
36
33
  safe_make_shared_context
34
+ types.each do |type|
35
+ safe_create_resource_spec_files(type)
36
+ end
37
+ FileUtils.remove_entry_secure tmp_modules_dir # ensure we remove the temporary directory
38
+ true
39
+ end
40
+
41
+ def safe_create_rakefile(template='rakefile.erb')
42
+ safe_create_template_file('Rakefile', template)
43
+ end
44
+
45
+ def safe_make_shared_context(template='shared_context.erb')
46
+ safe_create_template_file(File.join('spec','shared_contexts.rb'), template)
47
+ end
48
+
49
+ def safe_create_fixtures_file(template='fixtures_file.erb')
50
+ safe_create_template_file('.fixtures.yml', template)
51
+ end
52
+
53
+ def safe_create_spec_helper(template='spec_helper_file.erb')
54
+ safe_create_template_file(File.join('spec','spec_helper.rb'), template)
55
+ end
56
+
57
+ def safe_create_gemfile(template='gemfile.erb')
58
+ safe_create_template_file('Gemfile', template)
59
+ end
60
+
61
+ def safe_create_template_file(path, template)
62
+ # check to ensure parent directory exists
63
+ file_dir_path = File.expand_path(File.join(module_path,File.dirname(path)))
64
+ if ! File.exists?(file_dir_path)
65
+ Helpers.safe_mkdir(file_dir_path)
66
+ end
67
+ template_path = File.join(template_dir, template)
68
+ File.open(template_path) do |file|
69
+ renderer = ERB.new(file.read, 0, '-')
70
+ content = renderer.result binding
71
+ dest_path = File.expand_path(File.join(module_path,path))
72
+ Helpers.safe_create_file(dest_path, content)
73
+ end
74
+ end
75
+
76
+ def types
77
+ @types ||= search_module || []
78
+ end
79
+
80
+ # puts a symlink in that module directory that points back to the user supplied module path
81
+ def tmp_module_path
82
+ if @tmp_module_path.nil?
83
+ # create a link where source is the current repo and dest is /tmp/modules/module_name
84
+ path = File.join(tmp_modules_dir, module_name)
85
+ FileUtils.ln_s(module_path, path)
86
+ @tmp_module_path = path
87
+ end
88
+ @tmp_module_path
89
+ end
90
+
91
+ def module_name
92
+ @module_name ||= File.basename(module_path)
93
+ end
94
+
95
+ # creates a tmp module directory so puppet can work correctly
96
+ def tmp_modules_dir
97
+ if @modules_dir.nil?
98
+ dir = Dir.mktmpdir
99
+ tmp_modules_path = File.expand_path(File.join(dir, 'modules'))
100
+ FileUtils.mkdir_p(tmp_modules_path)
101
+ @modules_dir = tmp_modules_path
102
+ end
103
+ @modules_dir
37
104
  end
38
105
 
39
106
  # pass in either the path to the module directory
@@ -48,15 +115,12 @@ class Retrospec
48
115
  spec.create_files
49
116
  end
50
117
 
51
- def safe_create_gemfile(template='gemfile.erb')
52
- safe_create_template_file('Gemfile', template)
53
- end
54
-
55
118
  # if user doesn't supply template directory we assume we should use the templates in this gem
56
119
  def template_dir
57
120
  @template_dir ||= Helpers.gem_template_dir
58
121
  end
59
122
 
123
+
60
124
  def modules_included
61
125
  @modules_included ||= default_modules + referenced_modules
62
126
  end
@@ -65,169 +129,111 @@ class Retrospec
65
129
  []
66
130
  end
67
131
 
68
- def module_name
69
- @module_name ||= Helpers.get_module_name
70
- end
71
-
72
- def manifest_files
73
- if @manifest_files.nil?
74
- # first check to see if manifests directory even exists when path is nil
75
- if default_path.nil?
76
- raise 'No manifest directory' if ! File.exist?('manifests')
77
- @default_path = 'manifests/**/*.pp'
78
- # check to see if at least one of the files given is a pp file
79
- # remove any non pp files
80
- elsif default_path.instance_of?(Array)
81
- data = default_path.find_all { |file| File.extname(file) == '.pp' }
82
- if data.length < 1
83
- raise "No valid puppet manifests given"
84
- end
85
- @default_path = data
86
- # this should be a module directory which would have a manifests directory
87
- elsif Dir.exist?(File.expand_path(default_path))
88
- raise 'No manifest directory' if ! File.exist?(File.expand_path(File.join(default_path, 'manifests')))
89
- @default_path = File.join(default_path, 'manifests/**/*.pp')
90
- else
91
- path = File.expand_path(default_path)
92
- raise "File does not exist at path #{path}" if ! File.exist?(path)
93
- raise 'Not a puppet manifest file' if File.extname(path) != '.pp'
94
- end
95
- @manifest_files = Dir.glob(default_path)
96
-
132
+ # processes a directory and expands to its full path, assumes './'
133
+ # returns the validated dir
134
+ def validate_module_dir(dir)
135
+ # first check to see if manifests directory even exists when path is nil
136
+ if dir.nil?
137
+ dir = '.'
138
+ elsif dir.instance_of?(Array)
139
+ raise "Retrospec - an array of moudule paths is not supported at this time"
97
140
  end
98
- @manifest_files
99
- end
100
-
101
- def classes_and_defines(file)
102
- @classes_and_defines = []
103
- # for each file we are going to use the puppet lexer to find the class or define
104
- resources = []
105
- p = Puppet::Parser::Lexer.new
106
- p.string = File.read(file)
107
- tokens = p.fullscan
108
- tokens.each do | token|
109
- if [:CLASS, :DEFINE].include? token.first
110
- k = tokens.index { |token| [:NAME].include? token.first }
111
- # there is some sort of ordering bug here with ruby 1.8.7 and I have to modify the code like below
112
- # to get it working. I think its this index method above
113
- # TODO make this work with ruby versions 1.8.7 and above
114
- #resources.push({:type_name => tokens[k-1].last[:value], :name => token.last[:value] })
115
- resources.push({:type_name => token.last[:value] , :name => tokens[k].last[:value] })
116
- end
117
- end
118
- # sometimes the manifest can be blank and not include a class or define statement
119
- if resources.length > 0
120
- @classes_and_defines.push({:filename => File.basename(file, '.pp'), :types => resources })
121
- end
122
- @classes_and_defines
123
- end
124
-
125
- # finds all the included resources so we can test and depend on in the fixtures file
126
- def included_declarations(file)
127
- @included_declarations = {}
128
- includes = []
129
- p = Puppet::Parser::Lexer.new
130
- p.string = File.read(file)
131
- tokens = p.fullscan
132
- k = 0
133
- typename = nil
134
- tokens.each do | token|
135
- next if not token.last.is_a?(Hash)
136
- if typename.nil? and [:CLASS, :DEFINE].include? token.first
137
- j = tokens.index { |token| [:NAME].include? token.first }
138
- typename = tokens[j].last[:value]
139
- end
140
- if token.last.fetch(:value, nil) == 'include'
141
- key = token.last[:value]
142
- value = tokens[k + 1].last[:value]
143
- includes << value
144
- end
145
- k = k + 1
141
+ dir = File.expand_path(dir)
142
+ manifest_dir = File.join(dir,'manifests')
143
+ if ! File.exist?(manifest_dir)
144
+ raise "No manifest directory in #{manifest_dir}, cannot validate this is a module"
145
+ else
146
+ files = Dir.glob("#{manifest_dir}/**/*.pp")
147
+ warn 'No puppet manifest files found at #' if files.length < 1
146
148
  end
147
- @included_declarations[typename] = includes
148
- @included_declarations
149
+ dir
149
150
  end
150
151
 
152
+ # finds all the included resources so we can test and depend on in the fixtures file
153
+ # def included_declarations(file)
154
+ # @included_declarations = {}
155
+ # includes = []
156
+ # p = Puppet::Parser::Lexer.new
157
+ # p.string = File.read(file)
158
+ # tokens = p.fullscan
159
+ # k = 0
160
+ # typename = nil
161
+ # tokens.each do | token|
162
+ # next if not token.last.is_a?(Hash)
163
+ # if typename.nil? and [:CLASS, :DEFINE].include? token.first
164
+ # j = tokens.index { |token| [:NAME].include? token.first }
165
+ # typename = tokens[j].last[:value]
166
+ # end
167
+ # if token.last.fetch(:value, nil) == 'include'
168
+ # key = token.last[:value]
169
+ # value = tokens[k + 1].last[:value]
170
+ # includes << value
171
+ # end
172
+ # k = k + 1
173
+ # end
174
+ # @included_declarations[typename] = includes
175
+ # @included_declarations
176
+ # end
151
177
 
152
- def safe_make_shared_context(template='shared_context.erb')
153
- safe_create_template_file('spec/shared_contexts.rb', template)
154
- end
155
-
156
- # Gets all the classes and define types from all the files in the manifests directory
157
178
  # Creates an associated spec file for each type and even creates the subfolders for nested classes one::two::three
158
- def safe_create_resource_spec_files(manifest_file,template='resource_spec_file.erb')
179
+ def safe_create_resource_spec_files(type,template='resource_spec_file.erb')
159
180
  classes_dir = 'spec/classes'
160
181
  defines_dir = 'spec/defines'
161
- classes_and_defines(manifest_file).each do |value|
162
- types = value[:types]
163
- types.each do |type|
164
- # run template
165
- tokens = type[:name].split('::')
166
- if type[:type_name] == 'class'
167
- type_dir_name = classes_dir
168
- else
169
- type_dir_name = defines_dir
170
- end
171
- file_name = tokens.pop # the last item should be the filename
172
- # if there are only two tokens ie. tomcat::params we dont need to create a subdirectory
173
- if tokens.count > 1
174
- # this is a deep level resource ie. tomcat::config::server::connector
175
- # however we don't need the tomcat directory so we can just remove it
176
- # this should leave us with config/server/connector_spec.rb
177
- tokens.delete_at(0)
178
- # so lets make a directory structure out of it
179
- dir_name = File.join(tokens) # config/server
180
- dir_name = File.join(type_dir_name,dir_name) # spec/classes/tomcat/config/server
181
- safe_create_template_file(File.join(dir_name,"#{file_name}_spec.rb"), template)
182
- else
183
- safe_create_template_file(File.join(type_dir_name,"#{file_name}_spec.rb"), template)
184
- end
185
- end
182
+ hosts_dir = 'spec/hosts'
183
+ @parameters = type.arguments
184
+ @type = type
185
+ case type.type
186
+ when :hostclass
187
+ type_dir_name = classes_dir
188
+ when :definition
189
+ type_dir_name = defines_dir
190
+ else
191
+ raise "#{type.type} is not a supported resource type yet"
192
+ end
193
+ tokens = type.name.split('::')
194
+ file_name = tokens.pop # the last item should be the filename
195
+ # if there are only two tokens ie. tomcat::params we dont need to create a subdirectory
196
+ if tokens.count > 1
197
+ # this is a deep level resource ie. tomcat::config::server::connector
198
+ # however we don't need the tomcat directory so we can just remove it
199
+ # this should leave us with config/server/connector_spec.rb
200
+ tokens.delete_at(0)
201
+ # so lets make a directory structure out of it
202
+ dir_name = File.join(tokens) # config/server
203
+ dir_name = File.join(type_dir_name,dir_name) # spec/classes/tomcat/config/server
204
+ safe_create_template_file(File.join(dir_name,"#{file_name}_spec.rb"), template)
205
+ else
206
+ safe_create_template_file(File.join(type_dir_name,"#{file_name}_spec.rb"), template)
186
207
  end
187
208
  end
188
209
 
189
- def safe_create_fixtures_file(template='fixtures_file.erb')
190
- safe_create_template_file('.fixtures.yml', template)
210
+ def request(key, method)
211
+ instance = Puppet::Indirector::Indirection.instance(:resource_type)
212
+ indirection_name = 'test'
213
+ @request = Puppet::Indirector::Request.new(indirection_name, method, key, instance)
214
+ @request.environment = puppet_environment
215
+ @request
191
216
  end
192
217
 
193
- def safe_create_spec_helper(template='spec_helper_file.erb')
194
- safe_create_template_file('spec/spec_helper.rb', template)
218
+ def resource_type_parser
219
+ @resource_type_parser ||= Puppet::Indirector::ResourceType::Parser.new
195
220
  end
196
221
 
197
- def safe_create_template_file(path, template)
198
- # check to ensure parent directory exists
199
- file_dir_path = File.expand_path(File.join(module_dir,File.dirname(path)))
200
- if ! File.exists?(file_dir_path)
201
- Helpers.safe_mkdir(file_dir_path)
202
- end
203
- template_path = File.join(template_dir, template)
204
- File.open(template_path) do |file|
205
- renderer = ERB.new(file.read, 0, '-')
206
- content = renderer.result binding
207
- Helpers.safe_create_file(File.expand_path(File.join(module_dir,path)), content)
208
- end
209
-
222
+ # creates a puppet environment given a module path and environment name
223
+ def puppet_environment
224
+ @puppet_environment ||= Puppet::Node::Environment.create('production', [tmp_modules_dir])
210
225
  end
211
226
 
212
- # calculates where the spec directory is by going one directory back from manifests directory
213
- def module_dir
214
- @spec_dir ||= File.join(File.dirname(manifest_dir))
227
+ # returns the resource type ofject given a resource name ie. tomcat::connector
228
+ def find_resource(resource_name)
229
+ request = request(resource_name, 'find')
230
+ resource_type_parser.find(request)
215
231
  end
216
232
 
217
- def manifest_dir
218
- # look and compare, then get basename, loop till found
219
- if @manifest_dir.nil?
220
- file = manifest_files.first
221
- file.split(File::SEPARATOR).each do |part|
222
- filename = File.basename(file)
223
- if filename != 'manifests'
224
- file = File.dirname(file)
225
- else
226
- @manifest_dir = file
227
- end
228
- end
229
- end
230
- @manifest_dir
233
+ # returns the resource types found in the module
234
+ def search_module(pattern='*')
235
+ request = request(pattern, 'search')
236
+ resource_type_parser.search(request)
231
237
  end
232
238
 
233
239
  end
@@ -4,4 +4,5 @@ fixtures:
4
4
  repositories:
5
5
  stdlib:
6
6
  repo: https://github.com/puppetlabs/puppetlabs-stdlib.git
7
- ref: 4.3.2
7
+ ref: 4.3.2
8
+ forge_modules:
@@ -0,0 +1 @@
1
+ require 'bodeco_module_helper/rake_tasks'
@@ -1,25 +1,40 @@
1
1
  require 'spec_helper'
2
2
  require 'shared_contexts'
3
3
 
4
- <% @classes_and_defines.each do | value | -%>
5
- <% types = value[:types] -%>
6
- <% types.each do |type| -%>
7
- <% tname = type[:name] -%>
8
- describe '<%= tname %>' do
4
+ describe '<%= @type.name -%>' do
5
+ # by default the hiera integration uses hirea data from the shared_contexts.rb file
6
+ # but basically to mock hiera you first need to add a key/value pair
7
+ # to the specific context in the spec/shared_contexts.rb file
8
+ # Note: you can only use a single hiera context per describe/context block
9
+ # rspec-puppet does not allow you to swap out hiera data on a per test block
9
10
  include_context :hiera
10
- <% if type[:type_name] == 'define' -%>
11
+
12
+ <%- if @type.type == :definition -%>
11
13
  let(:title) { 'example_name' }
12
- <% end -%>
14
+ <%- end -%>
15
+
16
+ # below is the facts hash that gives you the ability to mock
17
+ # facts on a per describe/context block. If you use a fact in your
18
+ # manifest you should mock the facts below.
13
19
  let(:facts) do
14
20
  {}
15
21
  end
22
+ # below is a list of the resource parameters that you can override
23
+ # by default all non-required parameters are commented out
24
+ # while all required parameters will require you to add a value
16
25
  let(:params) do
17
- {}
26
+ {
27
+ <%- @parameters.each do |k,v| -%>
28
+ <%- if v.nil? -%>
29
+ <%= ":#{k} => 'place_value_here'," %>
30
+ <%- else -%>
31
+ <%= "#:#{k} => #{v}," %>
32
+ <%- end -%>
33
+ <%- end -%>
34
+ }
18
35
  end
19
- # add these two lines in a single test to enable puppet and hiera debug mode
36
+ # add these two lines in a single test block to enable puppet and hiera debug mode
20
37
  # Puppet::Util::Log.level = :debug
21
38
  # Puppet::Util::Log.newdestination(:console)
22
39
  it { should compile }
23
- <% end -%>
24
- end
25
- <% end -%>
40
+ end
@@ -5,6 +5,12 @@ hiera_config_file = File.expand_path(File.join(File.dirname(__FILE__), '..','dat
5
5
 
6
6
  # hiera_file and hiera_data are mutally exclusive contexts.
7
7
 
8
+ shared_context :hiera do
9
+ # example only,
10
+ let(:hiera_data) do
11
+ {:some_key => "some_value" }
12
+ end
13
+ end
8
14
 
9
15
  shared_context :linux_hiera do
10
16
  # example only,
@@ -2,23 +2,22 @@
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.2.0 ruby lib
5
+ # stub: puppet-retrospec 0.3.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "puppet-retrospec"
9
- s.version = "0.2.0"
9
+ s.version = "0.3.0"
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 = "2014-11-12"
14
+ s.date = "2014-11-14"
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"]
18
18
  s.extra_rdoc_files = [
19
19
  "LICENSE",
20
- "README.md",
21
- "README.rdoc"
20
+ "README.md"
22
21
  ]
23
22
  s.files = [
24
23
  ".document",
@@ -27,7 +26,6 @@ Gem::Specification.new do |s|
27
26
  "Gemfile",
28
27
  "LICENSE",
29
28
  "README.md",
30
- "README.rdoc",
31
29
  "Rakefile",
32
30
  "VERSION",
33
31
  "bin/retrospec",
@@ -35,13 +33,14 @@ Gem::Specification.new do |s|
35
33
  "lib/puppet-retrospec.rb",
36
34
  "lib/templates/fixtures_file.erb",
37
35
  "lib/templates/gemfile.erb",
36
+ "lib/templates/rakefile.erb",
38
37
  "lib/templates/resource_spec_file.erb",
39
38
  "lib/templates/shared_context.erb",
40
39
  "lib/templates/spec_helper_file.erb",
41
40
  "puppet-retrospec.gemspec",
41
+ "spec/fixtures/fixture_modules/zero_resource_module/manifests/not_a_resource_defination.pp",
42
42
  "spec/fixtures/manifests/includes-class.pp",
43
43
  "spec/fixtures/manifests/includes-defines.pp",
44
- "spec/fixtures/manifests/not_a_resource_defination.pp",
45
44
  "spec/spec_helper.rb",
46
45
  "spec/unit/puppet-retrospec_spec.rb"
47
46
  ]
data/spec/spec_helper.rb CHANGED
@@ -10,12 +10,20 @@ def fixtures_path
10
10
  @fixtures_path ||= File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))
11
11
  end
12
12
 
13
+ def clean_up_spec_dir(dir)
14
+ #puts "removing directory #{dir}"
15
+ FileUtils.rm_rf(File.join(dir, 'spec'))
16
+ FileUtils.rm_f(File.join(dir, 'Gemfile'))
17
+ FileUtils.rm_f(File.join(dir, '.fixtures.yml'))
18
+ FileUtils.rm_f(File.join(dir, 'Rakefile'))
19
+
20
+ end
21
+
13
22
  def install_module(module_name)
14
23
  FileUtils.mkdir_p(fixture_modules_path)
15
- puts "Downloading modules to fixtures directory"
16
- `puppet module install -i #{fixture_modules_path} #{module_name}`
17
- Dir.glob('spec/fixtures/modules/**/spec').each do |dir|
18
- FileUtils.rm_rf(dir)
24
+ puts `puppet module install -i #{fixture_modules_path} #{module_name}`
25
+ Dir.glob(File.join(fixture_modules_path, '**','spec')).each do |dir|
26
+ clean_up_spec_dir(dir)
19
27
  end
20
28
  end
21
29
 
@@ -2,25 +2,34 @@ require 'spec_helper'
2
2
  require 'puppet-retrospec'
3
3
  require 'helpers'
4
4
  require 'fakefs/safe'
5
- require 'pry'
6
5
 
7
6
  describe "puppet-retrospec" do
8
7
  after :all do
9
- #FileUtils.rm_rf(fixture_modules_path)
8
+ # enabling the removal slows down tests, but from time to time we may need to
9
+ FileUtils.rm_rf(fixture_modules_path) if ENV['RETROSPEC_CLEAN_UP_TEST_MODULES'] =~ /true/
10
+ end
11
+
12
+ before :all do
13
+ # enabling the removal of real modules slows down tests, but from time to time we may need to
14
+ FileUtils.rm_rf(fixture_modules_path) if ENV['RETROSPEC_CLEAN_UP_TEST_MODULES'] =~ /true/
15
+ install_module('puppetlabs-tomcat')
16
+ @path = File.join(fixture_modules_path, 'tomcat')
17
+
10
18
  end
11
19
 
12
20
  before :each do
13
- @retro = Retrospec.new(Dir.glob('spec/fixtures/manifests/*.pp'))
14
21
  ENV['RETROSPEC_ENABLE_LOCAL_TEMPLATES'] = nil
15
22
  ENV['RETROSPEC_TEMPLATES_PATH'] = nil
16
-
23
+ clean_up_spec_dir(@path)
17
24
 
18
25
  end
19
26
 
20
- it 'should run without errors' do
21
- install_module('puppetlabs-tomcat')
22
- tomcat = Retrospec.new('spec/fixtures/modules/tomcat')
23
- tomcat.create_files
27
+ it 'should run without errors using new' do
28
+ tomcat = Retrospec.new(@path)
29
+ expect(tomcat.create_files).to eq(true)
30
+ expect(File.exists?(File.join(@path, 'Gemfile'))).to eq(true)
31
+ expect(File.exists?(File.join(@path, '.fixtures.yml'))).to eq(true)
32
+ expect(File.exists?(File.join(@path, 'spec','classes','tomcat_spec.rb'))).to eq(true)
24
33
  end
25
34
 
26
35
  it 'should create a local templates directory when flag is on' do
@@ -48,7 +57,7 @@ describe "puppet-retrospec" do
48
57
  ENV['RETROSPEC_TEMPLATES_PATH'] = nil
49
58
  end
50
59
 
51
- it 'should create and use the user supplied templates directory when variable is set' do
60
+ it 'should create the user supplied templates directory when variable is set' do
52
61
  ENV['RETROSPEC_TEMPLATES_PATH'] = '/tmp/my_templates'
53
62
  FakeFS do
54
63
  FileUtils.mkdir_p(Helpers.gem_template_dir)
@@ -62,7 +71,6 @@ describe "puppet-retrospec" do
62
71
  r = Retrospec.new('/modules/tomcat')
63
72
  user_directory = r.template_dir
64
73
  expect(user_directory).to eq('/tmp/my_templates')
65
- r.create_files
66
74
  expect(File.exists?(user_directory)).to eq(true)
67
75
  expect(File.exists?(File.join(user_directory, 'fixtures_file.erb'))).to eq(true)
68
76
  expect(File.exists?(File.join(user_directory, 'gemfile.erb'))).to eq(true)
@@ -72,90 +80,110 @@ describe "puppet-retrospec" do
72
80
  end
73
81
  ENV['RETROSPEC_ENABLE_LOCAL_TEMPLATES'] = nil
74
82
  ENV['RETROSPEC_TEMPLATES_PATH'] = nil
75
- end
76
-
77
- it 'manifest path is calculated correctly' do
78
- @retro.manifest_dir.should eq('spec/fixtures/manifests')
79
- end
80
-
81
- it 'should return a list of files' do
82
- @retro.manifest_files.length.should == 3
83
- end
84
-
85
- it 'should retrieve a list of includes' do
86
- # ie. {"includes-class"=>["class1", "class2", "class3", "class6"]}
87
- includes = @retro.included_declarations('spec/fixtures/manifests/includes-class.pp')
88
- includes['includes-class'].should eq(["class1", "class2", "class3", "class6"])
89
- end
90
-
91
- it 'should not include the require statements' do
92
- # ie. {"includes-class"=>["class1", "class2", "class3", "class6"]}
93
- includes = @retro.included_declarations('spec/fixtures/manifests/includes-class.pp')
94
- includes['includes-class'].should_not eq(["class1", "class2", "class3", "class4", "class5", "class6"])
95
- end
96
83
 
97
- it 'should retrieve a list of class names' do
98
- # ie. [{:filename=>"includes-class", :types=>[{:type_name=>"class", :name=>"includes-class"}]}]
99
- classes = @retro.classes_and_defines('spec/fixtures/manifests/includes-class.pp')
100
- types = classes.first[:types]
101
- types.first[:type_name].should eq('class')
102
- types.first[:name].should eq("includes-class")
103
- end
104
-
105
- it 'should retrieve 0 defines or classes' do
106
- my_retro = Retrospec.new('spec/fixtures/manifests/not_a_resource_defination.pp')
107
- classes = my_retro.classes_and_defines('spec/fixtures/manifests/not_a_resource_defination.pp')
108
- classes.count.should == 0
109
- end
110
-
111
- it 'should not create any files when 0 resources exists' do
112
- my_retro = Retrospec.new('spec/fixtures/manifests/not_a_resource_defination.pp')
113
- my_retro.safe_create_resource_spec_files(my_retro.manifest_files.first)
114
- end
115
-
116
- it 'should retrieve a list of define names' do
117
- # ie. [{:filename=>"includes-class", :types=>[{:type_name=>"class", :name=>"includes-class"}]}]
118
- my_retro = Retrospec.new('spec/fixtures/manifests/includes-defines.pp')
119
- classes = my_retro.classes_and_defines('spec/fixtures/manifests/includes-defines.pp')
120
- types = classes.first[:types]
121
- types.first[:type_name].should eq('define')
122
- types.first[:name].should eq("webinstance")
123
84
  end
124
85
 
125
86
  it 'should create proper spec helper file' do
126
- filepath = File.expand_path(File.join(fixtures_path, 'spec/spec_helper.rb'))
127
- Helpers.should_receive(:safe_create_file).with(filepath,anything).once
128
- @retro.safe_create_spec_helper('spec_helper_file.erb')
129
-
87
+ tomcat = Retrospec.new(@path)
88
+ filepath = File.expand_path(File.join(@path, 'spec', 'spec_helper.rb'))
89
+ path = tomcat.tmp_module_path
90
+ tomcat.safe_create_spec_helper
91
+ expect(File.exists?(filepath)).to eq(true)
130
92
  end
131
93
 
132
- it 'should return the correct module name' do
133
- Helpers.should_receive(:get_module_name).and_return('mymodule')
134
- @retro.module_name.should eq('mymodule')
94
+ it 'should create proper shared context file' do
95
+ tomcat = Retrospec.new(@path)
96
+ filepath = File.expand_path(File.join(@path, 'spec', 'shared_contexts.rb'))
97
+ path = tomcat.tmp_module_path
98
+ tomcat.safe_make_shared_context
99
+ expect(File.exists?(filepath)).to eq(true)
135
100
  end
136
101
 
137
- it 'should create proper fixtures file' do
138
- filepath = File.expand_path(File.join(fixtures_path, '.fixtures.yml'))
139
- Helpers.should_receive(:safe_create_file).with(filepath,anything).once
140
- @retro.safe_create_fixtures_file('fixtures_file.erb')
141
-
142
- end
143
-
144
- it 'included_declarations should not be nil' do
145
- @retro.included_declarations(@retro.manifest_files.first).length.should >= 1
102
+ it 'should create Gemfile file' do
103
+ tomcat = Retrospec.new(@path)
104
+ filepath = File.expand_path(File.join(@path, 'Gemfile'))
105
+ tomcat.safe_create_gemfile
106
+ expect(File.exists?(filepath)).to eq(true)
146
107
  end
147
108
 
148
- it 'classes_and_defines should not be nil' do
149
- @retro.classes_and_defines(@retro.manifest_files.first).length.should >= 1
109
+ it 'should create Rakefile file' do
110
+ tomcat = Retrospec.new(@path)
111
+ filepath = File.expand_path(File.join(@path, 'Rakefile'))
112
+ tomcat.safe_create_rakefile
113
+ expect(File.exists?(filepath)).to eq(true)
150
114
  end
151
115
 
152
- it 'module_name should not be nil' do
153
- Helpers.should_receive(:get_module_name).and_return('mymodule')
154
- @retro.module_name.should_not be_nil
116
+ it 'should create proper fixtures file' do
117
+ filepath = File.expand_path(File.join(@path,'.fixtures.yml'))
118
+ FileUtils.rm_f(filepath) # ensure we have a clean state
119
+ tomcat = Retrospec.new(@path)
120
+ tomcat.safe_create_fixtures_file
121
+ expect(File.exists?(filepath)).to eq(true)
155
122
  end
156
123
 
157
- it 'modules_included should not be nil' do
158
- @retro.modules_included.length.should eq(1)
159
- end
124
+ it 'should not create any files when 0 resources exists' do
125
+ my_path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'zero_resource_module'))
126
+ my_retro = Retrospec.new(my_path)
127
+ Helpers.should_not_receive(:safe_create_file).with(anything,'resource_spec_file.erb')
128
+ end
129
+
130
+ it 'should create a temp modules dir' do
131
+ tomcat = Retrospec.new(@path)
132
+ path = tomcat.tmp_modules_dir
133
+ path.should =~ /modules/
134
+ end
135
+
136
+ it 'should create a link in the temp modules directory' do
137
+ tomcat = Retrospec.new(@path)
138
+ path = tomcat.tmp_modules_dir
139
+ tomcat.tmp_module_path
140
+ File.exists?(tomcat.tmp_module_path).should eq(true)
141
+ tomcat.tmp_module_path.should eq(File.join(path, tomcat.module_name))
142
+ end
143
+
144
+ it 'should create a file from a template' do
145
+ tomcat = Retrospec.new(@path)
146
+ tomcat.safe_create_template_file('.fixtures.yml', 'fixtures_file.erb')
147
+ file_path = File.join(@path,'.fixtures.yml')
148
+ expect(File.exists?(file_path)).to eq(true)
149
+ end
150
+
151
+ # it 'should contain a list of parameters in the test' do
152
+ # tomcat = Retrospec.new(@path)
153
+ # tomcat.create_files
154
+ #
155
+ # end
156
+ #
157
+ # it 'should retrieve a list of includes' do
158
+ # # ie. {"includes-class"=>["class1", "class2", "class3", "class6"]}
159
+ # includes = @retro.included_declarations('spec/fixtures/manifests/includes-class.pp')
160
+ # includes['includes-class'].should eq(["class1", "class2", "class3", "class6"])
161
+ # end
162
+ #
163
+ # it 'should not include the require statements' do
164
+ # # ie. {"includes-class"=>["class1", "class2", "class3", "class6"]}
165
+ # includes = @retro.included_declarations('spec/fixtures/manifests/includes-class.pp')
166
+ # includes['includes-class'].should_not eq(["class1", "class2", "class3", "class4", "class5", "class6"])
167
+ # end
168
+ #
169
+ #
170
+ # it 'should retrieve a list of define names' do
171
+ # # ie. [{:filename=>"includes-class", :types=>[{:type_name=>"class", :name=>"includes-class"}]}]
172
+ # my_retro = Retrospec.new('spec/fixtures/manifests/includes-defines.pp')
173
+ # classes = my_retro.classes_and_defines('spec/fixtures/manifests/includes-defines.pp')
174
+ # types = classes.first[:types]
175
+ # types.first[:type_name].should eq('define')
176
+ # types.first[:name].should eq("webinstance")
177
+ # end
178
+ #
179
+ #
180
+ # it 'included_declarations should not be nil' do
181
+ # @retro.included_declarations(@retro.manifest_files.first).length.should >= 1
182
+ # end
183
+ #
184
+ #
185
+ # it 'modules_included should not be nil' do
186
+ # @retro.modules_included.length.should eq(1)
187
+ # end
160
188
 
161
189
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-retrospec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Osman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-12 00:00:00.000000000 Z
11
+ date: 2014-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet
@@ -144,7 +144,6 @@ extensions: []
144
144
  extra_rdoc_files:
145
145
  - LICENSE
146
146
  - README.md
147
- - README.rdoc
148
147
  files:
149
148
  - .document
150
149
  - .rspec
@@ -152,7 +151,6 @@ files:
152
151
  - Gemfile
153
152
  - LICENSE
154
153
  - README.md
155
- - README.rdoc
156
154
  - Rakefile
157
155
  - VERSION
158
156
  - bin/retrospec
@@ -160,13 +158,14 @@ files:
160
158
  - lib/puppet-retrospec.rb
161
159
  - lib/templates/fixtures_file.erb
162
160
  - lib/templates/gemfile.erb
161
+ - lib/templates/rakefile.erb
163
162
  - lib/templates/resource_spec_file.erb
164
163
  - lib/templates/shared_context.erb
165
164
  - lib/templates/spec_helper_file.erb
166
165
  - puppet-retrospec.gemspec
166
+ - spec/fixtures/fixture_modules/zero_resource_module/manifests/not_a_resource_defination.pp
167
167
  - spec/fixtures/manifests/includes-class.pp
168
168
  - spec/fixtures/manifests/includes-defines.pp
169
- - spec/fixtures/manifests/not_a_resource_defination.pp
170
169
  - spec/spec_helper.rb
171
170
  - spec/unit/puppet-retrospec_spec.rb
172
171
  homepage: http://github.com/logicminds/puppet-retrospec
data/README.rdoc DELETED
@@ -1,19 +0,0 @@
1
- = puppet-retrospec2
2
-
3
- Description goes here.
4
-
5
- == Contributing to puppet-retrospec2
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
- * Fork the project.
10
- * Start a feature/bugfix branch.
11
- * Commit and push until you are happy with your contribution.
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2013 Corey Osman. See LICENSE.txt for
18
- further details.
19
-