mocha 0.12.8 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +22 -0
- data/COPYING.md +3 -0
- data/README.md +230 -0
- data/{RELEASE.rdoc → RELEASE.md} +61 -50
- data/Rakefile +45 -37
- data/build-matrix.rb +16 -4
- data/lib/mocha/api.rb +13 -16
- data/lib/mocha/class_method.rb +7 -3
- data/lib/mocha/class_methods.rb +63 -0
- data/lib/mocha/debug.rb +11 -0
- data/lib/mocha/deprecation.rb +1 -1
- data/lib/mocha/exception_raiser.rb +1 -1
- data/lib/mocha/expectation_error.rb +5 -0
- data/lib/mocha/expectation_error_factory.rb +19 -0
- data/lib/mocha/hooks.rb +43 -0
- data/lib/mocha/integration/assertion_counter.rb +13 -0
- data/lib/mocha/integration/mini_test/adapter.rb +54 -0
- data/lib/mocha/integration/mini_test/exception_translation.rb +0 -6
- data/lib/mocha/integration/mini_test/nothing.rb +19 -0
- data/lib/mocha/integration/mini_test/version_13.rb +32 -25
- data/lib/mocha/integration/mini_test/version_140.rb +32 -26
- data/lib/mocha/integration/mini_test/version_141.rb +40 -34
- data/lib/mocha/integration/mini_test/version_142_to_172.rb +40 -34
- data/lib/mocha/integration/mini_test/version_200.rb +41 -35
- data/lib/mocha/integration/mini_test/version_201_to_222.rb +41 -35
- data/lib/mocha/integration/mini_test/version_2110_to_2111.rb +49 -43
- data/lib/mocha/integration/mini_test/version_2112_to_320.rb +53 -47
- data/lib/mocha/integration/mini_test/version_230_to_2101.rb +43 -37
- data/lib/mocha/integration/mini_test.rb +42 -57
- data/lib/mocha/integration/monkey_patcher.rb +18 -0
- data/lib/mocha/integration/test_unit/adapter.rb +51 -0
- data/lib/mocha/integration/test_unit/gem_version_200.rb +36 -29
- data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +36 -29
- data/lib/mocha/integration/test_unit/gem_version_203_to_220.rb +36 -29
- data/lib/mocha/integration/test_unit/gem_version_230_to_250.rb +65 -0
- data/lib/mocha/integration/test_unit/nothing.rb +19 -0
- data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +36 -29
- data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +37 -30
- data/lib/mocha/integration/test_unit.rb +38 -45
- data/lib/mocha/integration.rb +6 -38
- data/lib/mocha/method_matcher.rb +1 -1
- data/lib/mocha/module_methods.rb +14 -0
- data/lib/mocha/{object.rb → object_methods.rb} +0 -83
- data/lib/mocha/setup.rb +10 -0
- data/lib/mocha/standalone.rb +3 -0
- data/lib/mocha/version.rb +1 -1
- data/lib/mocha.rb +6 -2
- data/lib/mocha_standalone.rb +3 -1
- data/mocha.gemspec +16 -9
- data/test/acceptance/bug_18914_test.rb +1 -1
- data/test/acceptance/bug_21465_test.rb +1 -1
- data/test/acceptance/bug_21563_test.rb +1 -1
- data/test/acceptance/exception_rescue_test.rb +1 -1
- data/test/acceptance/expectations_on_multiple_methods_test.rb +1 -1
- data/test/acceptance/expected_invocation_count_test.rb +1 -1
- data/test/acceptance/failure_messages_test.rb +1 -1
- data/test/acceptance/issue_65_test.rb +1 -1
- data/test/acceptance/issue_70_test.rb +1 -1
- data/test/acceptance/mocha_example_test.rb +1 -1
- data/test/acceptance/mocha_test_result_test.rb +1 -1
- data/test/acceptance/mock_test.rb +1 -1
- data/test/acceptance/mock_with_initializer_block_test.rb +1 -1
- data/test/acceptance/mocked_methods_dispatch_test.rb +1 -1
- data/test/acceptance/multiple_expectations_failure_message_test.rb +1 -1
- data/test/acceptance/optional_parameters_test.rb +1 -1
- data/test/acceptance/parameter_matcher_test.rb +1 -1
- data/test/acceptance/partial_mocks_test.rb +1 -1
- data/test/acceptance/raise_exception_test.rb +1 -1
- data/test/acceptance/return_value_test.rb +1 -1
- data/test/acceptance/sequence_test.rb +1 -1
- data/test/acceptance/states_test.rb +1 -1
- data/test/acceptance/stub_any_instance_method_test.rb +1 -1
- data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +1 -1
- data/test/acceptance/stub_class_method_defined_on_class_test.rb +1 -1
- data/test/acceptance/stub_class_method_defined_on_module_test.rb +1 -1
- data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +1 -1
- data/test/acceptance/stub_everything_test.rb +1 -1
- data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +1 -1
- data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +1 -1
- data/test/acceptance/stub_instance_method_defined_on_class_test.rb +1 -1
- data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +1 -1
- data/test/acceptance/stub_instance_method_defined_on_module_test.rb +1 -1
- data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +1 -1
- data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +1 -1
- data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +1 -1
- data/test/acceptance/stub_module_method_test.rb +1 -1
- data/test/acceptance/stub_test.rb +1 -1
- data/test/acceptance/stubba_example_test.rb +1 -1
- data/test/acceptance/stubba_test_result_test.rb +1 -1
- data/test/acceptance/stubbing_error_backtrace_test.rb +1 -1
- data/test/acceptance/stubbing_frozen_object_test.rb +1 -1
- data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +1 -1
- data/test/acceptance/stubbing_method_unnecessarily_test.rb +1 -1
- data/test/acceptance/stubbing_nil_test.rb +1 -1
- data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +1 -1
- data/test/acceptance/stubbing_non_existent_class_method_test.rb +1 -1
- data/test/acceptance/stubbing_non_existent_instance_method_test.rb +1 -1
- data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +1 -1
- data/test/acceptance/stubbing_non_public_class_method_test.rb +1 -1
- data/test/acceptance/stubbing_non_public_instance_method_test.rb +1 -1
- data/test/acceptance/stubbing_on_non_mock_object_test.rb +1 -1
- data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +3 -3
- data/test/acceptance/throw_test.rb +1 -1
- data/test/acceptance/unstubbing_test.rb +1 -1
- data/test/integration/mini_test_test.rb +9 -0
- data/test/integration/shared_tests.rb +174 -0
- data/test/integration/test_unit_test.rb +9 -0
- data/test/mini_test_result.rb +0 -1
- data/test/test_runner.rb +14 -14
- data/test/unit/class_methods_test.rb +40 -0
- data/test/unit/method_matcher_test.rb +5 -0
- data/test/unit/mock_test.rb +6 -0
- data/test/unit/module_methods_test.rb +19 -0
- data/test/unit/object_methods_test.rb +45 -0
- metadata +44 -72
- data/COPYING.rdoc +0 -3
- data/README.rdoc +0 -56
- data/examples/misc.rb +0 -43
- data/examples/mocha.rb +0 -25
- data/examples/stubba.rb +0 -64
- data/gemfiles/Gemfile.minitest.3.3.0 +0 -7
- data/gemfiles/Gemfile.minitest.4.2.0 +0 -7
- data/lib/mocha/integration/mini_test/assertion_counter.rb +0 -23
- data/lib/mocha/integration/mini_test/version_330_to_410.rb +0 -65
- data/lib/mocha/integration/mini_test/version_420_to_433.rb +0 -70
- data/lib/mocha/integration/mini_test/version_440.rb +0 -70
- data/lib/mocha/integration/test_unit/assertion_counter.rb +0 -23
- data/lib/mocha/integration/test_unit/gem_version_230_to_253.rb +0 -58
- data/lib/mocha/options.rb +0 -1
- data/test/acceptance/api_test.rb +0 -139
- data/test/acceptance/minitest_test.rb +0 -162
- data/test/unit/object_test.rb +0 -92
- /data/{MIT-LICENSE.rdoc → MIT-LICENSE.md} +0 -0
|
@@ -1,59 +1,65 @@
|
|
|
1
|
-
require 'mocha/integration/
|
|
2
|
-
require 'mocha/
|
|
1
|
+
require 'mocha/integration/assertion_counter'
|
|
2
|
+
require 'mocha/integration/monkey_patcher'
|
|
3
|
+
require 'mocha/integration/mini_test/exception_translation'
|
|
3
4
|
|
|
4
5
|
module Mocha
|
|
5
|
-
|
|
6
6
|
module Integration
|
|
7
|
-
|
|
8
7
|
module MiniTest
|
|
9
|
-
|
|
10
8
|
module Version230To2101
|
|
9
|
+
def self.applicable_to?(mini_test_version)
|
|
10
|
+
Gem::Requirement.new('>= 2.3.0', '<= 2.10.1').satisfied_by?(mini_test_version)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.description
|
|
14
|
+
"monkey patch for MiniTest gem >= v2.3.0 <= v2.10.1"
|
|
15
|
+
end
|
|
16
|
+
|
|
11
17
|
def self.included(mod)
|
|
12
|
-
|
|
18
|
+
MonkeyPatcher.apply(mod, RunMethodPatch)
|
|
13
19
|
end
|
|
14
|
-
def run runner
|
|
15
|
-
trap 'INFO' do
|
|
16
|
-
time = runner.start_time ? Time.now - runner.start_time : 0
|
|
17
|
-
warn "%s#%s %.2fs" % [self.class, self.__name__, time]
|
|
18
|
-
runner.status $stderr
|
|
19
|
-
end if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
module RunMethodPatch
|
|
22
|
+
def run runner
|
|
23
|
+
trap 'INFO' do
|
|
24
|
+
time = runner.start_time ? Time.now - runner.start_time : 0
|
|
25
|
+
warn "%s#%s %.2fs" % [self.class, self.__name__, time]
|
|
26
|
+
runner.status $stderr
|
|
27
|
+
end if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
|
28
|
+
|
|
29
|
+
assertion_counter = AssertionCounter.new(self)
|
|
30
|
+
result = ""
|
|
24
31
|
begin
|
|
25
|
-
@passed = nil
|
|
26
|
-
self.setup
|
|
27
|
-
self.run_setup_hooks
|
|
28
|
-
self.__send__ self.__name__
|
|
29
|
-
mocha_verify(assertion_counter)
|
|
30
|
-
result = "." unless io?
|
|
31
|
-
@passed = true
|
|
32
|
-
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
|
33
|
-
raise
|
|
34
|
-
rescue Exception => e
|
|
35
|
-
@passed = false
|
|
36
|
-
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
|
37
|
-
ensure
|
|
38
32
|
begin
|
|
39
|
-
|
|
40
|
-
self.
|
|
33
|
+
@passed = nil
|
|
34
|
+
self.setup
|
|
35
|
+
self.run_setup_hooks
|
|
36
|
+
self.__send__ self.__name__
|
|
37
|
+
mocha_verify(assertion_counter)
|
|
38
|
+
result = "." unless io?
|
|
39
|
+
@passed = true
|
|
41
40
|
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
|
42
41
|
raise
|
|
43
42
|
rescue Exception => e
|
|
43
|
+
@passed = false
|
|
44
44
|
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
|
45
|
+
ensure
|
|
46
|
+
begin
|
|
47
|
+
self.run_teardown_hooks
|
|
48
|
+
self.teardown
|
|
49
|
+
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
|
50
|
+
raise
|
|
51
|
+
rescue Exception => e
|
|
52
|
+
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
|
53
|
+
end
|
|
54
|
+
trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
|
45
55
|
end
|
|
46
|
-
|
|
56
|
+
ensure
|
|
57
|
+
mocha_teardown
|
|
47
58
|
end
|
|
48
|
-
|
|
49
|
-
mocha_teardown
|
|
59
|
+
result
|
|
50
60
|
end
|
|
51
|
-
result
|
|
52
61
|
end
|
|
53
62
|
end
|
|
54
|
-
|
|
55
63
|
end
|
|
56
|
-
|
|
57
64
|
end
|
|
58
|
-
|
|
59
65
|
end
|
|
@@ -1,68 +1,53 @@
|
|
|
1
|
-
require 'mocha/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
module MiniTest
|
|
21
|
-
class Unit
|
|
22
|
-
class TestCase
|
|
23
|
-
|
|
24
|
-
include Mocha::API
|
|
25
|
-
|
|
26
|
-
alias_method :run_before_mocha, :run
|
|
27
|
-
remove_method :run
|
|
1
|
+
require 'mocha/debug'
|
|
2
|
+
|
|
3
|
+
require 'mocha/integration/mini_test/nothing'
|
|
4
|
+
require 'mocha/integration/mini_test/version_13'
|
|
5
|
+
require 'mocha/integration/mini_test/version_140'
|
|
6
|
+
require 'mocha/integration/mini_test/version_141'
|
|
7
|
+
require 'mocha/integration/mini_test/version_142_to_172'
|
|
8
|
+
require 'mocha/integration/mini_test/version_200'
|
|
9
|
+
require 'mocha/integration/mini_test/version_201_to_222'
|
|
10
|
+
require 'mocha/integration/mini_test/version_230_to_2101'
|
|
11
|
+
require 'mocha/integration/mini_test/version_2110_to_2111'
|
|
12
|
+
require 'mocha/integration/mini_test/version_2112_to_320'
|
|
13
|
+
require 'mocha/integration/mini_test/adapter'
|
|
14
|
+
|
|
15
|
+
module Mocha
|
|
16
|
+
module Integration
|
|
17
|
+
module MiniTest
|
|
18
|
+
def self.activate
|
|
19
|
+
return false unless defined?(::MiniTest::Unit::TestCase)
|
|
28
20
|
|
|
29
21
|
mini_test_version = begin
|
|
30
|
-
Gem::Version.new(MiniTest::Unit::VERSION)
|
|
22
|
+
Gem::Version.new(::MiniTest::Unit::VERSION)
|
|
31
23
|
rescue LoadError
|
|
32
24
|
Gem::Version.new('0.0.0')
|
|
33
25
|
end
|
|
34
26
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
include Mocha::Integration::MiniTest::Version2112To320
|
|
55
|
-
elsif Gem::Requirement.new('>= 3.3.0', '<= 4.1.0').satisfied_by?(mini_test_version)
|
|
56
|
-
include Mocha::Integration::MiniTest::Version330To410
|
|
57
|
-
elsif Gem::Requirement.new('>= 4.2.0', '<= 4.3.3').satisfied_by?(mini_test_version)
|
|
58
|
-
include Mocha::Integration::MiniTest::Version420To433
|
|
59
|
-
elsif Gem::Requirement.new('>= 4.4.0', '<= 4.4.0').satisfied_by?(mini_test_version)
|
|
60
|
-
include Mocha::Integration::MiniTest::Version440
|
|
61
|
-
else
|
|
62
|
-
raise "No Mocha monkey-patch for MiniTest version"
|
|
27
|
+
Debug.puts "Detected MiniTest version: #{mini_test_version}"
|
|
28
|
+
|
|
29
|
+
integration_module = [
|
|
30
|
+
MiniTest::Adapter,
|
|
31
|
+
MiniTest::Version2112To320,
|
|
32
|
+
MiniTest::Version2110To2111,
|
|
33
|
+
MiniTest::Version230To2101,
|
|
34
|
+
MiniTest::Version201To222,
|
|
35
|
+
MiniTest::Version200,
|
|
36
|
+
MiniTest::Version142To172,
|
|
37
|
+
MiniTest::Version141,
|
|
38
|
+
MiniTest::Version140,
|
|
39
|
+
MiniTest::Version13,
|
|
40
|
+
MiniTest::Nothing
|
|
41
|
+
].detect { |m| m.applicable_to?(mini_test_version) }
|
|
42
|
+
|
|
43
|
+
unless ::MiniTest::Unit::TestCase < integration_module
|
|
44
|
+
Debug.puts "Applying #{integration_module.description}"
|
|
45
|
+
::MiniTest::Unit::TestCase.send(:include, integration_module)
|
|
63
46
|
end
|
|
64
|
-
|
|
65
47
|
end
|
|
48
|
+
true
|
|
66
49
|
end
|
|
67
50
|
end
|
|
68
51
|
end
|
|
52
|
+
|
|
53
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'mocha/api'
|
|
2
|
+
|
|
3
|
+
module Mocha
|
|
4
|
+
module Integration
|
|
5
|
+
module MonkeyPatcher
|
|
6
|
+
def self.apply(mod, run_method_patch)
|
|
7
|
+
unless mod < Mocha::API
|
|
8
|
+
mod.send(:include, Mocha::API)
|
|
9
|
+
end
|
|
10
|
+
unless mod.method_defined?(:run_before_mocha)
|
|
11
|
+
mod.send(:alias_method, :run_before_mocha, :run)
|
|
12
|
+
mod.send(:remove_method, :run)
|
|
13
|
+
mod.send(:include, run_method_patch)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'mocha/api'
|
|
2
|
+
require 'mocha/integration/assertion_counter'
|
|
3
|
+
require 'mocha/expectation_error'
|
|
4
|
+
|
|
5
|
+
module Mocha
|
|
6
|
+
module Integration
|
|
7
|
+
module TestUnit
|
|
8
|
+
|
|
9
|
+
# Integrates Mocha into recent versions of Test::Unit.
|
|
10
|
+
#
|
|
11
|
+
# See the source code for an example of how to integrate Mocha into a test library.
|
|
12
|
+
module Adapter
|
|
13
|
+
include Mocha::API
|
|
14
|
+
|
|
15
|
+
# @private
|
|
16
|
+
def self.applicable_to?(test_unit_version, ruby_version = nil)
|
|
17
|
+
Gem::Requirement.new('>= 2.5.1').satisfied_by?(test_unit_version)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @private
|
|
21
|
+
def self.description
|
|
22
|
+
"adapter for Test::Unit gem >= v2.5.1"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @private
|
|
26
|
+
def self.included(mod)
|
|
27
|
+
mod.setup :mocha_setup, :before => :prepend
|
|
28
|
+
|
|
29
|
+
mod.exception_handler(:handle_mocha_expectation_error)
|
|
30
|
+
|
|
31
|
+
mod.cleanup :after => :append do
|
|
32
|
+
assertion_counter = Integration::AssertionCounter.new(self)
|
|
33
|
+
mocha_verify(assertion_counter)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
mod.teardown :mocha_teardown, :after => :append
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
# @private
|
|
42
|
+
def handle_mocha_expectation_error(e)
|
|
43
|
+
return false unless e.is_a?(Mocha::ExpectationError)
|
|
44
|
+
problem_occurred
|
|
45
|
+
add_failure(e.message, e.backtrace)
|
|
46
|
+
true
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -1,52 +1,59 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require 'mocha/integration/
|
|
1
|
+
require 'mocha/integration/assertion_counter'
|
|
2
|
+
require 'mocha/integration/monkey_patcher'
|
|
3
3
|
require 'mocha/expectation_error'
|
|
4
4
|
|
|
5
5
|
module Mocha
|
|
6
|
-
|
|
7
6
|
module Integration
|
|
8
|
-
|
|
9
7
|
module TestUnit
|
|
10
|
-
|
|
11
8
|
module GemVersion200
|
|
9
|
+
def self.applicable_to?(test_unit_version, ruby_version = nil)
|
|
10
|
+
Gem::Requirement.new('2.0.0').satisfied_by?(test_unit_version)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.description
|
|
14
|
+
"monkey patch for Test::Unit gem v2.0.0"
|
|
15
|
+
end
|
|
16
|
+
|
|
12
17
|
def self.included(mod)
|
|
13
|
-
|
|
18
|
+
MonkeyPatcher.apply(mod, RunMethodPatch)
|
|
14
19
|
end
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
yield(Test::Unit::TestCase::STARTED, name)
|
|
20
|
+
|
|
21
|
+
module RunMethodPatch
|
|
22
|
+
def run(result)
|
|
23
|
+
assertion_counter = AssertionCounter.new(self)
|
|
20
24
|
begin
|
|
25
|
+
@_result = result
|
|
26
|
+
yield(Test::Unit::TestCase::STARTED, name)
|
|
21
27
|
begin
|
|
22
|
-
run_setup
|
|
23
|
-
__send__(@method_name)
|
|
24
|
-
mocha_verify(assertion_counter)
|
|
25
|
-
rescue Mocha::ExpectationError => e
|
|
26
|
-
add_failure(e.message, e.backtrace)
|
|
27
|
-
rescue Exception
|
|
28
|
-
@interrupted = true
|
|
29
|
-
raise unless handle_exception($!)
|
|
30
|
-
ensure
|
|
31
28
|
begin
|
|
32
|
-
|
|
29
|
+
run_setup
|
|
30
|
+
__send__(@method_name)
|
|
31
|
+
mocha_verify(assertion_counter)
|
|
32
|
+
rescue Mocha::ExpectationError => e
|
|
33
|
+
add_failure(e.message, e.backtrace)
|
|
33
34
|
rescue Exception
|
|
35
|
+
@interrupted = true
|
|
34
36
|
raise unless handle_exception($!)
|
|
37
|
+
ensure
|
|
38
|
+
begin
|
|
39
|
+
run_teardown
|
|
40
|
+
rescue Mocha::ExpectationError => e
|
|
41
|
+
add_failure(e.message, e.backtrace)
|
|
42
|
+
rescue Exception
|
|
43
|
+
raise unless handle_exception($!)
|
|
44
|
+
end
|
|
35
45
|
end
|
|
46
|
+
ensure
|
|
47
|
+
mocha_teardown
|
|
36
48
|
end
|
|
49
|
+
result.add_run
|
|
50
|
+
yield(Test::Unit::TestCase::FINISHED, name)
|
|
37
51
|
ensure
|
|
38
|
-
|
|
52
|
+
@_result = nil
|
|
39
53
|
end
|
|
40
|
-
result.add_run
|
|
41
|
-
yield(Test::Unit::TestCase::FINISHED, name)
|
|
42
|
-
ensure
|
|
43
|
-
@_result = nil
|
|
44
54
|
end
|
|
45
55
|
end
|
|
46
56
|
end
|
|
47
|
-
|
|
48
57
|
end
|
|
49
|
-
|
|
50
58
|
end
|
|
51
|
-
|
|
52
59
|
end
|
|
@@ -1,52 +1,59 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require 'mocha/integration/
|
|
1
|
+
require 'mocha/integration/assertion_counter'
|
|
2
|
+
require 'mocha/integration/monkey_patcher'
|
|
3
3
|
require 'mocha/expectation_error'
|
|
4
4
|
|
|
5
5
|
module Mocha
|
|
6
|
-
|
|
7
6
|
module Integration
|
|
8
|
-
|
|
9
7
|
module TestUnit
|
|
10
|
-
|
|
11
8
|
module GemVersion201To202
|
|
9
|
+
def self.applicable_to?(test_unit_version, ruby_version = nil)
|
|
10
|
+
Gem::Requirement.new('>= 2.0.1', '<= 2.0.2').satisfied_by?(test_unit_version)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.description
|
|
14
|
+
"monkey patch for Test::Unit gem >= v2.0.1 and <= v2.0.2"
|
|
15
|
+
end
|
|
16
|
+
|
|
12
17
|
def self.included(mod)
|
|
13
|
-
|
|
18
|
+
MonkeyPatcher.apply(mod, RunMethodPatch)
|
|
14
19
|
end
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
yield(Test::Unit::TestCase::STARTED, name)
|
|
20
|
+
|
|
21
|
+
module RunMethodPatch
|
|
22
|
+
def run(result)
|
|
23
|
+
assertion_counter = AssertionCounter.new(self)
|
|
20
24
|
begin
|
|
25
|
+
@_result = result
|
|
26
|
+
yield(Test::Unit::TestCase::STARTED, name)
|
|
21
27
|
begin
|
|
22
|
-
run_setup
|
|
23
|
-
run_test
|
|
24
|
-
mocha_verify(assertion_counter)
|
|
25
|
-
rescue Mocha::ExpectationError => e
|
|
26
|
-
add_failure(e.message, e.backtrace)
|
|
27
|
-
rescue Exception
|
|
28
|
-
@interrupted = true
|
|
29
|
-
raise unless handle_exception($!)
|
|
30
|
-
ensure
|
|
31
28
|
begin
|
|
32
|
-
|
|
29
|
+
run_setup
|
|
30
|
+
run_test
|
|
31
|
+
mocha_verify(assertion_counter)
|
|
32
|
+
rescue Mocha::ExpectationError => e
|
|
33
|
+
add_failure(e.message, e.backtrace)
|
|
33
34
|
rescue Exception
|
|
35
|
+
@interrupted = true
|
|
34
36
|
raise unless handle_exception($!)
|
|
37
|
+
ensure
|
|
38
|
+
begin
|
|
39
|
+
run_teardown
|
|
40
|
+
rescue Mocha::ExpectationError => e
|
|
41
|
+
add_failure(e.message, e.backtrace)
|
|
42
|
+
rescue Exception
|
|
43
|
+
raise unless handle_exception($!)
|
|
44
|
+
end
|
|
35
45
|
end
|
|
46
|
+
ensure
|
|
47
|
+
mocha_teardown
|
|
36
48
|
end
|
|
49
|
+
result.add_run
|
|
50
|
+
yield(Test::Unit::TestCase::FINISHED, name)
|
|
37
51
|
ensure
|
|
38
|
-
|
|
52
|
+
@_result = nil
|
|
39
53
|
end
|
|
40
|
-
result.add_run
|
|
41
|
-
yield(Test::Unit::TestCase::FINISHED, name)
|
|
42
|
-
ensure
|
|
43
|
-
@_result = nil
|
|
44
54
|
end
|
|
45
55
|
end
|
|
46
56
|
end
|
|
47
|
-
|
|
48
57
|
end
|
|
49
|
-
|
|
50
58
|
end
|
|
51
|
-
|
|
52
59
|
end
|
|
@@ -1,52 +1,59 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require 'mocha/integration/
|
|
1
|
+
require 'mocha/integration/assertion_counter'
|
|
2
|
+
require 'mocha/integration/monkey_patcher'
|
|
3
3
|
require 'mocha/expectation_error'
|
|
4
4
|
|
|
5
5
|
module Mocha
|
|
6
|
-
|
|
7
6
|
module Integration
|
|
8
|
-
|
|
9
7
|
module TestUnit
|
|
10
|
-
|
|
11
8
|
module GemVersion203To220
|
|
9
|
+
def self.applicable_to?(test_unit_version, ruby_version = nil)
|
|
10
|
+
Gem::Requirement.new('>= 2.0.3', '<= 2.2.0').satisfied_by?(test_unit_version)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.description
|
|
14
|
+
"monkey patch for Test::Unit gem >= v2.0.3 and <= v2.2.0"
|
|
15
|
+
end
|
|
16
|
+
|
|
12
17
|
def self.included(mod)
|
|
13
|
-
|
|
18
|
+
MonkeyPatcher.apply(mod, RunMethodPatch)
|
|
14
19
|
end
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
yield(Test::Unit::TestCase::STARTED, name)
|
|
20
|
+
|
|
21
|
+
module RunMethodPatch
|
|
22
|
+
def run(result)
|
|
23
|
+
assertion_counter = AssertionCounter.new(self)
|
|
20
24
|
begin
|
|
25
|
+
@_result = result
|
|
26
|
+
yield(Test::Unit::TestCase::STARTED, name)
|
|
21
27
|
begin
|
|
22
|
-
run_setup
|
|
23
|
-
run_test
|
|
24
|
-
mocha_verify(assertion_counter)
|
|
25
|
-
rescue Mocha::ExpectationError => e
|
|
26
|
-
add_failure(e.message, e.backtrace)
|
|
27
|
-
rescue Exception
|
|
28
|
-
@interrupted = true
|
|
29
|
-
raise unless handle_exception($!)
|
|
30
|
-
ensure
|
|
31
28
|
begin
|
|
32
|
-
|
|
29
|
+
run_setup
|
|
30
|
+
run_test
|
|
31
|
+
mocha_verify(assertion_counter)
|
|
32
|
+
rescue Mocha::ExpectationError => e
|
|
33
|
+
add_failure(e.message, e.backtrace)
|
|
33
34
|
rescue Exception
|
|
35
|
+
@interrupted = true
|
|
34
36
|
raise unless handle_exception($!)
|
|
37
|
+
ensure
|
|
38
|
+
begin
|
|
39
|
+
run_teardown
|
|
40
|
+
rescue Mocha::ExpectationError => e
|
|
41
|
+
add_failure(e.message, e.backtrace)
|
|
42
|
+
rescue Exception
|
|
43
|
+
raise unless handle_exception($!)
|
|
44
|
+
end
|
|
35
45
|
end
|
|
46
|
+
ensure
|
|
47
|
+
mocha_teardown
|
|
36
48
|
end
|
|
49
|
+
result.add_run
|
|
50
|
+
yield(Test::Unit::TestCase::FINISHED, name)
|
|
37
51
|
ensure
|
|
38
|
-
|
|
52
|
+
# @_result = nil # For test-spec's after_all :<
|
|
39
53
|
end
|
|
40
|
-
result.add_run
|
|
41
|
-
yield(Test::Unit::TestCase::FINISHED, name)
|
|
42
|
-
ensure
|
|
43
|
-
# @_result = nil # For test-spec's after_all :<
|
|
44
54
|
end
|
|
45
55
|
end
|
|
46
56
|
end
|
|
47
|
-
|
|
48
57
|
end
|
|
49
|
-
|
|
50
58
|
end
|
|
51
|
-
|
|
52
59
|
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require 'mocha/integration/assertion_counter'
|
|
2
|
+
require 'mocha/integration/monkey_patcher'
|
|
3
|
+
require 'mocha/expectation_error'
|
|
4
|
+
|
|
5
|
+
module Mocha
|
|
6
|
+
module Integration
|
|
7
|
+
module TestUnit
|
|
8
|
+
module GemVersion230To250
|
|
9
|
+
def self.applicable_to?(test_unit_version, ruby_version = nil)
|
|
10
|
+
Gem::Requirement.new('>= 2.3.0', '<= 2.5.0').satisfied_by?(test_unit_version)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.description
|
|
14
|
+
"monkey patch for Test::Unit gem >= v2.3.0 and <= v2.5.0"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.included(mod)
|
|
18
|
+
MonkeyPatcher.apply(mod, RunMethodPatch)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
module RunMethodPatch
|
|
22
|
+
def run(result)
|
|
23
|
+
assertion_counter = AssertionCounter.new(self)
|
|
24
|
+
begin
|
|
25
|
+
@internal_data.test_started
|
|
26
|
+
@_result = result
|
|
27
|
+
yield(Test::Unit::TestCase::STARTED, name)
|
|
28
|
+
yield(Test::Unit::TestCase::STARTED_OBJECT, self)
|
|
29
|
+
begin
|
|
30
|
+
begin
|
|
31
|
+
run_setup
|
|
32
|
+
run_test
|
|
33
|
+
run_cleanup
|
|
34
|
+
mocha_verify(assertion_counter)
|
|
35
|
+
add_pass
|
|
36
|
+
rescue Mocha::ExpectationError => e
|
|
37
|
+
add_failure(e.message, e.backtrace)
|
|
38
|
+
rescue Exception
|
|
39
|
+
@internal_data.interrupted
|
|
40
|
+
raise unless handle_exception($!)
|
|
41
|
+
ensure
|
|
42
|
+
begin
|
|
43
|
+
run_teardown
|
|
44
|
+
rescue Mocha::ExpectationError => e
|
|
45
|
+
add_failure(e.message, e.backtrace)
|
|
46
|
+
rescue Exception
|
|
47
|
+
raise unless handle_exception($!)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
ensure
|
|
51
|
+
mocha_teardown
|
|
52
|
+
end
|
|
53
|
+
@internal_data.test_finished
|
|
54
|
+
result.add_run
|
|
55
|
+
yield(Test::Unit::TestCase::FINISHED, name)
|
|
56
|
+
yield(Test::Unit::TestCase::FINISHED_OBJECT, self)
|
|
57
|
+
ensure
|
|
58
|
+
# @_result = nil # For test-spec's after_all :<
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Mocha
|
|
2
|
+
module Integration
|
|
3
|
+
module TestUnit
|
|
4
|
+
module Nothing
|
|
5
|
+
def self.applicable_to?(test_unit_version, ruby_version = nil)
|
|
6
|
+
true
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.description
|
|
10
|
+
"nothing (no Test::Unit integration available)"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.included(mod)
|
|
14
|
+
raise "No Test::Unit integration available"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|