Sha256: d3d3c99afa9c7a8331a4eb3fb5b6c524be8335752beb1ae0cd7359883eda6d16

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

#encoding: utf-8
require 'bob_the_helper'


include BobTheHelper::FileSystem
include BobTheHelper::Command

def root_directory
  File.expand_path('../../../', __FILE__)
end

def pointrb_config_directories
  result = []
  result << expand_path( File.join('~', '.config', 'pointrb' ) )
  result << expand_path( File.join('~', '.config', 'pointrb', 'layouts' ) )

  result
end

def run_this_command(command)
  search_paths = [ File.join( root_directory, 'bin' ) , '/usr/bin', '/bin' ]

  new_env_vars = { 
    'HOME' => File.join(working_directory, ENV['HOME']),
    'PATH' => search_paths.join(':') 
  }

  if @cmd_debug
    runner = lambda do |cmd| 
      r = system(cmd) 

      status_klass = Class.new do
        def initialize(status)
          @status = status
        end

        def success?
          @status
        end
      end

      result = CommandResult.new
      result.stderr = "Keep in mind, you're in debugging mode. Look for '@cmd_debug' in your feature files"
      result.stdout = "Keep in mind, you're in debugging mode. Look for '@cmd_debug' in your feature files"
      result.status = status_klass.new(r)

      result
    end
  else
    runner = lambda { |cmd| run_command(cmd) }
  end

  result = isolated_environment new_env_vars  do

    cmd_result = switch_to_working_directory do
      runner.call(command)
    end

    cmd_result
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pointrb-0.1.2 features/support/helper.rb
pointrb-0.1.1 features/support/helper.rb
pointrb-0.1.0 features/support/helper.rb