Sha256: 1f5a4008263c0c7938bf516e9341d0d7347c362e6bba78cd7da5ada590297db8

Contents?: true

Size: 1.47 KB

Versions: 11

Compression:

Stored size: 1.47 KB

Contents

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))

require 'rspec'
require 'json'

if ENV['SIMPLE_COV']
  # SimpleCov
  # https://github.com/colszowka/simplecov
  require 'simplecov'
  SimpleCov.start do
    add_filter 'spec/'
    add_filter 'pkg/'
    add_filter 'vendor/'
  end
end

# XXX skip coverage setting if run appveyor. Because, fail to push coveralls in appveyor.
unless ENV['APPVEYOR']
  require 'coveralls'
  Coveralls.wear!('rails')
end

require 'td/command/runner'

def execute_td(command_line)
  args = command_line.split(" ")
  original_stdin, original_stderr, original_stdout = $stdin, $stderr, $stdout

  $stdin  = captured_stdin  = StringIO.new
  $stderr = captured_stderr = StringIO.new
  $stdout = captured_stdout = StringIO.new
  class << captured_stdout
    def tty?
      true
    end
  end

  begin
    runner = TreasureData::Command::Runner.new
    $0 = 'td'
    runner.run(args)
  rescue SystemExit
  ensure
    $stdin, $stderr, $stdout = original_stdin, original_stderr, original_stdout
  end

  [captured_stderr.string, captured_stdout.string]
end

class CallSystemExitError < RuntimeError; end

shared_context 'quiet_out' do
  let(:stdout_io) { StringIO.new }
  let(:stderr_io) { StringIO.new }

  around do |example|
    out = $stdout.dup
    err= $stdout.dup
    begin
      $stdout = stdout_io
      $stderr = stderr_io
      example.call
    ensure
      $stdout = out
      $stderr = err
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
td-0.15.6 spec/spec_helper.rb
td-0.15.5 spec/spec_helper.rb
td-0.15.4 spec/spec_helper.rb
td-0.15.3 spec/spec_helper.rb
td-0.15.2 spec/spec_helper.rb
td-0.15.0 spec/spec_helper.rb
td-0.14.1 spec/spec_helper.rb
td-0.14.0 spec/spec_helper.rb
td-0.13.2 spec/spec_helper.rb
td-0.13.1 spec/spec_helper.rb
td-0.13.0 spec/spec_helper.rb