2008-06-18 02:57:57 -04:00
|
|
|
require 'stringio'
|
|
|
|
|
|
|
|
|
|
dir = File.dirname(__FILE__)
|
|
|
|
|
lib_path = File.expand_path("#{dir}/../lib")
|
|
|
|
|
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
|
|
|
|
|
$_spec_spec = true # Prevents Kernel.exit in various places
|
|
|
|
|
|
|
|
|
|
require 'spec'
|
|
|
|
|
require 'spec/mocks'
|
|
|
|
|
require 'spec/story'
|
|
|
|
|
spec_classes_path = File.expand_path("#{dir}/../spec/spec/spec_classes")
|
|
|
|
|
require spec_classes_path unless $LOAD_PATH.include?(spec_classes_path)
|
|
|
|
|
require File.dirname(__FILE__) + '/../lib/spec/expectations/differs/default'
|
|
|
|
|
|
2008-11-29 12:00:06 -05:00
|
|
|
module Spec
|
|
|
|
|
module Example
|
|
|
|
|
class NonStandardError < Exception; end
|
|
|
|
|
end
|
|
|
|
|
|
2008-06-18 02:57:57 -04:00
|
|
|
module Matchers
|
|
|
|
|
def fail
|
|
|
|
|
raise_error(Spec::Expectations::ExpectationNotMetError)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def fail_with(message)
|
|
|
|
|
raise_error(Spec::Expectations::ExpectationNotMetError, message)
|
|
|
|
|
end
|
|
|
|
|
|
2008-11-29 12:00:06 -05:00
|
|
|
def exception_from(&block)
|
|
|
|
|
exception = nil
|
|
|
|
|
begin
|
|
|
|
|
yield
|
|
|
|
|
rescue StandardError => e
|
|
|
|
|
exception = e
|
2008-06-18 02:57:57 -04:00
|
|
|
end
|
2008-11-29 12:00:06 -05:00
|
|
|
exception
|
2008-06-18 02:57:57 -04:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2008-11-29 12:00:06 -05:00
|
|
|
share_as :SandboxedOptions do
|
2008-06-18 02:57:57 -04:00
|
|
|
attr_reader :options
|
|
|
|
|
|
2008-11-29 12:00:06 -05:00
|
|
|
before(:each) do
|
|
|
|
|
@original_rspec_options = ::Spec::Runner.options
|
|
|
|
|
::Spec::Runner.use(@options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new))
|
2008-06-18 02:57:57 -04:00
|
|
|
end
|
|
|
|
|
|
2008-11-29 12:00:06 -05:00
|
|
|
after(:each) do
|
|
|
|
|
::Spec::Runner.use(@original_rspec_options)
|
2008-06-18 02:57:57 -04:00
|
|
|
end
|
|
|
|
|
|
2008-11-29 12:00:06 -05:00
|
|
|
def run_with(options)
|
|
|
|
|
::Spec::Runner::CommandLine.run(options)
|
2008-06-18 02:57:57 -04:00
|
|
|
end
|
2008-11-29 12:00:06 -05:00
|
|
|
end unless Object.const_defined?(:SandboxedOptions)
|