Skip to content

Commit

Permalink
Guard against the require succeeding, but not properly loading a modu…
Browse files Browse the repository at this point in the history
…le. Specifically, TeamCity attempts to monkeypatch minitest if it's defined, but ends up defining a minimal module causing test failures.
  • Loading branch information
cmeiklejohn committed Jul 6, 2011
1 parent 5e83c77 commit b4c33ed
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
# Why: http://groups.google.com/group/cukes/browse_thread/thread/5682d41436e235d7
begin
require 'minitest/unit'
class MiniTest::Unit
class << self
@@installed_at_exit = true
end
# Don't attempt to monkeypatch if the require succeeded but didn't
# define the actual module.
#
# https://github.com/cucumber/cucumber/pull/93
# http://youtrack.jetbrains.net/issue/TW-17414
if defined?(MiniTest::Unit)
class MiniTest::Unit
class << self
@@installed_at_exit = true
end

def run(*)
0
def run(*)
0
end
end
end
rescue LoadError => ignore
end

# Do the same for Test::Unit
begin
require 'test/unit'
module Test::Unit
def self.run?
true
require 'test/unit'
# Don't attempt to monkeypatch if the require succeeded but didn't
# define the actual module.
#
# https://github.com/cucumber/cucumber/pull/93
# http://youtrack.jetbrains.net/issue/TW-17414
if defined?(Test::Unit)
module Test::Unit
def self.run?
true
end
end
end
rescue LoadError => ignore
Expand Down

0 comments on commit b4c33ed

Please sign in to comment.