Class: Specinfra::Backend::BeakerExec
- Inherits:
-
BeakerBase
- Object
- Base
- BeakerBase
- Specinfra::Backend::BeakerExec
- Defined in:
- lib/beaker-rspec/helpers/serverspec.rb
Instance Attribute Summary
Attributes inherited from BeakerBase
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
244 245 246 247 248 249 250 251 |
# File 'lib/beaker-rspec/helpers/serverspec.rb', line 244 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
233 234 235 236 237 238 239 240 241 242 |
# File 'lib/beaker-rspec/helpers/serverspec.rb', line 233 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 cmd = %(env PATH="#{path}" #{cmd}) if path 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
219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/beaker-rspec/helpers/serverspec.rb', line 219 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 |