Sha256: cc84d0cb0a822cee4e260fdfd4244983fe35d87e24a35baa8f0c30b941f6b865

Contents?: true

Size: 1.26 KB

Versions: 28

Compression:

Stored size: 1.26 KB

Contents

module Serverspec
  module Type
    class Command < Base
      attr_accessor :result

      def return_stdout?(content)
        ret = backend.run_command(@name)
        if content.instance_of?(Regexp)
          ret[:stdout] =~ content
        else
          ret[:stdout].strip == content
        end
      end

      def return_stderr?(content)
        ret = backend.run_command(@name)
        # In ssh access with pty, stderr is merged to stdout
        # See http://stackoverflow.com/questions/7937651/receiving-extended-data-with-ssh-using-twisted-conch-as-client
        # So I use stdout instead of stderr
        if content.instance_of?(Regexp)
          ret[:stdout] =~ content
        else
          ret[:stdout].strip == content
        end
      end

      def return_exit_status?(status)
        ret = backend.run_command(@name)
        ret[:exit_status].to_i == status
      end

      def stdout
        if @result.nil?
          @result = backend.run_command(@name)[:stdout]
        end
        @result
      end

      # In ssh access with pty, stderr is merged to stdout
      # See http://stackoverflow.com/questions/7937651/receiving-extended-data-with-ssh-using-twisted-conch-as-client
      # So I use stdout instead of stderr
      alias :stderr :stdout
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
serverspec-0.14.4 lib/serverspec/type/command.rb
serverspec-0.14.3 lib/serverspec/type/command.rb
serverspec-0.14.2 lib/serverspec/type/command.rb
serverspec-0.14.1 lib/serverspec/type/command.rb
serverspec-0.14.0 lib/serverspec/type/command.rb
serverspec-0.13.7 lib/serverspec/type/command.rb
serverspec-0.13.6 lib/serverspec/type/command.rb
serverspec-0.13.5 lib/serverspec/type/command.rb
serverspec-0.13.4 lib/serverspec/type/command.rb
serverspec-0.13.3 lib/serverspec/type/command.rb
serverspec-0.13.2 lib/serverspec/type/command.rb
serverspec-0.13.1 lib/serverspec/type/command.rb
serverspec-0.13.0 lib/serverspec/type/command.rb
serverspec-0.12.0 lib/serverspec/type/command.rb
serverspec-0.11.5 lib/serverspec/type/command.rb
serverspec-0.11.4 lib/serverspec/type/command.rb
serverspec-0.11.3 lib/serverspec/type/command.rb
serverspec-0.11.2 lib/serverspec/type/command.rb
serverspec-0.11.1 lib/serverspec/type/command.rb
serverspec-0.11.0 lib/serverspec/type/command.rb