Sha256: aa885907ab81d3beaf8f5a8d0dd5d4220b00c510da16ab83eda62524ea125254

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require "rubygems"
require "bundler/setup"
Bundler.require(:default, :test)
if ENV["COVERAGE"]
  require "simplecov"
  SimpleCov.start
end
require File.expand_path("../../lib/hisyo.rb", __FILE__)


RSpec.configure do |conf|
  conf.before(:all) do
    @root = File.expand_path("../../", __FILE__)
    @approot = File.expand_path("../testapp", __FILE__)
  end

  # https://github.com/seattlerb/minitest/blob/master/lib/minitest/unit.rb#L431
  ##
  # Captures $stdout and $stderr into strings:
  #
  #   out, err = capture_io do
  #     warn "You did a bad thing"
  #   end
  #
  #   assert_match %r%bad%, err
  def capture_io
    require 'stringio'

    orig_stdout, orig_stderr         = $stdout, $stderr
    captured_stdout, captured_stderr = StringIO.new, StringIO.new
    $stdout, $stderr                 = captured_stdout, captured_stderr

    yield

    return captured_stdout.string, captured_stderr.string
  ensure
    $stdout = orig_stdout
    $stderr = orig_stderr
  end

  def generate_app(options = {})
    capture_io do
      Hisyo.generate_project(options)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hisyo-0.1.0 spec/spec_helper.rb