mocha 0.12.10 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +22 -0
- data/COPYING.md +3 -0
- data/{MIT-LICENSE.rdoc → MIT-LICENSE.md} +0 -0
- data/README.md +230 -0
- data/{RELEASE.rdoc → RELEASE.md} +61 -56
- data/Rakefile +45 -37
- data/build-matrix.rb +16 -4
- data/lib/mocha.rb +6 -2
- 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.rb +6 -38
- data/lib/mocha/integration/assertion_counter.rb +13 -0
- data/lib/mocha/integration/mini_test.rb +42 -60
- 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/monkey_patcher.rb +18 -0
- data/lib/mocha/integration/test_unit.rb +38 -45
- 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/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_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 +45 -74
- 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/mini_test/version_450_to_461.rb +0 -72
- data/lib/mocha/integration/test_unit/assertion_counter.rb +0 -23
- data/lib/mocha/integration/test_unit/gem_version_230_to_254.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
@@ -1,56 +1,62 @@
|
|
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 Version142To172
|
9
|
+
def self.applicable_to?(mini_test_version)
|
10
|
+
Gem::Requirement.new('>= 1.4.2', '<= 1.7.2').satisfied_by?(mini_test_version)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.description
|
14
|
+
"monkey patch for MiniTest gem >= v1.4.2 and <= v1.7.2"
|
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
|
-
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
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
module RunMethodPatch
|
22
|
+
def run runner
|
23
|
+
trap 'INFO' do
|
24
|
+
warn '%s#%s %.2fs' % [self.class, self.__name__,
|
25
|
+
(Time.now - runner.start_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.__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
32
|
begin
|
37
|
-
|
33
|
+
@passed = nil
|
34
|
+
self.setup
|
35
|
+
self.__send__ self.__name__
|
36
|
+
mocha_verify(assertion_counter)
|
37
|
+
@passed = true
|
38
38
|
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
39
39
|
raise
|
40
40
|
rescue Exception => e
|
41
|
+
@passed = false
|
41
42
|
result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
|
43
|
+
ensure
|
44
|
+
begin
|
45
|
+
self.teardown
|
46
|
+
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
47
|
+
raise
|
48
|
+
rescue Exception => e
|
49
|
+
result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
|
50
|
+
end
|
51
|
+
trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
42
52
|
end
|
43
|
-
|
53
|
+
ensure
|
54
|
+
mocha_teardown
|
44
55
|
end
|
45
|
-
|
46
|
-
mocha_teardown
|
56
|
+
result
|
47
57
|
end
|
48
|
-
result
|
49
58
|
end
|
50
59
|
end
|
51
|
-
|
52
60
|
end
|
53
|
-
|
54
61
|
end
|
55
|
-
|
56
62
|
end
|
@@ -1,57 +1,63 @@
|
|
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 Version200
|
9
|
+
def self.applicable_to?(mini_test_version)
|
10
|
+
Gem::Requirement.new('2.0.0').satisfied_by?(mini_test_version)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.description
|
14
|
+
"monkey patch for MiniTest gem v2.0.0"
|
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 = Time.now - runner.start_time
|
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 = Time.now - runner.start_time
|
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.__send__ self.__name__
|
28
|
-
mocha_verify(assertion_counter)
|
29
|
-
result = "." unless io?
|
30
|
-
@passed = true
|
31
|
-
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
32
|
-
raise
|
33
|
-
rescue Exception => e
|
34
|
-
@passed = false
|
35
|
-
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
36
|
-
ensure
|
37
32
|
begin
|
38
|
-
|
33
|
+
@passed = nil
|
34
|
+
self.setup
|
35
|
+
self.__send__ self.__name__
|
36
|
+
mocha_verify(assertion_counter)
|
37
|
+
result = "." unless io?
|
38
|
+
@passed = true
|
39
39
|
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
40
40
|
raise
|
41
41
|
rescue Exception => e
|
42
|
+
@passed = false
|
42
43
|
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
44
|
+
ensure
|
45
|
+
begin
|
46
|
+
self.teardown
|
47
|
+
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
48
|
+
raise
|
49
|
+
rescue Exception => e
|
50
|
+
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
51
|
+
end
|
52
|
+
trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
43
53
|
end
|
44
|
-
|
54
|
+
ensure
|
55
|
+
mocha_teardown
|
45
56
|
end
|
46
|
-
|
47
|
-
mocha_teardown
|
57
|
+
result
|
48
58
|
end
|
49
|
-
result
|
50
59
|
end
|
51
60
|
end
|
52
|
-
|
53
61
|
end
|
54
|
-
|
55
62
|
end
|
56
|
-
|
57
63
|
end
|
@@ -1,57 +1,63 @@
|
|
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 Version201To222
|
9
|
+
def self.applicable_to?(mini_test_version)
|
10
|
+
Gem::Requirement.new('>= 2.0.1', '<= 2.2.2').satisfied_by?(mini_test_version)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.description
|
14
|
+
"monkey patch for MiniTest gem >= v2.0.1 <= v2.2.2"
|
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.__send__ self.__name__
|
28
|
-
mocha_verify(assertion_counter)
|
29
|
-
result = "." unless io?
|
30
|
-
@passed = true
|
31
|
-
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
32
|
-
raise
|
33
|
-
rescue Exception => e
|
34
|
-
@passed = false
|
35
|
-
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
36
|
-
ensure
|
37
32
|
begin
|
38
|
-
|
33
|
+
@passed = nil
|
34
|
+
self.setup
|
35
|
+
self.__send__ self.__name__
|
36
|
+
mocha_verify(assertion_counter)
|
37
|
+
result = "." unless io?
|
38
|
+
@passed = true
|
39
39
|
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
40
40
|
raise
|
41
41
|
rescue Exception => e
|
42
|
+
@passed = false
|
42
43
|
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
44
|
+
ensure
|
45
|
+
begin
|
46
|
+
self.teardown
|
47
|
+
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
48
|
+
raise
|
49
|
+
rescue Exception => e
|
50
|
+
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
51
|
+
end
|
52
|
+
trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
43
53
|
end
|
44
|
-
|
54
|
+
ensure
|
55
|
+
mocha_teardown
|
45
56
|
end
|
46
|
-
|
47
|
-
mocha_teardown
|
57
|
+
result
|
48
58
|
end
|
49
|
-
result
|
50
59
|
end
|
51
60
|
end
|
52
|
-
|
53
61
|
end
|
54
|
-
|
55
62
|
end
|
56
|
-
|
57
63
|
end
|
@@ -1,61 +1,67 @@
|
|
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 Version2110To2111
|
9
|
+
def self.applicable_to?(mini_test_version)
|
10
|
+
Gem::Requirement.new('>= 2.11.0', '<= 2.11.1').satisfied_by?(mini_test_version)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.description
|
14
|
+
"monkey patch for MiniTest gem >= v2.11.0 <= v2.11.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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
32
|
+
begin
|
33
|
+
@passed = nil
|
34
|
+
self.before_setup
|
35
|
+
self.setup
|
36
|
+
self.after_setup
|
37
|
+
self.run_test self.__name__
|
38
|
+
mocha_verify(assertion_counter)
|
39
|
+
result = "." unless io?
|
40
|
+
@passed = true
|
41
|
+
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
42
|
+
raise
|
43
|
+
rescue Exception => e
|
44
|
+
@passed = false
|
45
|
+
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
46
|
+
ensure
|
47
|
+
%w{ before_teardown teardown after_teardown }.each do |hook|
|
48
|
+
begin
|
49
|
+
self.send hook
|
50
|
+
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
51
|
+
raise
|
52
|
+
rescue Exception => e
|
53
|
+
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
54
|
+
end
|
46
55
|
end
|
56
|
+
trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
47
57
|
end
|
48
|
-
|
58
|
+
ensure
|
59
|
+
mocha_teardown
|
49
60
|
end
|
50
|
-
|
51
|
-
mocha_teardown
|
61
|
+
result
|
52
62
|
end
|
53
|
-
result
|
54
63
|
end
|
55
64
|
end
|
56
|
-
|
57
65
|
end
|
58
|
-
|
59
66
|
end
|
60
|
-
|
61
67
|
end
|
@@ -1,64 +1,70 @@
|
|
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 Version2112To320
|
9
|
+
def self.applicable_to?(mini_test_version)
|
10
|
+
Gem::Requirement.new('>= 2.11.2', '<= 3.2.0').satisfied_by?(mini_test_version)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.description
|
14
|
+
"monkey patch for MiniTest gem >= v2.11.2 <= v3.2.0"
|
15
|
+
end
|
16
|
+
|
11
17
|
def self.included(mod)
|
12
|
-
|
18
|
+
MonkeyPatcher.apply(mod, RunMethodPatch)
|
13
19
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
|
21
|
+
module RunMethodPatch
|
22
|
+
def run runner
|
23
|
+
trap "INFO" do
|
24
|
+
runner.report.each_with_index do |msg, i|
|
25
|
+
warn "\n%3d) %s" % [i + 1, msg]
|
26
|
+
end
|
27
|
+
warn ''
|
28
|
+
time = runner.start_time ? Time.now - runner.start_time : 0
|
29
|
+
warn "Current Test: %s#%s %.2fs" % [self.class, self.__name__, time]
|
30
|
+
runner.status $stderr
|
31
|
+
end if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
32
|
+
assertion_counter = AssertionCounter.new(self)
|
33
|
+
result = ""
|
27
34
|
begin
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
35
|
+
begin
|
36
|
+
@passed = nil
|
37
|
+
self.before_setup
|
38
|
+
self.setup
|
39
|
+
self.after_setup
|
40
|
+
self.run_test self.__name__
|
41
|
+
mocha_verify(assertion_counter)
|
42
|
+
result = "." unless io?
|
43
|
+
@passed = true
|
44
|
+
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
45
|
+
raise
|
46
|
+
rescue Exception => e
|
47
|
+
@passed = false
|
48
|
+
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
49
|
+
ensure
|
50
|
+
%w{ before_teardown teardown after_teardown }.each do |hook|
|
51
|
+
begin
|
52
|
+
self.send hook
|
53
|
+
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
54
|
+
raise
|
55
|
+
rescue Exception => e
|
56
|
+
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
57
|
+
end
|
49
58
|
end
|
59
|
+
trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
50
60
|
end
|
51
|
-
|
61
|
+
ensure
|
62
|
+
mocha_teardown
|
52
63
|
end
|
53
|
-
|
54
|
-
mocha_teardown
|
64
|
+
result
|
55
65
|
end
|
56
|
-
result
|
57
66
|
end
|
58
67
|
end
|
59
|
-
|
60
68
|
end
|
61
|
-
|
62
69
|
end
|
63
|
-
|
64
70
|
end
|