Sha256: 0d5c7e448c19c9c5295a6cd0ae10803ec6af4868e52d63d275d9093a0837e3e8

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

# encoding: utf-8

##
# Use Bundler
require 'rubygems' if RUBY_VERSION < '1.9'
require 'bundler/setup'

##
# Load Backup
require 'backup'

require 'timecop'

module Backup::ExampleHelpers
  # ripped from MiniTest :)
  # RSpec doesn't have a method for this? Am I missing something?
  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
end

require 'rspec/autorun'
RSpec.configure do |config|
  ##
  # Use Mocha to mock with RSpec
  config.mock_with :mocha

  ##
  # Example Helpers
  config.include Backup::ExampleHelpers

  ##
  # Actions to perform before each example
  config.before(:each) do
    FileUtils.collect_method(:noop).each do |method|
      FileUtils.stubs(method).raises("Unexpected call to FileUtils.#{ method }")
    end

    Open4.stubs(:popen4).raises('Unexpected call to Open4::popen4()')

    [:message, :error, :warn, :normal, :silent].each do |method|
      Backup::Logger.stubs(method).raises("Unexpected call to Backup::Logger.#{ method }")
    end
  end
end

unless @_put_ruby_version
  puts @_put_ruby_version = "\n\nRuby version: #{ RUBY_DESCRIPTION }\n\n"
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
backup-agoddard-3.0.28 spec/spec_helper.rb
backup-agoddard-3.0.27 spec/spec_helper.rb
ey-vendored-backup-3.0.27 spec/spec_helper.rb
backup-3.0.27 spec/spec_helper.rb
backup-3.0.26 spec/spec_helper.rb
backup-3.0.25 spec/spec_helper.rb
backup-3.0.24 spec/spec_helper.rb