Method: Retrospec::Puppet::Generators::FunctionGenerator#generate_spec_files
- Defined in:
- lib/retrospec/plugins/v1/plugin/generators/function_generator.rb
#generate_spec_files ⇒ Object
creates the spec files for the discovered_functions
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/retrospec/plugins/v1/plugin/generators/function_generator.rb', line 211 def generate_spec_files spec_files = [] discovered_functions.each do |file| begin if v3_function?(file) context.function_type = 'v3' file_data = Retrospec::Puppet::Parser::Functions.load_function(file) elsif native_function?(file) context.test_type = 'rspec' context.function_type = 'native' file_data = Parsers::NativeFunction.load_function(file) else context.function_type = 'v4' file_data = Retrospec::Puppet::Functions.load_function(file) end rescue NoMethodError => e puts "Error evaluating function for #{file}, skipping".warning next rescue SyntaxError => e puts "Function syntax is bad for #{file}, skipping".warning next # lets skip functions that have bad syntax end # separate out namespace for v4 and native functions # TODO should we create sub directories for triple namespace functions one::two::three? file_name = file_data.name.to_s.split('::').last spec_path = File.join(spec_file_dir, "#{file_name}_spec.rb") spec_files << spec_path safe_create_template_file(spec_path, File.join(template_dir, template_file), file_data) end spec_files end |