vagrant/test/acceptance/base.rb

48 lines
1.3 KiB
Ruby
Raw Normal View History

require "rubygems"
require "rspec/autorun"
require "log4r"
2011-12-11 23:53:11 +00:00
# Add the test directory to the load path
2011-12-04 03:05:50 +00:00
$:.unshift File.expand_path("../../", __FILE__)
# Load in the supporting files for our tests
2011-12-11 23:53:11 +00:00
require "acceptance/support/shared/base_context"
require "acceptance/support/config"
require "acceptance/support/virtualbox"
require "acceptance/support/matchers/match_output"
2011-11-27 18:16:24 +00:00
# Do not buffer output
$stdout.sync = true
$stderr.sync = true
# If VirtualBox is currently running, fail.
if Acceptance::VirtualBox.find_vboxsvc
$stderr.puts "VirtualBox must be closed and remain closed for the duration of the tests."
abort
end
# Enable logging if requested
if ENV["ACCEPTANCE_LOGGING"]
logger = Log4r::Logger.new("acceptance")
logger.outputters = Log4r::Outputter.stdout
logger.level = Log4r.const_get(ENV["ACCEPTANCE_LOGGING"].upcase)
logger = nil
end
# Parse the command line options and load the global configuration.
if !ENV.has_key?("ACCEPTANCE_CONFIG")
$stderr.puts "A configuration file must be passed into the acceptance test."
abort
elsif !File.file?(ENV["ACCEPTANCE_CONFIG"])
$stderr.puts "The configuration file must exist."
abort
end
$acceptance_options = Acceptance::Config.new(ENV["ACCEPTANCE_CONFIG"])
# Configure RSpec
RSpec.configure do |c|
c.expect_with :rspec, :stdlib
end