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
- #outputs ⇒ 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 |
# File 'lib/rspec/terraspace/ts.rb', line 9 def build_test_harness(={}) project = Project.new() root = project.create Terraspace.root = root # switch root to the generated test harness end |
#down(args) ⇒ Object
22 23 24 |
# File 'lib/rspec/terraspace/ts.rb', line 22 def down(args) run("down #{args} -y") end |
#out_path ⇒ Object
46 47 48 |
# File 'lib/rspec/terraspace/ts.rb', line 46 def out_path "#{Terraspace.tmp_root}/rspec/output.json" end |
#output(mod, name) ⇒ Object
38 39 40 |
# File 'lib/rspec/terraspace/ts.rb', line 38 def output(mod, name) outputs.dig(name, "value") end |
#outputs ⇒ Object
42 43 44 |
# File 'lib/rspec/terraspace/ts.rb', line 42 def outputs JSON.load(IO.read(out_path)) end |
#run(command) ⇒ Object
26 27 28 29 30 |
# File 'lib/rspec/terraspace/ts.rb', line 26 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
33 34 35 36 |
# File 'lib/rspec/terraspace/ts.rb', line 33 def save_output FileUtils.mkdir_p(File.dirname(out_path)) run("output #{@mod.name} --format json --out #{out_path}") end |
#up(args) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/rspec/terraspace/ts.rb', line 15 def up(args) run("up #{args} -y") mod = args.split(' ').first @mod = ::Terraspace::Mod.new(mod) save_output end |