Class: Terraspace::CLI::Test
- Inherits:
-
Object
- Object
- Terraspace::CLI::Test
- Defined in:
- lib/terraspace/cli/test.rb
Instance Method Summary collapse
- #adjust_command(command) ⇒ Object
-
#cd_into_test? ⇒ Boolean
Automatically cd into the test folder in case running within the root of a module.
- #execute(command) ⇒ Object
-
#initialize(options = {}) ⇒ Test
constructor
A new instance of Test.
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Test
Returns a new instance of Test.
3 4 5 |
# File 'lib/terraspace/cli/test.rb', line 3 def initialize(={}) @options = end |
Instance Method Details
#adjust_command(command) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/terraspace/cli/test.rb', line 19 def adjust_command(command) if cd_into_test? command = "bundle exec #{command}" unless command.include?("bundle exec") command = "cd test && #{command}" else command end end |
#cd_into_test? ⇒ Boolean
Automatically cd into the test folder in case running within the root of a module. Detect/guess that we’re in a module folder vs the terraspace project
30 31 32 33 |
# File 'lib/terraspace/cli/test.rb', line 30 def cd_into_test? !File.exist?("app") && File.exist?("test") && (File.exist?("main.tf") || File.exist?("main.rb")) end |
#execute(command) ⇒ Object
13 14 15 16 17 |
# File 'lib/terraspace/cli/test.rb', line 13 def execute(command) command = adjust_command(command) puts "=> #{command}" Kernel.exec(command) end |
#run ⇒ Object
7 8 9 10 11 |
# File 'lib/terraspace/cli/test.rb', line 7 def run config = Terraspace.config test_command = config.test_framework_command || config.test_framework execute(test_command) end |