Sha256: b910a5c2550cbd235c50b4d9fe24353c582ccf58a0b5762f8028acd11cebf137

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

unless defined? Bundler
  require 'rubygems'
  require 'bundler'
  Bundler.setup
end

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'git-ssh-wrapper'
require 'rspec'

ROOT_PATH        = Pathname.new("..").expand_path(File.dirname(__FILE__))
PRIVATE_KEY_PATH = ROOT_PATH.join('spec/test_key').realpath.freeze
PRIVATE_KEY      = PRIVATE_KEY_PATH.read.freeze
GIT_SSH_BIN      = ROOT_PATH.join('bin/git-ssh').freeze
WRAPPER_BIN      = ROOT_PATH.join('bin/git-ssh-wrapper').freeze
PRINT_ENV_SCRIPT = ROOT_PATH.join('spec/print_env').freeze

module SpecHelpers
  def exist
    be_exist
  end

  def private_key
    PRIVATE_KEY
  end

  def private_key_path
    PRIVATE_KEY_PATH
  end

  def print_env_script
    PRINT_ENV_SCRIPT
  end

  def run_succeeds(bin, *args)
    cmd = ([bin] + args).flatten.join(' ')
    ret = `#{cmd} 2>&1`
    if !$?.success?
      fail "Expected exit status 0, got #{$?.exitstatus}.\n\t#{cmd}\n\t#{ret}"
    end
    ret
  end

  def run_fails(bin, *args)
    cmd = ([bin] + args).flatten.join(' ')
    ret = `#{cmd} 2>&1`
    if $?.success?
      fail "Expected failure.\n\t#{cmd}\n\t#{ret}"
    end
    ret
  end
end

RSpec.configure do |config|
  config.include SpecHelpers
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git-ssh-wrapper-0.2.0 spec/spec_helper.rb