lib/rspec/terraform/helpers/actions/output.rb in rspec-terraform-0.1.0.pre.47 vs lib/rspec/terraform/helpers/actions/output.rb in rspec-terraform-0.1.0.pre.48

- old
+ new

@@ -12,17 +12,40 @@ module Output include CommandInstantiation def output(parameters) stdout = StringIO.new + parameters = output_parameters(parameters) + + log_output_starting(parameters) + log_output_using_parameters(parameters) + output_command(stdout: stdout) - .execute(output_parameters(parameters)) + .execute(parameters) + + log_output_complete + stdout.string end private + def log_output_starting(parameters) + logger&.info( + 'Outputting for configuration in directory: ' \ + "'#{parameters[:chdir]}'..." + ) + end + + def log_output_using_parameters(parameters) + logger&.debug("Outputting using parameters: #{parameters}...") + end + + def log_output_complete + logger&.info('Output complete.') + end + def output_command(opts = {}) instantiate_command(RubyTerraform::Commands::Output, opts) end def output_parameters(parameters) @@ -30,17 +53,24 @@ with_output_standard_parameters(parameters) ) end def with_output_standard_parameters(parameters) - parameters.merge( - chdir: parameters[:configuration_directory] - ) + configuration_directory = parameters[:configuration_directory] + + parameters + .except(:configuration_directory) + .merge( + chdir: configuration_directory + ) end def with_output_state_file_parameters(parameters) - if parameters[:state_file] - return parameters.merge(state: parameters[:state_file]) + state_file = parameters[:state_file] + if state_file + return parameters + .except(:state_file) + .merge(state: state_file) end parameters end end