Sha256: 1e3baa2e0af841884cad40beb709b380f753df4f8bbae13746a4827f313ed99d

Contents?: true

Size: 660 Bytes

Versions: 3

Compression:

Stored size: 660 Bytes

Contents

require 'singleton'
require 'specinfra/command_result'

module SpecInfra
  module Backend
    class Base
      include Singleton

      def set_commands(c)
        @commands = c
      end

      def set_example(e)
        @example = e
      end

      def commands
        @commands
      end

      def check_zero(cmd, *args)
        run_command(commands.send(cmd, *args)).success?
      end

      # Default action is to call check_zero with args
      def method_missing(meth, *args, &block)
        if meth =~ /^check/
          check_zero(meth, *args)
        else
          run_command(commands.send(meth, *args))
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
specinfra-1.0.2 lib/specinfra/backend/base.rb
specinfra-1.0.1 lib/specinfra/backend/base.rb
specinfra-1.0.0 lib/specinfra/backend/base.rb