Class: Specinfra::Backend::BeakerExec
- Inherits:
-
BeakerBase
- Object
- Base
- BeakerBase
- Specinfra::Backend::BeakerExec
- Defined in:
- lib/beaker-rspec/helpers/serverspec.rb
Instance Method Summary collapse
- #add_pre_command(cmd) ⇒ Object
- #build_command(cmd) ⇒ Object
-
#run_command(cmd, opt = {}) ⇒ Hash
Run a unix style command using serverspec.
Methods inherited from BeakerBase
Instance Method Details
#add_pre_command(cmd) ⇒ Object
299 300 301 302 303 304 305 306 |
# File 'lib/beaker-rspec/helpers/serverspec.rb', line 299 def add_pre_command(cmd) if Specinfra.configuration.pre_command pre_cmd = build_command(Specinfra.configuration.pre_command) "#{pre_cmd} && #{cmd}" else cmd end end |
#build_command(cmd) ⇒ Object
286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/beaker-rspec/helpers/serverspec.rb', line 286 def build_command(cmd) useshell = '/bin/sh' cmd = cmd.shelljoin if cmd.is_a?(Array) cmd = "#{String(useshell).shellescape} -c #{String(cmd).shellescape}" path = Specinfra.configuration.path if path cmd = %Q{env PATH="#{path}" #{cmd}} end cmd end |
#run_command(cmd, opt = {}) ⇒ Hash
Run a unix style command using serverspec. Defaults to running on the ‘default_node’ test node, otherwise uses the node specified in @example.metadata
272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/beaker-rspec/helpers/serverspec.rb', line 272 def run_command(cmd, opt = {}) node = get_working_node cmd = build_command(cmd) cmd = add_pre_command(cmd) ret = ssh_exec!(node, cmd) if @example @example.[:command] = cmd @example.[:stdout] = ret[:stdout] end CommandResult.new ret end |