Class: RSpec::Terraspace::Ts
- Inherits:
-
Object
- Object
- RSpec::Terraspace::Ts
- Extended by:
- Memoist
- Defined in:
- lib/rspec/terraspace/ts.rb
Constant Summary collapse
- CLI =
::Terraspace::CLI
Instance Method Summary collapse
- #build_test_harness(options = {}) ⇒ Object
- #down(args) ⇒ Object
- #output(mod, name) ⇒ Object
- #run(command) ⇒ Object
- #save_output(mod) ⇒ Object
- #saved_output_path ⇒ Object
- #up(args) ⇒ Object
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(={}) puts "Building test harness..." project = Project.new() @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_path ⇒ Object
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 |