Sha256: 010628218c18736cddcc431d5d1348ecc6ff4ccace7d1778c3276d23086ce61a

Contents?: true

Size: 942 Bytes

Versions: 2

Compression:

Stored size: 942 Bytes

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)
        if content.instance_of?(Regexp)
          ret.stderr =~ content
        else
          ret.stderr.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

      def stderr
        if @result.nil?
          @result = backend.run_command(@name).stderr
        end
        @result
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
serverspec-1.0.0 lib/serverspec/type/command.rb
serverspec-0.16.0 lib/serverspec/type/command.rb