24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/kurgan/test.rb', line 24
def create_test
case options[:type]
when 'config'
template('templates/test.yaml.tt', "#{options[:directory]}/#{test_name}.test.yaml")
when 'spec'
if test_name == '*'
test_yamls = Dir["tests/*.test.yaml"]
tests = test_yamls.map {|test_yaml| test_yaml[/tests\/(.*).test.yaml/, 1]}
else
tests = [test_name]
end
tests.each do |name|
output_file = "#{Dir.pwd}/out/tests/#{name}/#{@component_name}.compiled.yaml"
if !File.file?(output_file)
warn "compile cloudformation test output file #{output_file} not found.\nRun `cfhighlander cftest -t #{options[:directory]}/#{name}.test.yaml`"
end
compiled_test = YAML.load_file("#{Dir.pwd}/out/tests/#{name}/#{@component_name}.compiled.yaml")
template('templates/test.spec.tt', "spec/#{name}_spec.rb", compiled_test)
end
else
error "#{options[:type]} is not a supported test type yet", :red
end
end
|