Sha256: fdb040c26e93d3a1f99555c460b44ec22d683a2a5e15f686612f9c3f6cc5f03c

Contents?: true

Size: 794 Bytes

Versions: 3

Compression:

Stored size: 794 Bytes

Contents

require 'fileutils'

#constants
ROOT    = `pwd`.strip.freeze
SAMPLE  = "#{ROOT}/spec/sample_site".freeze
BUILD   = "#{ROOT}/build".freeze

# helper methods
def quiet_stdout
  if QUIET
    begin
      orig_stderr = $stderr.clone
      orig_stdout = $stdout.clone
      $stderr.reopen File.new('/dev/null', 'w')
      $stdout.reopen File.new('/dev/null', 'w')
      retval = yield
    rescue StandardError => e
      $stdout.reopen orig_stdout
      $stderr.reopen orig_stderr
      raise e
    ensure
      $stdout.reopen orig_stdout
      $stderr.reopen orig_stderr
    end
    retval
  else
    yield
  end
end

module WaxTasks::Test
  def self.reset
    Dir.chdir(ROOT)
    FileUtils.rm_r(BUILD) if File.directory?(BUILD)
    FileUtils.copy_entry SAMPLE, BUILD
    Dir.chdir(BUILD)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wax_tasks-0.3.2 spec/setup.rb
wax_tasks-0.3.1 spec/setup.rb
wax_tasks-0.3.0 spec/setup.rb