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
- #out_path ⇒ Object
- #output(mod, name) ⇒ Object
- #run(command) ⇒ Object
-
#save_output ⇒ Object
Note: a terraspace.down will remove the output.json since it does a clean.
- #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() root = project.create Terraspace.root = root # switch root to the generated test harness end |
#down(args) ⇒ Object
23 24 25 |
# File 'lib/rspec/terraspace/ts.rb', line 23 def down(args) run("down #{args} -y") end |
#out_path ⇒ Object
44 45 46 |
# File 'lib/rspec/terraspace/ts.rb', line 44 def out_path "#{Terraspace.tmp_root}/rspec/output.json" end |
#output(mod, name) ⇒ Object
39 40 41 42 |
# File 'lib/rspec/terraspace/ts.rb', line 39 def output(mod, name) data = JSON.load(IO.read(out_path)) data.dig(name, "value") end |
#run(command) ⇒ Object
27 28 29 30 31 |
# File 'lib/rspec/terraspace/ts.rb', line 27 def run(command) puts "=> terraspace #{command}".color(:green) args = command.split(' ') CLI.start(args) end |
#save_output ⇒ Object
Note: a terraspace.down will remove the output.json since it does a clean
34 35 36 37 |
# File 'lib/rspec/terraspace/ts.rb', line 34 def save_output FileUtils.mkdir_p(File.dirname(out_path)) run("output #{@mod.name} --format json --out #{out_path}") end |
#up(args) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rspec/terraspace/ts.rb', line 16 def up(args) run("up #{args} -y") mod = args.split(' ').first @mod = ::Terraspace::Mod.new(mod) save_output end |