Sha256: 273f54244ac9acde00caccf0503c67b1b13335b0ef3fe746b6c7a818dfbe79ba

Contents?: true

Size: 928 Bytes

Versions: 1

Compression:

Stored size: 928 Bytes

Contents

$:.unshift( File.dirname( __FILE__ ) + '/../lib' )

require 'rubygems'
require 'mocha'
require 'rspec'
require 'stringio'
require 'ostruct'
require 'tempfile'

require 'sandbox'

RSpec.configure do |config|
  config.mock_with :mocha

  def capture
    results = OpenStruct.new

    begin
      $stdout = StringIO.new
      $stderr = StringIO.new
      yield
      results.stdout = $stdout.string
      results.stderr = $stderr.string
    ensure
      $stdout = STDOUT
      $stderr = STDERR
    end

    results
  end

  alias silence capture
end

# Thanks to Jay Fields for http://blog.jayfields.com/2007/11/ruby-testing-private-methods.html
class Class
  def publicize_methods
    saved_private_instance_methods = self.private_instance_methods
    begin
      self.class_eval { public *saved_private_instance_methods }
      yield
    ensure
      self.class_eval { private *saved_private_instance_methods }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-virtualenv-0.5.0 spec/spec_helper.rb