Sha256: 1ebd9e6f0346707728e3cf4c34721d3de83fa263ccd12e7096297140fd676cd7

Contents?: true

Size: 1.88 KB

Versions: 15

Compression:

Stored size: 1.88 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

RSpec.configure do |config|
  # This allows you to limit a spec run to individual examples or groups
  # you care about by tagging them with `:focus` metadata. When nothing
  # is tagged with `:focus`, all examples get run. RSpec also provides
  # aliases for `it`, `describe`, and `context` that include `:focus`
  # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
  config.filter_run_when_matching :focus
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

15 entries across 15 versions & 1 rubygems

Version Path
td-0.17.1 spec/spec_helper.rb
td-0.17.0 spec/spec_helper.rb
td-0.16.10 spec/spec_helper.rb
td-0.16.9 spec/spec_helper.rb
td-0.16.8 spec/spec_helper.rb
td-0.16.7 spec/spec_helper.rb
td-0.16.6 spec/spec_helper.rb
td-0.16.5 spec/spec_helper.rb
td-0.16.4 spec/spec_helper.rb
td-0.16.3 spec/spec_helper.rb
td-0.16.1 spec/spec_helper.rb
td-0.16.0 spec/spec_helper.rb
td-0.15.9 spec/spec_helper.rb
td-0.15.8 spec/spec_helper.rb
td-0.15.7 spec/spec_helper.rb