aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/gems/rspec-1.3.1/lib/spec/interop
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2011-02-24 15:10:14 +0000
committerLouise Crow <louise.crow@gmail.com>2011-02-24 15:10:14 +0000
commit08a64f9e3139851fd65c7ba6969ee590b4afea6a (patch)
tree20c77e796002dfa95b2af3ba00ebd2f691c02fc7 /vendor/gems/rspec-1.3.1/lib/spec/interop
parent3757bb52c0aa86b779b00428d7ebe35b30cea1ee (diff)
Adding rspec gem.
Diffstat (limited to 'vendor/gems/rspec-1.3.1/lib/spec/interop')
-rw-r--r--vendor/gems/rspec-1.3.1/lib/spec/interop/test.rb44
-rw-r--r--vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/autorunner.rb6
-rw-r--r--vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/testcase.rb56
-rw-r--r--vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/testresult.rb6
-rw-r--r--vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/testsuite_adapter.rb36
-rw-r--r--vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/ui/console/testrunner.rb61
6 files changed, 209 insertions, 0 deletions
diff --git a/vendor/gems/rspec-1.3.1/lib/spec/interop/test.rb b/vendor/gems/rspec-1.3.1/lib/spec/interop/test.rb
new file mode 100644
index 000000000..156ab8f87
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/lib/spec/interop/test.rb
@@ -0,0 +1,44 @@
+require 'spec'
+
+if Spec::Ruby.version.to_f >= 1.9
+ gem 'test-unit','= 1.2.3'
+end
+
+require 'test/unit'
+
+if Spec::Ruby.version.to_f >= 1.9
+ require 'test/unit/version'
+ if Test::Unit::VERSION > '1.2.3'
+ raise <<-MESSAGE
+#{'*' * 50}
+Required: test-unit-1.2.3
+Loaded: test-unit-#{Test::Unit::VERSION}
+
+With ruby-1.9, rspec-#{Spec::VERSION::STRING} requires test-unit-1.2.3, and
+tries to force it with "gem 'test-unit', '= 1.2.3'" in:
+
+ #{__FILE__}
+
+Unfortunately, test-unit-#{Test::Unit::VERSION} was loaded anyway. While we are
+aware of this bug we have not been able to track down its source.
+Until we do, you have two alternatives:
+
+* uninstall test-unit-#{Test::Unit::VERSION}
+* use 'script/spec' instead of 'rake spec'
+#{'*' * 50}
+MESSAGE
+ end
+end
+
+
+require 'test/unit/testresult'
+
+require 'spec/interop/test/unit/testcase'
+require 'spec/interop/test/unit/testsuite_adapter'
+require 'spec/interop/test/unit/autorunner'
+require 'spec/interop/test/unit/testresult'
+require 'spec/interop/test/unit/ui/console/testrunner'
+
+Spec::Example::ExampleGroupFactory.default(Test::Unit::TestCase)
+
+Test::Unit.run = true
diff --git a/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/autorunner.rb b/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/autorunner.rb
new file mode 100644
index 000000000..3944e6995
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/autorunner.rb
@@ -0,0 +1,6 @@
+class Test::Unit::AutoRunner
+ remove_method :process_args
+ def process_args(argv)
+ true
+ end
+end
diff --git a/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/testcase.rb b/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/testcase.rb
new file mode 100644
index 000000000..dc10a2a64
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/testcase.rb
@@ -0,0 +1,56 @@
+require 'test/unit/testcase'
+
+module Test
+ module Unit
+ # This extension of the standard Test::Unit::TestCase makes RSpec
+ # available from within, so that you can do things like:
+ #
+ # require 'spec/test/unit'
+ #
+ # class MyTest < Test::Unit::TestCase
+ # it "should work with Test::Unit assertions" do
+ # assert_equal 4, 2+1
+ # end
+ #
+ # def test_should_work_with_rspec_expectations
+ # (3+1).should == 5
+ # end
+ # end
+ #
+ # See also Spec::Example::ExampleGroup
+ class TestCase
+ extend Spec::Example::ExampleGroupMethods
+ include Spec::Example::ExampleMethods
+
+ def self.suite
+ Test::Unit::TestSuiteAdapter.new(self)
+ end
+
+ def self.example_method?(method_name)
+ should_method?(method_name) || test_method?(method_name)
+ end
+
+ def self.test_method?(method_name)
+ method_name =~ /^test./ && (
+ instance_method(method_name).arity == 0 ||
+ instance_method(method_name).arity == -1
+ )
+ end
+
+ before(:each) {setup}
+ after(:each) {teardown}
+
+ def initialize(description, &implementation)
+ super
+ # Some Test::Unit extensions depend on @method_name being present.
+ @method_name = description.description
+ @_result = ::Test::Unit::TestResult.new
+ end
+
+ def run(ignore_this_argument=nil)
+ super()
+ end
+
+ end
+ end
+end
diff --git a/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/testresult.rb b/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/testresult.rb
new file mode 100644
index 000000000..dddcfe868
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/testresult.rb
@@ -0,0 +1,6 @@
+class Test::Unit::TestResult
+ alias_method :tu_passed?, :passed?
+ def passed?
+ return tu_passed? & ::Spec::Runner.run
+ end
+end \ No newline at end of file
diff --git a/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/testsuite_adapter.rb b/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/testsuite_adapter.rb
new file mode 100644
index 000000000..76dcd14dc
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/testsuite_adapter.rb
@@ -0,0 +1,36 @@
+require 'test/unit/testsuite'
+
+module Test
+ module Unit
+ class TestSuiteAdapter < TestSuite
+ attr_reader :example_group, :examples
+ alias_method :tests, :examples
+ def initialize(example_group)
+ @example_group = example_group
+ @examples = example_group.examples
+ end
+
+ def name
+ example_group.description
+ end
+
+ def run(*args)
+ return true unless args.empty?
+ example_group.run(Spec::Runner.options)
+ end
+
+ def size
+ example_group.number_of_examples
+ end
+
+ def delete(example)
+ examples.delete example
+ end
+
+ def empty?
+ examples.empty?
+ end
+ end
+ end
+end
+
diff --git a/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/ui/console/testrunner.rb b/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/ui/console/testrunner.rb
new file mode 100644
index 000000000..8e9995e02
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/lib/spec/interop/test/unit/ui/console/testrunner.rb
@@ -0,0 +1,61 @@
+require 'test/unit/ui/console/testrunner'
+
+module Test
+ module Unit
+ module UI
+ module Console
+ class TestRunner
+
+ alias_method :started_without_rspec, :started
+ def started_with_rspec(result)
+ @result = result
+ @need_to_output_started = true
+ end
+ alias_method :started, :started_with_rspec
+
+ alias_method :test_started_without_rspec, :test_started
+ def test_started_with_rspec(name)
+ if @need_to_output_started
+ if @rspec_io
+ @rspec_io.rewind
+ output(@rspec_io.read)
+ end
+ output("Started")
+ @need_to_output_started = false
+ end
+ test_started_without_rspec(name)
+ end
+ alias_method :test_started, :test_started_with_rspec
+
+ alias_method :test_finished_without_rspec, :test_finished
+ def test_finished_with_rspec(name)
+ test_finished_without_rspec(name)
+ @ran_test = true
+ end
+ alias_method :test_finished, :test_finished_with_rspec
+
+ alias_method :finished_without_rspec, :finished
+ def finished_with_rspec(elapsed_time)
+ @ran_test ||= false
+ if @ran_test
+ finished_without_rspec(elapsed_time)
+ end
+ end
+ alias_method :finished, :finished_with_rspec
+
+ alias_method :setup_mediator_without_rspec, :setup_mediator
+ def setup_mediator_with_rspec
+ orig_io = @io
+ @io = StringIO.new
+ setup_mediator_without_rspec
+ ensure
+ @rspec_io = @io
+ @io = orig_io
+ end
+ alias_method :setup_mediator, :setup_mediator_with_rspec
+
+ end
+ end
+ end
+ end
+end