Class: RSpec::Terraspace::Ts

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/rspec/terraspace/ts.rb

Constant Summary collapse

CLI =
::Terraspace::CLI

Instance Method Summary collapse

Instance Method Details

#build_test_harness(options = {}) ⇒ Object



9
10
11
12
13
14
# File 'lib/rspec/terraspace/ts.rb', line 9

def build_test_harness(options={})
  puts "Building test harness..."
  project = Project.new(options)
  @ts_root = project.create
  ENV['TS_ROOT'] = @ts_root # switch root to the generated test harness
end

#down(args) ⇒ Object



20
21
22
# File 'lib/rspec/terraspace/ts.rb', line 20

def down(args)
  run("down #{args} -y")
end

#output(mod, name) ⇒ Object



34
35
36
37
38
# File 'lib/rspec/terraspace/ts.rb', line 34

def output(mod, name)
  save_output(mod)
  data = JSON.load(IO.read(saved_output_path))
  data.dig(name, "value")
end

#run(command) ⇒ Object



24
25
26
27
# File 'lib/rspec/terraspace/ts.rb', line 24

def run(command)
  args = command.split(' ')
  CLI.start(args)
end

#save_output(mod) ⇒ Object



29
30
31
# File 'lib/rspec/terraspace/ts.rb', line 29

def save_output(mod)
  run("output #{mod} --json --save-to #{saved_output_path}")
end

#saved_output_pathObject



40
41
42
# File 'lib/rspec/terraspace/ts.rb', line 40

def saved_output_path
  "#{@ts_root}/output.json"
end

#up(args) ⇒ Object



16
17
18
# File 'lib/rspec/terraspace/ts.rb', line 16

def up(args)
  run("up #{args} -y")
end