Fri Feb 23 01:50:44 PST 2007 'Brian Donovan ' * Adds the ability to specify what superclass to use. Allows test/spec to be used in things like Rails' integration tests. diff -rN -u old-testspec/lib/test/spec.rb new-testspec/lib/test/spec.rb --- old-testspec/lib/test/spec.rb 2007-02-27 20:40:46.000000000 -0800 +++ new-testspec/lib/test/spec.rb 2007-02-27 20:40:46.000000000 -0800 @@ -352,9 +352,9 @@ attr_accessor :setups attr_accessor :teardowns - def context(name, &block) + def context(name, superclass=Test::Unit::TestCase, &block) (Test::Spec::CONTEXTS[self.name + "\t" + name] ||= - Test::Spec::TestCase.new(name, self)).add(&block) + Test::Spec::TestCase.new(name, self, superclass)).add(&block) end def specify(specname, &block) @@ -397,8 +397,8 @@ @@POSITION = 0 - def initialize(name, parent=nil) - @testcase = Class.new(Test::Unit::TestCase) { + def initialize(name, parent=nil, superclass=Test::Unit::TestCase) + @testcase = Class.new(superclass) { include InstanceMethods extend ClassMethods } @@ -503,8 +503,8 @@ end module Kernel - def context(name, &block) # :doc: - (Test::Spec::CONTEXTS[name] ||= Test::Spec::TestCase.new(name)).add(&block) + def context(name, superclass=Test::Unit::TestCase, &block) # :doc: + (Test::Spec::CONTEXTS[name] ||= Test::Spec::TestCase.new(name, nil, superclass)).add(&block) end private :context diff -rN -u old-testspec/test/spec_testspec.rb new-testspec/test/spec_testspec.rb --- old-testspec/test/spec_testspec.rb 2007-02-27 20:40:46.000000000 -0800 +++ new-testspec/test/spec_testspec.rb 2007-02-27 20:40:46.000000000 -0800 @@ -532,3 +532,15 @@ foo.should.equal 42 end end + +class CustomTestUnitSubclass < Test::Unit::TestCase + def test_truth + assert true + end +end + +context "contexts with subclasses", CustomTestUnitSubclass do + specify "use the supplied class as the superclass" do + self.should.be.a.kind_of CustomTestUnitSubclass + end +end \ No newline at end of file