Sha256: fb2c9235453075bb3574845485073fe4f721039b0efc8e8bce700ef0d2f99306

Contents?: true

Size: 1.76 KB

Versions: 13

Compression:

Stored size: 1.76 KB

Contents

require 'blazing'
require 'rspec'
require 'stringio'
require 'pry'

ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"

#
# Stuff borrowed from carlhuda/bundler
#
RSpec.configure do |config|

  #
  # Reset Logger
  #
  Logging.appenders.reset
  Logging.appenders.string_io(
    'string_io',
    :layout => Logging.layouts.pattern(
      :pattern => ' ------> [blazing] %-5l: %m\n',
      :color_scheme => 'bright'
    )
  )

  Logging.logger.root.appenders = 'string_io'

  def capture(*streams)
    streams.map! { |stream| stream.to_s }
    begin
      result = StringIO.new
      streams.each { |stream| eval "$#{stream} = result" }
      yield
    ensure
      streams.each { |stream| eval("$#{stream} = #{stream.upcase}") }
    end
    result.string
  end

  def setup_sandbox
    @blazing_root = Dir.pwd
    @sandbox_directory = File.join('/tmp/blazing_sandbox')

    # Sometimes, when specs failed, the sandbox would stick around
    FileUtils.rm_rf(@sandbox_directory) if File.exists?(@sandbox_directory)

    # Setup Sandbox and cd into it
    Dir.mkdir(@sandbox_directory)
    Dir.chdir(@sandbox_directory)

    # Setup dummy repository
    Dir.mkdir('repository')
    `git init repository`

    # Setup dummy project
    Dir.mkdir('project')
    `git init project`

    # cd into project
    Dir.chdir('project')
  end

  def teardown_sandbox
    # Teardown Sandbox
    Dir.chdir(@blazing_root)
    FileUtils.rm_rf(@sandbox_directory)
  end

  def spec_root
    File.dirname(__FILE__)
  end

  #def prepare_sample_config
    #sample_config = File.join(spec_root, 'support', 'sample_config_1.rb')
    #Dir.mkdir(@sandbox_directory + '/config')
    #FileUtils.cp(sample_config, @sandbox_directory + '/config/blazing.rb')
  #end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
blazing-0.4.2 spec/spec_helper.rb
blazing-0.4.1 spec/spec_helper.rb
blazing-0.4.0 spec/spec_helper.rb
blazing-0.4.0.beta3 spec/spec_helper.rb
blazing-0.4.0.beta2 spec/spec_helper.rb
blazing-0.4.0.beta1 spec/spec_helper.rb
blazing-0.3.0 spec/spec_helper.rb
blazing-0.2.14 spec/spec_helper.rb
blazing-0.2.13 spec/spec_helper.rb
blazing-0.2.12 spec/spec_helper.rb
blazing-0.2.11 spec/spec_helper.rb
blazing-0.2.10 spec/spec_helper.rb
blazing-0.2.9 spec/spec_helper.rb