spec/spec_helper.rb in serverspec-0.8.1 vs spec/spec_helper.rb in serverspec-0.9.0

- old
+ new

@@ -9,14 +9,12 @@ Dir[PROJECT_ROOT.join("spec/support/**/*.rb")].each { |file| require(file) } module Serverspec module Backend - class Exec - def run_command(cmd) - cmd = build_command(cmd) - cmd = add_pre_command(cmd) + module TestCommandRunner + def do_run cmd if @example @example.metadata[:subject].set_command(cmd) end if cmd =~ /invalid/ @@ -34,32 +32,26 @@ :exit_signal => nil } end end end - - class Ssh - def run_command(cmd) - cmd = build_command(cmd) - cmd = add_pre_command(cmd) - if @example - @example.metadata[:subject].set_command(cmd) + [Exec, Ssh].each do |clz| + clz.class_eval do + include TestCommandRunner + def run_command(cmd) + cmd = build_command(cmd) + cmd = add_pre_command(cmd) + do_run cmd end - - if cmd =~ /invalid/ - { - :stdout => ::Serverspec.configuration.stdout, - :stderr => ::Serverspec.configuration.stderr, - :exit_status => 1, - :exit_signal => nil - } - else - { - :stdout => ::Serverspec.configuration.stdout, - :stderr => ::Serverspec.configuration.stderr, - :exit_status => 0, - :exit_signal => nil - } + end + end + [Cmd, WinRM].each do |clz| + clz.class_eval do + include TestCommandRunner + def run_command(cmd) + cmd = build_command(cmd.script) + cmd = add_pre_command(cmd) + do_run cmd end end end end