Sha256: 0d0061d230a9836da51fa08bee976085e21ea5354cfae3e7c7c36bab7406c465

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

require 'fileutils'
include FileUtils
require 'buildem'
require 'rspec'

$SPEC_ROOT = File.expand_path(File.dirname(__FILE__))

require "bundler/setup"

def require_files filename
  filename.each do |file|
    require "#{$SPEC_ROOT}/../lib/buildem/#{file}"
  end if filename.class == Array
  require "#{$SPEC_ROOT}/../lib/buildem/#{filename}" if filename.class == String
end
  
def within path
  cd path do
    yield
  end
end

RSpec.configure do |config|
  
  def expecting_exception(clazz)
    begin
      yield
    rescue Exception => e
      case clazz
      when String
        e.message.should == clazz
        return
      when Regexp
        e.message.should =~ clazz
        return
      else
        e.class.should   == clazz
        return
      end
    end
    fail "Did not throw an exception like intended"
  end
  
  def capture(stream)
    begin
      stream = stream.to_s
      eval "$#{stream} = StringIO.new"
      yield
      result = eval("$#{stream}").string
    ensure
      eval("$#{stream} = #{stream.upcase}")
    end

    result
  end

  def source_root
    File.join(File.dirname(__FILE__), 'fixtures')
  end

  def destination_root
    File.join(File.dirname(__FILE__), 'sandbox')
  end

  alias :silence :capture
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
buildem-0.0.5 spec/helper.rb
buildem-0.0.4 spec/helper.rb