Class: Terraspace::CLI::New::Source::Test

Inherits:
Core
  • Object
show all
Defined in:
lib/terraspace/cli/new/source/test.rb

Instance Method Summary collapse

Methods inherited from Core

#initialize, #override_source_paths, #require_gem, #set_core_source, #set_plugin_gem_source, #template_name

Methods included from Util::Pretty

#pretty_path, #pretty_time

Methods included from Util::Sure

#sure?

Methods included from Util::Logging

#logger

Constructor Details

This class inherits a constructor from Terraspace::CLI::New::Source::Core

Instance Method Details

#set_source_paths(template, type) ⇒ Object

different interface than Source::Plugin

template: base, hcl, ruby
type: module, project, stack


8
9
10
11
12
13
14
# File 'lib/terraspace/cli/new/source/test.rb', line 8

def set_source_paths(template, type)
  if @options[:examples]
    set_plugin_gem_source("test", type)
  else
    set_test_framework_gem_source(type) # tester gem like rspec-terraspace has empty starter templates
  end
end

#set_test_framework_gem_source(type) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/terraspace/cli/new/source/test.rb', line 16

def set_test_framework_gem_source(type)
  test_gem_name = "rspec/terraspace"

  require_gem(test_gem_name)
  tester = Terraspace::Tester.find_with(framework: Terraspace.config.test_framework)

  template_path = File.expand_path("#{tester.root}/lib/templates/#{type}")
  override_source_paths(template_path)
end