Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

Commit

Permalink
only try to load Test::Unit if Test::Unit is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Nov 17, 2008
1 parent 6fa3315 commit 5b163e2
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 8 deletions.
3 changes: 2 additions & 1 deletion History.txt
Expand Up @@ -11,9 +11,10 @@
* should throw_symbol accepts an optional argument: should throw_symbol(:sym, arg)
* fixed --line for jruby (Zach Moazeni)

* 1 bug fix
* 2 bug fixex

* fixed bug where {:a => 1, :b => 2}.should include(:a, :b) failed (Yossef Mendelssohn)
* only try to load Test::Unit if Test::Unit is defined

=== Version 1.1.11 / 2008-10-24

Expand Down
8 changes: 6 additions & 2 deletions lib/spec.rb
Expand Up @@ -7,7 +7,11 @@
require 'spec/version'
require 'spec/dsl'

if Object.const_defined?(:Test)
def test_unit_defined?
Object.const_defined?(:Test) && Test.const_defined?(:Unit)
end

if test_unit_defined?
require 'spec/interop/test'
end

Expand All @@ -23,7 +27,7 @@ def run
end

def exit?
!Object.const_defined?(:Test) || Test::Unit.run?
!test_unit_defined? || Test::Unit.run?
end

def spec_command?
Expand Down
6 changes: 1 addition & 5 deletions spec/spec/interop/test/unit/spec_spec.rb
Expand Up @@ -2,11 +2,7 @@

describe "ExampleGroup with test/unit/interop" do
include TestUnitSpecHelper

def resources
File.dirname(__FILE__) + "/resources"
end


describe "with passing examples" do
it "should output 0 failures" do
output = ruby("#{resources}/spec_that_passes.rb")
Expand Down
4 changes: 4 additions & 0 deletions spec/spec/interop/test/unit/test_unit_spec_helper.rb
Expand Up @@ -3,6 +3,10 @@

module TestUnitSpecHelper
include RubyForker

def resources
File.dirname(__FILE__) + "/resources"
end

def run_script(file_name)
output = ruby(file_name)
Expand Down
14 changes: 14 additions & 0 deletions stories/interop/test_but_not_test_unit
@@ -0,0 +1,14 @@
Story: Test is defined, but not Test::Unit

As an RSpec user who has my own library named Test (but not Test::Unit)
I want to run examples without getting Test::Unit NameErrors

Scenario: Run with ruby
Given the file test/spec_including_test_but_not_unit.rb
When I run it with the ruby interpreter
Then the stderr should not match "Test::Unit"

Scenario: Run with spec
Given the file test/spec_including_test_but_not_unit.rb
When I run it with the spec script
Then the stderr should not match "Test::Unit"
11 changes: 11 additions & 0 deletions stories/resources/test/spec_including_test_but_not_unit.rb
@@ -0,0 +1,11 @@
$:.push File.join(File.dirname(__FILE__), *%w[.. .. .. lib])
require 'spec'

module Test
end

describe "description" do
it "should description" do
1.should == 1
end
end

0 comments on commit 5b163e2

Please sign in to comment.