jferris-mocha 0.9.7.20090911190113 → 0.9.8.20100526112143

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/README +3 -1
  2. data/RELEASE +7 -0
  3. data/Rakefile +3 -3
  4. data/lib/mocha/configuration.rb +29 -10
  5. data/lib/mocha/expectation.rb +5 -1
  6. data/lib/mocha/integration/mini_test.rb +27 -2
  7. data/lib/mocha/integration/mini_test/exception_translation.rb +20 -0
  8. data/lib/mocha/integration/mini_test/version_13.rb +44 -0
  9. data/lib/mocha/integration/mini_test/{version_131_and_above.rb → version_140.rb} +7 -12
  10. data/lib/mocha/integration/mini_test/version_141.rb +56 -0
  11. data/lib/mocha/integration/mini_test/version_142_and_above.rb +56 -0
  12. data/lib/mocha/integration/test_unit.rb +20 -7
  13. data/lib/mocha/integration/test_unit/gem_version_200.rb +3 -0
  14. data/lib/mocha/integration/test_unit/{gem_version_201_and_above.rb → gem_version_201_to_202.rb} +4 -1
  15. data/lib/mocha/integration/test_unit/gem_version_203_to_207.rb +52 -0
  16. data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +3 -0
  17. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +3 -0
  18. data/lib/mocha/mock.rb +0 -1
  19. data/lib/mocha/module_method.rb +1 -1
  20. data/lib/mocha/parameter_matchers/base.rb +50 -2
  21. data/lib/mocha/parameter_matchers/has_key.rb +1 -0
  22. data/lib/mocha/parameter_matchers/has_value.rb +1 -0
  23. data/lib/mocha/parameter_matchers/includes.rb +1 -0
  24. data/lib/mocha/parameter_matchers/regexp_matches.rb +1 -0
  25. data/test/acceptance/acceptance_test_helper.rb +1 -1
  26. data/test/acceptance/api_test.rb +1 -1
  27. data/test/acceptance/bug_18914_test.rb +1 -1
  28. data/test/acceptance/bug_21465_test.rb +1 -1
  29. data/test/acceptance/bug_21563_test.rb +1 -1
  30. data/test/acceptance/expected_invocation_count_test.rb +1 -1
  31. data/test/acceptance/failure_messages_test.rb +1 -1
  32. data/test/acceptance/minitest_test.rb +128 -124
  33. data/test/acceptance/mocha_example_test.rb +1 -1
  34. data/test/acceptance/mocha_test_result_test.rb +1 -1
  35. data/test/acceptance/mock_test.rb +1 -1
  36. data/test/acceptance/mock_with_initializer_block_test.rb +1 -1
  37. data/test/acceptance/mocked_methods_dispatch_test.rb +1 -1
  38. data/test/acceptance/optional_parameters_test.rb +1 -1
  39. data/test/acceptance/parameter_matcher_test.rb +38 -1
  40. data/test/acceptance/partial_mocks_test.rb +1 -1
  41. data/test/acceptance/return_value_test.rb +1 -1
  42. data/test/acceptance/sequence_test.rb +1 -1
  43. data/test/acceptance/states_test.rb +1 -1
  44. data/test/acceptance/stub_any_instance_method_test.rb +5 -2
  45. data/test/acceptance/stub_class_method_test.rb +5 -2
  46. data/test/acceptance/stub_everything_test.rb +1 -1
  47. data/test/acceptance/stub_instance_method_test.rb +5 -2
  48. data/test/acceptance/stub_module_method_test.rb +3 -3
  49. data/test/acceptance/stub_test.rb +1 -1
  50. data/test/acceptance/stubba_example_test.rb +1 -1
  51. data/test/acceptance/stubba_test.rb +1 -1
  52. data/test/acceptance/stubba_test_result_test.rb +1 -1
  53. data/test/acceptance/stubbing_error_backtrace_test.rb +1 -1
  54. data/test/acceptance/stubbing_method_unnecessarily_test.rb +1 -1
  55. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +5 -5
  56. data/test/acceptance/stubbing_non_existent_class_method_test.rb +5 -5
  57. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +5 -5
  58. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +9 -9
  59. data/test/acceptance/stubbing_non_public_class_method_test.rb +9 -9
  60. data/test/acceptance/stubbing_non_public_instance_method_test.rb +9 -9
  61. data/test/acceptance/stubbing_on_non_mock_object_test.rb +5 -5
  62. data/test/mini_test_result.rb +74 -0
  63. data/test/test_helper.rb +1 -0
  64. data/test/test_runner.rb +25 -11
  65. data/test/unit/any_instance_method_test.rb +1 -1
  66. data/test/unit/array_inspect_test.rb +1 -1
  67. data/test/unit/backtrace_filter_test.rb +1 -1
  68. data/test/unit/cardinality_test.rb +1 -1
  69. data/test/unit/central_test.rb +1 -1
  70. data/test/unit/change_state_side_effect_test.rb +1 -1
  71. data/test/unit/class_method_test.rb +1 -1
  72. data/test/unit/configuration_test.rb +38 -0
  73. data/test/unit/date_time_inspect_test.rb +1 -1
  74. data/test/unit/exception_raiser_test.rb +1 -1
  75. data/test/unit/expectation_list_test.rb +1 -1
  76. data/test/unit/expectation_test.rb +1 -1
  77. data/test/unit/hash_inspect_test.rb +1 -1
  78. data/test/unit/in_state_ordering_constraint_test.rb +1 -1
  79. data/test/unit/metaclass_test.rb +1 -1
  80. data/test/unit/method_matcher_test.rb +1 -1
  81. data/test/unit/mock_test.rb +1 -1
  82. data/test/unit/mockery_test.rb +1 -1
  83. data/test/unit/multiple_yields_test.rb +1 -1
  84. data/test/unit/no_yields_test.rb +1 -1
  85. data/test/unit/object_inspect_test.rb +9 -8
  86. data/test/unit/object_test.rb +1 -1
  87. data/test/unit/parameter_matchers/all_of_test.rb +1 -1
  88. data/test/unit/parameter_matchers/any_of_test.rb +1 -1
  89. data/test/unit/parameter_matchers/anything_test.rb +1 -1
  90. data/test/unit/parameter_matchers/equals_test.rb +1 -1
  91. data/test/unit/parameter_matchers/has_entries_test.rb +1 -1
  92. data/test/unit/parameter_matchers/has_entry_test.rb +1 -1
  93. data/test/unit/parameter_matchers/has_key_test.rb +20 -1
  94. data/test/unit/parameter_matchers/has_value_test.rb +21 -1
  95. data/test/unit/parameter_matchers/includes_test.rb +21 -2
  96. data/test/unit/parameter_matchers/instance_of_test.rb +1 -1
  97. data/test/unit/parameter_matchers/is_a_test.rb +1 -1
  98. data/test/unit/parameter_matchers/kind_of_test.rb +1 -1
  99. data/test/unit/parameter_matchers/not_test.rb +1 -1
  100. data/test/unit/parameter_matchers/regexp_matches_test.rb +22 -1
  101. data/test/unit/parameter_matchers/responds_with_test.rb +1 -1
  102. data/test/unit/parameter_matchers/yaml_equivalent_test.rb +1 -1
  103. data/test/unit/parameters_matcher_test.rb +1 -1
  104. data/test/unit/return_values_test.rb +1 -1
  105. data/test/unit/sequence_test.rb +1 -1
  106. data/test/unit/single_return_value_test.rb +1 -1
  107. data/test/unit/single_yield_test.rb +1 -1
  108. data/test/unit/state_machine_test.rb +1 -1
  109. data/test/unit/string_inspect_test.rb +1 -1
  110. data/test/unit/yield_parameters_test.rb +1 -1
  111. metadata +39 -13
data/README CHANGED
@@ -13,11 +13,13 @@ Mocha was harvested from projects at Reevoo[http://www.reevoo.com] by me (James[
13
13
  Install the gem with the following command...
14
14
 
15
15
  $ gem install mocha
16
-
16
+
17
17
  Or install the Rails[http://www.rubyonrails.org] plugin...
18
18
 
19
19
  $ script/plugin install git://github.com/floehopper/mocha.git
20
20
 
21
+ Note that versions 0.9.6 & 0.9.7 of the Rails plugin were broken. As of version 0.9.8, you need to explicitly load Mocha after the test framework e.g. by adding "require 'mocha'" at the bottom of test/test_helper.rb.
22
+
21
23
  Or download Mocha...
22
24
 
23
25
  http://rubyforge.org/frs/?group_id=1917
data/RELEASE CHANGED
@@ -1,3 +1,10 @@
1
+ = 0.9.8 (645024765b2d92018efc511652e1174163844e39)
2
+ * Fixed bug "NameError raised when using Mocha as a Rails plug-in" - http://floehopper.lighthouseapp.com/projects/22289/tickets/53. Since 0.9.6 the Rails plugin has been broken. See bug report for details. You will need to explicitly load Mocha *after* the test framework has been loaded, e.g. by adding "require 'mocha'" at the bottom of test/test_helper.rb.
3
+ * Make Mocha::ParameterMatchers#regexp_matches, #includes, #has_value, #has_key more robust. Thanks to Sander Hartlage.
4
+ * Allow passing a block to Mocha::Configuration methods to only change configuration for the duration of the block. Thanks to Dan Manges.
5
+ * Fixed bug "doc generation fails in 0.9.7 gem" - http://floehopper.lighthouseapp.com/projects/22289/tickets/51.
6
+ * Remove rdoc template incorporating google analytics from source control. The file just needs to exist locally and be ignored by source control. This should stop the warning showing up on e.g. RunCodeRun build results.
7
+
1
8
  = 0.9.7 (80d816f250dc13aaf856f3f9cbd97ebe9c371839)
2
9
  * Although I had provided a deprecation warning for people using Mocha::Standalone, I had assumed people wouldn't be explicitly loading the mocha/standalone.rb file. It turns out this assumption was incorrect at least in the case of Rspec. This is now fixed.
3
10
 
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
3
3
  require 'rake/testtask'
4
4
 
5
5
  module Mocha
6
- VERSION = "0.9.7"
6
+ VERSION = "0.9.8"
7
7
  end
8
8
 
9
9
  desc "Run all tests"
@@ -42,8 +42,8 @@ namespace 'test' do
42
42
 
43
43
  desc "Run performance tests"
44
44
  task 'performance' do
45
- require 'test/acceptance/stubba_example_test'
46
- require 'test/acceptance/mocha_example_test'
45
+ require File.join(File.dirname(__FILE__), 'test', 'acceptance', 'stubba_example_test')
46
+ require File.join(File.dirname(__FILE__), 'test', 'acceptance', 'mocha_example_test')
47
47
  iterations = 1000
48
48
  puts "\nBenchmarking with #{iterations} iterations..."
49
49
  [MochaExampleTest, StubbaExampleTest].each do |test_case|
@@ -7,36 +7,39 @@ module Mocha # :nodoc:
7
7
 
8
8
  class << self
9
9
 
10
- # :call-seq: allow(action)
10
+ # :call-seq: allow(action, &block)
11
11
  #
12
12
  # Allow the specified <tt>action</tt> (as a symbol).
13
13
  # The <tt>actions</tt> currently available are <tt>:stubbing_method_unnecessarily, :stubbing_method_on_non_mock_object, :stubbing_non_existent_method, :stubbing_non_public_method</tt>.
14
- def allow(action)
15
- configuration[action] = :allow
14
+ # If given a block, the configuration for the action will only be changed for the duration of the block, and will then be restored to the previous value.
15
+ def allow(action, &block)
16
+ change_config action, :allow, &block
16
17
  end
17
18
 
18
19
  def allow?(action) # :nodoc:
19
20
  configuration[action] == :allow
20
21
  end
21
22
 
22
- # :call-seq: warn_when(action)
23
+ # :call-seq: warn_when(action, &block)
23
24
  #
24
25
  # Warn if the specified <tt>action</tt> (as a symbol) is attempted.
25
26
  # The <tt>actions</tt> currently available are <tt>:stubbing_method_unnecessarily, :stubbing_method_on_non_mock_object, :stubbing_non_existent_method, :stubbing_non_public_method</tt>.
26
- def warn_when(action)
27
- configuration[action] = :warn
27
+ # If given a block, the configuration for the action will only be changed for the duration of the block, and will then be restored to the previous value.
28
+ def warn_when(action, &block)
29
+ change_config action, :warn, &block
28
30
  end
29
31
 
30
32
  def warn_when?(action) # :nodoc:
31
33
  configuration[action] == :warn
32
34
  end
33
35
 
34
- # :call-seq: prevent(action)
36
+ # :call-seq: prevent(action, &block)
35
37
  #
36
38
  # Raise a StubbingError if the specified <tt>action</tt> (as a symbol) is attempted.
37
39
  # The <tt>actions</tt> currently available are <tt>:stubbing_method_unnecessarily, :stubbing_method_on_non_mock_object, :stubbing_non_existent_method, :stubbing_non_public_method</tt>.
38
- def prevent(action)
39
- configuration[action] = :prevent
40
+ # If given a block, the configuration for the action will only be changed for the duration of the block, and will then be restored to the previous value.
41
+ def prevent(action, &block)
42
+ change_config action, :prevent, &block
40
43
  end
41
44
 
42
45
  def prevent?(action) # :nodoc:
@@ -52,9 +55,25 @@ module Mocha # :nodoc:
52
55
  def configuration # :nodoc:
53
56
  @configuration ||= DEFAULTS.dup
54
57
  end
58
+
59
+ def change_config(action, new_value, &block) # :nodoc:
60
+ if block_given?
61
+ temporarily_change_config action, new_value, &block
62
+ else
63
+ configuration[action] = new_value
64
+ end
65
+ end
66
+
67
+ def temporarily_change_config(action, new_value, &block) # :nodoc:
68
+ original_value = configuration[action]
69
+ configuration[action] = new_value
70
+ yield
71
+ ensure
72
+ configuration[action] = original_value
73
+ end
55
74
 
56
75
  end
57
76
 
58
77
  end
59
78
 
60
- end
79
+ end
@@ -287,10 +287,14 @@ module Mocha # :nodoc:
287
287
 
288
288
  # :call-seq: raises(exception = RuntimeError, message = nil) -> expectation
289
289
  #
290
- # Modifies expectation so that when the expected method is called, it raises the specified +exception+ with the specified +message+.
290
+ # Modifies expectation so that when the expected method is called, it raises the specified +exception+ with the specified +message+ i.e. calls Kernel#raise(exception, message).
291
291
  # object = mock()
292
292
  # object.expects(:expected_method).raises(Exception, 'message')
293
293
  # object.expected_method # => raises exception of class Exception and with message 'message'
294
+ # Note that if you have a custom exception class with extra constructor parameters, you can pass in an instance of the exception (just as you can for Kernel#raise).
295
+ # object = mock()
296
+ # object.expects(:expected_method).raises(MyException.new('message', 1, 2, 3))
297
+ # object.expected_method # => raises the specified instance of MyException
294
298
  # May be called multiple times on the same expectation. Also see Expectation#then.
295
299
  # object = mock()
296
300
  # object.stubs(:expected_method).raises(Exception1).then.raises(Exception2)
@@ -2,7 +2,11 @@ require 'mocha/api'
2
2
 
3
3
  if !MiniTest::Unit::TestCase.ancestors.include?(Mocha::API)
4
4
 
5
- require 'mocha/integration/mini_test/version_131_and_above'
5
+ require 'mocha/integration/mini_test/exception_translation'
6
+ require 'mocha/integration/mini_test/version_13'
7
+ require 'mocha/integration/mini_test/version_140'
8
+ require 'mocha/integration/mini_test/version_141'
9
+ require 'mocha/integration/mini_test/version_142_and_above'
6
10
 
7
11
  module MiniTest
8
12
  class Unit
@@ -13,7 +17,28 @@ if !MiniTest::Unit::TestCase.ancestors.include?(Mocha::API)
13
17
  alias_method :run_before_mocha, :run
14
18
  remove_method :run
15
19
 
16
- include Mocha::Integration::MiniTest::Version131AndAbove
20
+ mini_test_version = begin
21
+ MiniTest::Unit::VERSION
22
+ rescue LoadError
23
+ 'unknown'
24
+ end
25
+
26
+ warn "Detected MiniTest version: #{mini_test_version}"
27
+
28
+ if (mini_test_version >= '1.3.0') && (mini_test_version <= '1.3.1')
29
+ include Mocha::Integration::MiniTest::Version13
30
+ elsif (mini_test_version == '1.4.0')
31
+ include Mocha::Integration::MiniTest::Version140
32
+ elsif (mini_test_version == '1.4.1')
33
+ include Mocha::Integration::MiniTest::Version141
34
+ elsif (mini_test_version >= '1.4.2') && (mini_test_version <= '1.6.0')
35
+ include Mocha::Integration::MiniTest::Version142AndAbove
36
+ elsif (mini_test_version > '1.6.0')
37
+ warn "*** MiniTest integration has not been verified but patching anyway ***"
38
+ include Mocha::Integration::MiniTest::Version142AndAbove
39
+ else
40
+ warn "*** No Mocha integration for MiniTest version ***"
41
+ end
17
42
 
18
43
  end
19
44
  end
@@ -0,0 +1,20 @@
1
+ require 'mocha/expectation_error'
2
+
3
+ module Mocha
4
+
5
+ module Integration
6
+
7
+ module MiniTest
8
+
9
+ def self.translate(exception)
10
+ return exception unless exception.kind_of?(::Mocha::ExpectationError)
11
+ translated_exception = ::MiniTest::Assertion.new(exception.message)
12
+ translated_exception.set_backtrace(exception.backtrace)
13
+ translated_exception
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,44 @@
1
+ require 'mocha/integration/mini_test/assertion_counter'
2
+
3
+ module Mocha
4
+
5
+ module Integration
6
+
7
+ module MiniTest
8
+
9
+ module Version13
10
+ def self.included(mod)
11
+ warn "Monkey patching MiniTest v1.3"
12
+ end
13
+ def run runner
14
+ assertion_counter = AssertionCounter.new(self)
15
+ result = '.'
16
+ begin
17
+ begin
18
+ @passed = nil
19
+ self.setup
20
+ self.__send__ self.name
21
+ mocha_verify(assertion_counter)
22
+ @passed = true
23
+ rescue Exception => e
24
+ @passed = false
25
+ result = runner.puke(self.class, self.name, Mocha::Integration::MiniTest.translate(e))
26
+ ensure
27
+ begin
28
+ self.teardown
29
+ rescue Exception => e
30
+ result = runner.puke(self.class, self.name, Mocha::Integration::MiniTest.translate(e))
31
+ end
32
+ end
33
+ ensure
34
+ mocha_teardown
35
+ end
36
+ result
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -7,33 +7,28 @@ module Mocha
7
7
 
8
8
  module MiniTest
9
9
 
10
- def self.translate(exception)
11
- return exception unless exception.kind_of?(::Mocha::ExpectationError)
12
- translated_exception = ::MiniTest::Assertion.new(exception.message)
13
- translated_exception.set_backtrace(exception.backtrace)
14
- translated_exception
15
- end
16
-
17
- module Version131AndAbove
10
+ module Version140
11
+ def self.included(mod)
12
+ warn "Monkey patching MiniTest v1.4.0"
13
+ end
18
14
  def run runner
19
15
  assertion_counter = AssertionCounter.new(self)
20
16
  result = '.'
21
- name = (self.respond_to?(:name) ? self.name : self.__name__)
22
17
  begin
23
18
  begin
24
19
  @passed = nil
25
20
  self.setup
26
- self.__send__ name
21
+ self.__send__ self.__name__
27
22
  mocha_verify(assertion_counter)
28
23
  @passed = true
29
24
  rescue Exception => e
30
25
  @passed = false
31
- result = runner.puke(self.class, name, Mocha::Integration::MiniTest.translate(e))
26
+ result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
32
27
  ensure
33
28
  begin
34
29
  self.teardown
35
30
  rescue Exception => e
36
- result = runner.puke(self.class, name, Mocha::Integration::MiniTest.translate(e))
31
+ result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
37
32
  end
38
33
  end
39
34
  ensure
@@ -0,0 +1,56 @@
1
+ require 'mocha/integration/mini_test/assertion_counter'
2
+ require 'mocha/expectation_error'
3
+
4
+ module Mocha
5
+
6
+ module Integration
7
+
8
+ module MiniTest
9
+
10
+ module Version141
11
+ def self.included(mod)
12
+ warn "Monkey patching MiniTest v1.4.1"
13
+ end
14
+ def run runner
15
+ trap 'INFO' do
16
+ warn '%s#%s %.2fs' % [self.class, self.__name__,
17
+ (Time.now - runner.start_time)]
18
+ runner.status $stderr
19
+ end
20
+
21
+ assertion_counter = AssertionCounter.new(self)
22
+ result = '.'
23
+ begin
24
+ begin
25
+ @passed = nil
26
+ self.setup
27
+ self.__send__ self.__name__
28
+ mocha_verify(assertion_counter)
29
+ @passed = true
30
+ rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
31
+ raise
32
+ rescue Exception => e
33
+ @passed = false
34
+ result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
35
+ ensure
36
+ begin
37
+ self.teardown
38
+ rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
39
+ raise
40
+ rescue Exception => e
41
+ result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
42
+ end
43
+ trap 'INFO', 'DEFAULT'
44
+ end
45
+ ensure
46
+ mocha_teardown
47
+ end
48
+ result
49
+ end
50
+ end
51
+
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,56 @@
1
+ require 'mocha/integration/mini_test/assertion_counter'
2
+ require 'mocha/expectation_error'
3
+
4
+ module Mocha
5
+
6
+ module Integration
7
+
8
+ module MiniTest
9
+
10
+ module Version142AndAbove
11
+ def self.included(mod)
12
+ warn "Monkey patching MiniTest >= v1.4.2"
13
+ end
14
+ def run runner
15
+ trap 'INFO' do
16
+ warn '%s#%s %.2fs' % [self.class, self.__name__,
17
+ (Time.now - runner.start_time)]
18
+ runner.status $stderr
19
+ end if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
20
+
21
+ assertion_counter = AssertionCounter.new(self)
22
+ result = '.'
23
+ begin
24
+ begin
25
+ @passed = nil
26
+ self.setup
27
+ self.__send__ self.__name__
28
+ mocha_verify(assertion_counter)
29
+ @passed = true
30
+ rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
31
+ raise
32
+ rescue Exception => e
33
+ @passed = false
34
+ result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
35
+ ensure
36
+ begin
37
+ self.teardown
38
+ rescue *PASSTHROUGH_EXCEPTIONS
39
+ raise
40
+ rescue Exception => e
41
+ result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
42
+ end
43
+ trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
44
+ end
45
+ ensure
46
+ mocha_teardown
47
+ end
48
+ result
49
+ end
50
+ end
51
+
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -3,7 +3,8 @@ require 'mocha/api'
3
3
  if !Test::Unit::TestCase.ancestors.include?(Mocha::API)
4
4
 
5
5
  require 'mocha/integration/test_unit/gem_version_200'
6
- require 'mocha/integration/test_unit/gem_version_201_and_above'
6
+ require 'mocha/integration/test_unit/gem_version_201_to_202'
7
+ require 'mocha/integration/test_unit/gem_version_203_to_207'
7
8
  require 'mocha/integration/test_unit/ruby_version_185_and_below'
8
9
  require 'mocha/integration/test_unit/ruby_version_186_and_above'
9
10
 
@@ -23,14 +24,26 @@ if !Test::Unit::TestCase.ancestors.include?(Mocha::API)
23
24
  '1.x'
24
25
  end
25
26
 
26
- if test_unit_version == '2.0.0'
27
+ warn "Detected Ruby version: #{RUBY_VERSION}"
28
+ warn "Detected Test::Unit version: #{test_unit_version}"
29
+
30
+ if (test_unit_version == '1.x') || (test_unit_version == '1.2.3')
31
+ if RUBY_VERSION < '1.8.6'
32
+ include Mocha::Integration::TestUnit::RubyVersion185AndBelow
33
+ else
34
+ include Mocha::Integration::TestUnit::RubyVersion186AndAbove
35
+ end
36
+ elsif (test_unit_version == '2.0.0')
27
37
  include Mocha::Integration::TestUnit::GemVersion200
28
- elsif test_unit_version >= '2.0.1'
29
- include Mocha::Integration::TestUnit::GemVersion201AndAbove
30
- elsif RUBY_VERSION < '1.8.6'
31
- include Mocha::Integration::TestUnit::RubyVersion185AndBelow
38
+ elsif (test_unit_version >= '2.0.1') && (test_unit_version <= '2.0.2')
39
+ include Mocha::Integration::TestUnit::GemVersion201To202
40
+ elsif (test_unit_version >= '2.0.3') && (test_unit_version <= '2.0.7')
41
+ include Mocha::Integration::TestUnit::GemVersion203To207
42
+ elsif (test_unit_version > '2.0.7')
43
+ warn "*** Test::Unit integration has not been verified but patching anyway ***"
44
+ include Mocha::Integration::TestUnit::GemVersion203To207
32
45
  else
33
- include Mocha::Integration::TestUnit::RubyVersion186AndAbove
46
+ warn "*** No Mocha integration for Test::Unit version ***"
34
47
  end
35
48
 
36
49
  end