Permalink
Browse files

Use allocate rather than monkey patching Test::Unit::TestCase#initial…

…ize.

Thanks to @justinko for the suggestion.
  • Loading branch information...
1 parent bbfb723 commit 37d038becfff4522271af13d2fc2df954ec0dabb @myronmarston myronmarston committed Mar 28, 2011
Showing with 4 additions and 10 deletions.
  1. +2 −2 spec/rspec/matchers/matchers_spec.rb
  2. +2 −2 spec/rspec/matchers/method_missing_spec.rb
  3. +0 −6 spec/spec_helper.rb
@@ -12,14 +12,14 @@ module RSpec
context "once required" do
it "includes itself in Test::Unit::TestCase" do
- test_unit_case = Test::Unit::TestCase.new
+ test_unit_case = Test::Unit::TestCase.allocate
sample_matchers.each do |sample_matcher|
test_unit_case.should respond_to(sample_matcher)
end
end
it "includes itself in MiniTest::Unit::TestCase", :if => defined?(MiniTest) do
- minitest_case = MiniTest::Unit::TestCase.new(nil)
+ minitest_case = MiniTest::Unit::TestCase.allocate
sample_matchers.each do |sample_matcher|
minitest_case.should respond_to(sample_matcher)
end
@@ -11,12 +11,12 @@
it_behaves_like "a well-behaved method_missing hook"
context 'when invoked in a Test::Unit::TestCase' do
- subject { Test::Unit::TestCase.new }
+ subject { Test::Unit::TestCase.allocate }
it_behaves_like "a well-behaved method_missing hook"
end
context 'when invoked in a MiniTest::Unit::TestCase', :if => defined?(MiniTest) do
- subject { MiniTest::Unit::TestCase.new(nil) }
+ subject { MiniTest::Unit::TestCase.allocate }
it_behaves_like "a well-behaved method_missing hook"
end
end
View
@@ -9,12 +9,6 @@ def add_to_load_path(path, prepend=false)
require 'test/unit'
-# Make it easy to instantiate test cases for our specs.
-# Test::Unit::TestCase#initialize is picky about what arguments it expects.
-class Test::Unit::TestCase
- def initialize; end
-end
-
add_to_load_path("rspec-expectations", :prepend)
add_to_load_path("rspec-core")
add_to_load_path("rspec-mocks")

0 comments on commit 37d038b

Please sign in to comment.