Permalink
Browse files

Include Matchers in MiniTest and TestUnit

- Closes #19.
  • Loading branch information...
1 parent de19d98 commit 78605a8fd9864796da8b6700614276a78f52a42b @txus txus committed with dchelimsky Oct 2, 2010
Showing with 57 additions and 0 deletions.
  1. +8 −0 lib/rspec/matchers.rb
  2. +49 −0 spec/rspec/matchers/matchers_spec.rb
View
8 lib/rspec/matchers.rb
@@ -158,6 +158,14 @@ module Matchers
if RSpec.respond_to?(:configure)
RSpec.configure {|c| c.include self}
end
+
+ # Include Matchers for other test frameworks
+ if defined?(Test::Unit::TestCase)
+ Test::Unit::TestCase.send(:include, self)
+ end
+ if defined?(MiniTest::Unit::TestCase)
+ MiniTest::Unit::TestCase.send(:include, self)
+ end
end
end
View
49 spec/rspec/matchers/matchers_spec.rb
@@ -1,2 +1,51 @@
require 'spec_helper'
+module Test
+ module Unit
+ class TestCase
+ end
+ end
+end
+
+module MiniTest
+ module Unit
+ class TestCase
+ end
+ end
+end
+
+module RSpec
+ describe Matchers do
+
+ let(:sample_matchers) do
+ [:be,
+ :be_close,
+ :be_instance_of,
+ :be_kind_of]
+ end
+
+ context "once required" do
+
+ before(:all) do
+ path = File.expand_path("../../../../#{path}", __FILE__)
+ load File.join(path, 'lib/rspec/matchers.rb')
+ end
+
+ it "includes itself in Test::Unit::TestCase" do
+ test_unit_case = Test::Unit::TestCase.new
+ sample_matchers.each do |sample_matcher|
+ test_unit_case.should respond_to(sample_matcher)
+ end
+ end
+
+ it "includes itself in MiniTest::Unit::TestCase" do
+ minitest_case = MiniTest::Unit::TestCase.new
+ sample_matchers.each do |sample_matcher|
+ minitest_case.should respond_to(sample_matcher)
+ end
+ end
+
+ end
+
+ end
+end

0 comments on commit 78605a8

Please sign in to comment.