mocha 1.11.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +29 -0
- data/README.md +35 -31
- data/RELEASE.md +128 -0
- data/Rakefile +26 -22
- data/gemfiles/Gemfile.minitest.latest +1 -0
- data/gemfiles/Gemfile.test-unit.latest +2 -5
- data/lib/mocha/any_instance_method.rb +0 -5
- data/lib/mocha/api.rb +29 -78
- data/lib/mocha/cardinality.rb +30 -27
- data/lib/mocha/class_methods.rb +2 -2
- data/lib/mocha/configuration.rb +30 -108
- data/lib/mocha/expectation.rb +86 -31
- data/lib/mocha/inspect.rb +5 -3
- data/lib/mocha/instance_method.rb +0 -4
- data/lib/mocha/integration/mini_test.rb +10 -38
- data/lib/mocha/integration/test_unit/adapter.rb +1 -1
- data/lib/mocha/integration/test_unit.rb +10 -33
- data/lib/mocha/invocation.rb +12 -16
- data/lib/mocha/minitest.rb +2 -4
- data/lib/mocha/mock.rb +26 -26
- data/lib/mocha/mockery.rb +10 -25
- data/lib/mocha/parameter_matchers/base.rb +1 -1
- data/lib/mocha/parameter_matchers/equivalent_uri.rb +0 -1
- data/lib/mocha/parameter_matchers/has_entry.rb +22 -13
- data/lib/mocha/parameter_matchers/has_keys.rb +53 -0
- data/lib/mocha/parameter_matchers/instance_methods.rb +10 -1
- data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +64 -0
- data/lib/mocha/parameter_matchers.rb +1 -0
- data/lib/mocha/parameters_matcher.rb +3 -3
- data/lib/mocha/ruby_version.rb +1 -2
- data/lib/mocha/state_machine.rb +30 -38
- data/lib/mocha/stubbed_method.rb +5 -42
- data/lib/mocha/test_unit.rb +2 -4
- data/lib/mocha/version.rb +1 -1
- data/lib/mocha.rb +0 -8
- data/mocha.gemspec +6 -31
- metadata +10 -286
- data/bin/build-matrix +0 -82
- data/docs/CNAME +0 -1
- data/docs/Mocha/API.html +0 -1285
- data/docs/Mocha/ClassMethods.html +0 -264
- data/docs/Mocha/Configuration.html +0 -1525
- data/docs/Mocha/Expectation.html +0 -2862
- data/docs/Mocha/ExpectationError.html +0 -152
- data/docs/Mocha/ExpectationErrorFactory.html +0 -260
- data/docs/Mocha/Hooks.html +0 -370
- data/docs/Mocha/Integration/MiniTest/Adapter.html +0 -164
- data/docs/Mocha/Integration/MiniTest.html +0 -123
- data/docs/Mocha/Integration/TestUnit/Adapter.html +0 -164
- data/docs/Mocha/Integration/TestUnit.html +0 -123
- data/docs/Mocha/Integration.html +0 -125
- data/docs/Mocha/Mock.html +0 -1210
- data/docs/Mocha/ObjectMethods.html +0 -765
- data/docs/Mocha/ParameterMatchers/AllOf.html +0 -153
- data/docs/Mocha/ParameterMatchers/AnyOf.html +0 -153
- data/docs/Mocha/ParameterMatchers/AnyParameters.html +0 -153
- data/docs/Mocha/ParameterMatchers/Anything.html +0 -153
- data/docs/Mocha/ParameterMatchers/Base.html +0 -441
- data/docs/Mocha/ParameterMatchers/Equals.html +0 -153
- data/docs/Mocha/ParameterMatchers/EquivalentUri.html +0 -153
- data/docs/Mocha/ParameterMatchers/HasEntries.html +0 -153
- data/docs/Mocha/ParameterMatchers/HasEntry.html +0 -153
- data/docs/Mocha/ParameterMatchers/HasKey.html +0 -153
- data/docs/Mocha/ParameterMatchers/HasValue.html +0 -153
- data/docs/Mocha/ParameterMatchers/Includes.html +0 -153
- data/docs/Mocha/ParameterMatchers/InstanceOf.html +0 -153
- data/docs/Mocha/ParameterMatchers/IsA.html +0 -153
- data/docs/Mocha/ParameterMatchers/KindOf.html +0 -153
- data/docs/Mocha/ParameterMatchers/Not.html +0 -153
- data/docs/Mocha/ParameterMatchers/Optionally.html +0 -153
- data/docs/Mocha/ParameterMatchers/RegexpMatches.html +0 -153
- data/docs/Mocha/ParameterMatchers/RespondsWith.html +0 -153
- data/docs/Mocha/ParameterMatchers/YamlEquivalent.html +0 -153
- data/docs/Mocha/ParameterMatchers.html +0 -2949
- data/docs/Mocha/Sequence.html +0 -149
- data/docs/Mocha/StateMachine/State.html +0 -140
- data/docs/Mocha/StateMachine/StatePredicate.html +0 -140
- data/docs/Mocha/StateMachine.html +0 -527
- data/docs/Mocha/StubbingError.html +0 -150
- data/docs/Mocha.html +0 -254
- data/docs/_index.html +0 -519
- data/docs/class_list.html +0 -51
- data/docs/css/common.css +0 -1
- data/docs/css/full_list.css +0 -58
- data/docs/css/style.css +0 -496
- data/docs/file.COPYING.html +0 -81
- data/docs/file.MIT-LICENSE.html +0 -85
- data/docs/file.README.html +0 -448
- data/docs/file.RELEASE.html +0 -1028
- data/docs/file_list.html +0 -71
- data/docs/frames.html +0 -17
- data/docs/index.html +0 -448
- data/docs/js/app.js +0 -303
- data/docs/js/full_list.js +0 -216
- data/docs/js/jquery.js +0 -4
- data/docs/method_list.html +0 -651
- data/docs/top-level-namespace.html +0 -118
- data/gemfiles/Gemfile.minitest.1.3.0 +0 -7
- data/gemfiles/Gemfile.minitest.1.4.0 +0 -7
- data/gemfiles/Gemfile.minitest.1.4.1 +0 -7
- data/gemfiles/Gemfile.minitest.1.4.2 +0 -7
- data/gemfiles/Gemfile.minitest.2.0.0 +0 -7
- data/gemfiles/Gemfile.minitest.2.0.1 +0 -7
- data/gemfiles/Gemfile.minitest.2.11.0 +0 -7
- data/gemfiles/Gemfile.minitest.2.11.2 +0 -7
- data/gemfiles/Gemfile.minitest.2.3.0 +0 -7
- data/gemfiles/Gemfile.minitest.5.11.3 +0 -7
- data/gemfiles/Gemfile.test-unit.2.0.0 +0 -7
- data/gemfiles/Gemfile.test-unit.2.0.1 +0 -7
- data/gemfiles/Gemfile.test-unit.2.0.3 +0 -7
- data/init.rb +0 -1
- data/lib/mocha/integration/mini_test/nothing.rb +0 -19
- data/lib/mocha/integration/mini_test/version_13.rb +0 -54
- data/lib/mocha/integration/mini_test/version_140.rb +0 -54
- data/lib/mocha/integration/mini_test/version_141.rb +0 -65
- data/lib/mocha/integration/mini_test/version_142_to_172.rb +0 -65
- data/lib/mocha/integration/mini_test/version_200.rb +0 -66
- data/lib/mocha/integration/mini_test/version_201_to_222.rb +0 -66
- data/lib/mocha/integration/mini_test/version_2110_to_2111.rb +0 -70
- data/lib/mocha/integration/mini_test/version_2112_to_320.rb +0 -73
- data/lib/mocha/integration/mini_test/version_230_to_2101.rb +0 -68
- data/lib/mocha/integration/test_unit/gem_version_200.rb +0 -62
- data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +0 -62
- data/lib/mocha/integration/test_unit/gem_version_203_to_220.rb +0 -62
- data/lib/mocha/integration/test_unit/gem_version_230_to_250.rb +0 -68
- data/lib/mocha/integration/test_unit/nothing.rb +0 -19
- data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +0 -61
- data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +0 -63
- data/lib/mocha/integration.rb +0 -11
- data/lib/mocha/setup.rb +0 -14
- data/lib/mocha/singleton_class.rb +0 -9
- data/test/acceptance/acceptance_test_helper.rb +0 -42
- data/test/acceptance/bug_18914_test.rb +0 -37
- data/test/acceptance/bug_21465_test.rb +0 -31
- data/test/acceptance/bug_21563_test.rb +0 -22
- data/test/acceptance/display_matching_invocations_alongside_expectations_test.rb +0 -69
- data/test/acceptance/exception_rescue_test.rb +0 -53
- data/test/acceptance/expectations_on_multiple_methods_test.rb +0 -55
- data/test/acceptance/expected_invocation_count_test.rb +0 -229
- data/test/acceptance/failure_messages_test.rb +0 -77
- data/test/acceptance/issue_272_test.rb +0 -50
- data/test/acceptance/issue_457_test.rb +0 -31
- data/test/acceptance/issue_65_test.rb +0 -64
- data/test/acceptance/issue_70_test.rb +0 -53
- data/test/acceptance/mocha_example_test.rb +0 -106
- data/test/acceptance/mocha_test_result_test.rb +0 -83
- data/test/acceptance/mock_built_with_first_argument_type_being_string_test.rb +0 -98
- data/test/acceptance/mock_test.rb +0 -191
- data/test/acceptance/mocked_methods_dispatch_test.rb +0 -75
- data/test/acceptance/multiple_expectations_failure_message_test.rb +0 -66
- data/test/acceptance/multiple_yielding_test.rb +0 -59
- data/test/acceptance/optional_parameters_test.rb +0 -67
- data/test/acceptance/parameter_matcher_test.rb +0 -299
- data/test/acceptance/partial_mocks_test.rb +0 -44
- data/test/acceptance/prepend_test.rb +0 -86
- data/test/acceptance/prevent_use_of_mocha_outside_test_test.rb +0 -76
- data/test/acceptance/raise_exception_test.rb +0 -36
- data/test/acceptance/return_value_test.rb +0 -49
- data/test/acceptance/sequence_test.rb +0 -189
- data/test/acceptance/states_test.rb +0 -71
- data/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb +0 -64
- data/test/acceptance/stub_any_instance_method_test.rb +0 -301
- data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +0 -105
- data/test/acceptance/stub_class_method_defined_on_class_test.rb +0 -78
- data/test/acceptance/stub_class_method_defined_on_module_test.rb +0 -73
- data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +0 -144
- data/test/acceptance/stub_everything_test.rb +0 -53
- data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +0 -91
- data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +0 -67
- data/test/acceptance/stub_instance_method_defined_on_class_test.rb +0 -67
- data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +0 -136
- data/test/acceptance/stub_instance_method_defined_on_module_test.rb +0 -76
- data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +0 -75
- data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +0 -67
- data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +0 -70
- data/test/acceptance/stub_method_defined_on_module_and_aliased_test.rb +0 -38
- data/test/acceptance/stub_module_method_test.rb +0 -200
- data/test/acceptance/stub_test.rb +0 -49
- data/test/acceptance/stubba_example_test.rb +0 -103
- data/test/acceptance/stubba_test_result_test.rb +0 -71
- data/test/acceptance/stubbing_error_backtrace_test.rb +0 -63
- data/test/acceptance/stubbing_frozen_object_test.rb +0 -88
- data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +0 -52
- data/test/acceptance/stubbing_method_unnecessarily_test.rb +0 -63
- data/test/acceptance/stubbing_nil_test.rb +0 -60
- data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +0 -157
- data/test/acceptance/stubbing_non_existent_class_method_test.rb +0 -157
- data/test/acceptance/stubbing_non_existent_instance_method_test.rb +0 -145
- data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +0 -128
- data/test/acceptance/stubbing_non_public_class_method_test.rb +0 -163
- data/test/acceptance/stubbing_non_public_instance_method_test.rb +0 -141
- data/test/acceptance/stubbing_on_non_mock_object_test.rb +0 -70
- data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +0 -33
- data/test/acceptance/throw_test.rb +0 -42
- data/test/acceptance/unexpected_invocation_test.rb +0 -23
- data/test/acceptance/unstubbing_test.rb +0 -194
- data/test/acceptance/yielding_test.rb +0 -80
- data/test/assertions.rb +0 -8
- data/test/deprecation_disabler.rb +0 -15
- data/test/execution_point.rb +0 -36
- data/test/integration/mini_test_test.rb +0 -8
- data/test/integration/shared_tests.rb +0 -178
- data/test/integration/test_unit_test.rb +0 -8
- data/test/method_definer.rb +0 -16
- data/test/mini_test_result.rb +0 -96
- data/test/minitest_result.rb +0 -48
- data/test/simple_counter.rb +0 -11
- data/test/test_helper.rb +0 -58
- data/test/test_runner.rb +0 -58
- data/test/test_unit_result.rb +0 -22
- data/test/unit/any_instance_method_test.rb +0 -175
- data/test/unit/array_inspect_test.rb +0 -14
- data/test/unit/backtrace_filter_test.rb +0 -17
- data/test/unit/cardinality_test.rb +0 -72
- data/test/unit/central_test.rb +0 -98
- data/test/unit/change_state_side_effect_test.rb +0 -37
- data/test/unit/class_methods_test.rb +0 -69
- data/test/unit/configuration_test.rb +0 -37
- data/test/unit/date_time_inspect_test.rb +0 -19
- data/test/unit/exception_raiser_test.rb +0 -45
- data/test/unit/expectation_list_test.rb +0 -82
- data/test/unit/expectation_test.rb +0 -504
- data/test/unit/hash_inspect_test.rb +0 -14
- data/test/unit/hooks_test.rb +0 -35
- data/test/unit/in_state_ordering_constraint_test.rb +0 -39
- data/test/unit/instance_method_test.rb +0 -282
- data/test/unit/method_matcher_test.rb +0 -26
- data/test/unit/mock_test.rb +0 -372
- data/test/unit/mockery_test.rb +0 -171
- data/test/unit/module_methods_test.rb +0 -16
- data/test/unit/object_inspect_test.rb +0 -60
- data/test/unit/object_methods_test.rb +0 -63
- data/test/unit/parameter_matchers/all_of_test.rb +0 -24
- data/test/unit/parameter_matchers/any_of_test.rb +0 -24
- data/test/unit/parameter_matchers/anything_test.rb +0 -19
- data/test/unit/parameter_matchers/equals_test.rb +0 -23
- data/test/unit/parameter_matchers/equivalent_uri_test.rb +0 -41
- data/test/unit/parameter_matchers/has_entries_test.rb +0 -51
- data/test/unit/parameter_matchers/has_entry_test.rb +0 -128
- data/test/unit/parameter_matchers/has_key_test.rb +0 -54
- data/test/unit/parameter_matchers/has_value_test.rb +0 -55
- data/test/unit/parameter_matchers/includes_test.rb +0 -106
- data/test/unit/parameter_matchers/instance_of_test.rb +0 -23
- data/test/unit/parameter_matchers/is_a_test.rb +0 -23
- data/test/unit/parameter_matchers/kind_of_test.rb +0 -23
- data/test/unit/parameter_matchers/not_test.rb +0 -24
- data/test/unit/parameter_matchers/regexp_matches_test.rb +0 -45
- data/test/unit/parameter_matchers/responds_with_test.rb +0 -38
- data/test/unit/parameter_matchers/stub_matcher.rb +0 -23
- data/test/unit/parameter_matchers/yaml_equivalent_test.rb +0 -23
- data/test/unit/parameters_matcher_test.rb +0 -119
- data/test/unit/receivers_test.rb +0 -96
- data/test/unit/return_values_test.rb +0 -66
- data/test/unit/sequence_test.rb +0 -100
- data/test/unit/single_return_value_test.rb +0 -17
- data/test/unit/state_machine_test.rb +0 -96
- data/test/unit/string_inspect_test.rb +0 -9
- data/test/unit/thrower_test.rb +0 -23
- data/test/unit/yield_parameters_test.rb +0 -73
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'mocha/integration/assertion_counter'
|
2
|
-
require 'mocha/integration/monkey_patcher'
|
3
|
-
require 'mocha/integration/mini_test/exception_translation'
|
4
|
-
|
5
|
-
module Mocha
|
6
|
-
module Integration
|
7
|
-
module MiniTest
|
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
|
-
|
17
|
-
def self.included(mod)
|
18
|
-
MonkeyPatcher.apply(mod, RunMethodPatch)
|
19
|
-
end
|
20
|
-
|
21
|
-
module RunMethodPatch
|
22
|
-
# rubocop:disable all
|
23
|
-
def run runner
|
24
|
-
trap 'INFO' do
|
25
|
-
time = runner.start_time ? Time.now - runner.start_time : 0
|
26
|
-
warn "%s#%s %.2fs" % [self.class, self.__name__, time]
|
27
|
-
runner.status $stderr
|
28
|
-
end if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
29
|
-
|
30
|
-
assertion_counter = AssertionCounter.new(self)
|
31
|
-
result = ""
|
32
|
-
begin
|
33
|
-
begin
|
34
|
-
@passed = nil
|
35
|
-
self.before_setup
|
36
|
-
mocha_setup
|
37
|
-
self.setup
|
38
|
-
self.after_setup
|
39
|
-
self.run_test self.__name__
|
40
|
-
mocha_verify(assertion_counter)
|
41
|
-
result = "." unless io?
|
42
|
-
@passed = true
|
43
|
-
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
44
|
-
raise
|
45
|
-
rescue Exception => e
|
46
|
-
@passed = false
|
47
|
-
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
48
|
-
ensure
|
49
|
-
%w{ before_teardown teardown after_teardown }.each do |hook|
|
50
|
-
begin
|
51
|
-
self.send hook
|
52
|
-
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
53
|
-
raise
|
54
|
-
rescue Exception => e
|
55
|
-
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
59
|
-
end
|
60
|
-
ensure
|
61
|
-
mocha_teardown
|
62
|
-
end
|
63
|
-
result
|
64
|
-
end
|
65
|
-
# rubocop:enable all
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'mocha/integration/assertion_counter'
|
2
|
-
require 'mocha/integration/monkey_patcher'
|
3
|
-
require 'mocha/integration/mini_test/exception_translation'
|
4
|
-
|
5
|
-
module Mocha
|
6
|
-
module Integration
|
7
|
-
module MiniTest
|
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
|
-
|
17
|
-
def self.included(mod)
|
18
|
-
MonkeyPatcher.apply(mod, RunMethodPatch)
|
19
|
-
end
|
20
|
-
|
21
|
-
module RunMethodPatch
|
22
|
-
# rubocop:disable all
|
23
|
-
def run runner
|
24
|
-
trap "INFO" do
|
25
|
-
runner.report.each_with_index do |msg, i|
|
26
|
-
warn "\n%3d) %s" % [i + 1, msg]
|
27
|
-
end
|
28
|
-
warn ''
|
29
|
-
time = runner.start_time ? Time.now - runner.start_time : 0
|
30
|
-
warn "Current Test: %s#%s %.2fs" % [self.class, self.__name__, time]
|
31
|
-
runner.status $stderr
|
32
|
-
end if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
33
|
-
assertion_counter = AssertionCounter.new(self)
|
34
|
-
result = ""
|
35
|
-
begin
|
36
|
-
begin
|
37
|
-
@passed = nil
|
38
|
-
self.before_setup
|
39
|
-
mocha_setup
|
40
|
-
self.setup
|
41
|
-
self.after_setup
|
42
|
-
self.run_test self.__name__
|
43
|
-
mocha_verify(assertion_counter)
|
44
|
-
result = "." unless io?
|
45
|
-
@passed = true
|
46
|
-
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
47
|
-
raise
|
48
|
-
rescue Exception => e
|
49
|
-
@passed = false
|
50
|
-
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
51
|
-
ensure
|
52
|
-
%w{ before_teardown teardown after_teardown }.each do |hook|
|
53
|
-
begin
|
54
|
-
self.send hook
|
55
|
-
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
56
|
-
raise
|
57
|
-
rescue Exception => e
|
58
|
-
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
62
|
-
end
|
63
|
-
ensure
|
64
|
-
mocha_teardown
|
65
|
-
end
|
66
|
-
result
|
67
|
-
end
|
68
|
-
# rubocop:enable all
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'mocha/integration/assertion_counter'
|
2
|
-
require 'mocha/integration/monkey_patcher'
|
3
|
-
require 'mocha/integration/mini_test/exception_translation'
|
4
|
-
|
5
|
-
module Mocha
|
6
|
-
module Integration
|
7
|
-
module MiniTest
|
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
|
-
|
17
|
-
def self.included(mod)
|
18
|
-
MonkeyPatcher.apply(mod, RunMethodPatch)
|
19
|
-
end
|
20
|
-
|
21
|
-
module RunMethodPatch
|
22
|
-
# rubocop:disable all
|
23
|
-
def run runner
|
24
|
-
trap 'INFO' do
|
25
|
-
time = runner.start_time ? Time.now - runner.start_time : 0
|
26
|
-
warn "%s#%s %.2fs" % [self.class, self.__name__, time]
|
27
|
-
runner.status $stderr
|
28
|
-
end if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
29
|
-
|
30
|
-
assertion_counter = AssertionCounter.new(self)
|
31
|
-
result = ""
|
32
|
-
begin
|
33
|
-
begin
|
34
|
-
@passed = nil
|
35
|
-
mocha_setup
|
36
|
-
self.setup
|
37
|
-
self.run_setup_hooks
|
38
|
-
self.__send__ self.__name__
|
39
|
-
mocha_verify(assertion_counter)
|
40
|
-
result = "." unless io?
|
41
|
-
@passed = true
|
42
|
-
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
43
|
-
raise
|
44
|
-
rescue Exception => e
|
45
|
-
@passed = false
|
46
|
-
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
47
|
-
ensure
|
48
|
-
begin
|
49
|
-
self.run_teardown_hooks
|
50
|
-
self.teardown
|
51
|
-
rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
|
52
|
-
raise
|
53
|
-
rescue Exception => e
|
54
|
-
result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
|
55
|
-
end
|
56
|
-
trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
|
57
|
-
end
|
58
|
-
ensure
|
59
|
-
mocha_teardown
|
60
|
-
end
|
61
|
-
result
|
62
|
-
end
|
63
|
-
# rubocop:enable all
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,62 +0,0 @@
|
|
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 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
|
-
|
17
|
-
def self.included(mod)
|
18
|
-
MonkeyPatcher.apply(mod, RunMethodPatch)
|
19
|
-
end
|
20
|
-
|
21
|
-
module RunMethodPatch
|
22
|
-
# rubocop:disable all
|
23
|
-
def run(result)
|
24
|
-
assertion_counter = AssertionCounter.new(self)
|
25
|
-
begin
|
26
|
-
@_result = result
|
27
|
-
yield(Test::Unit::TestCase::STARTED, name)
|
28
|
-
begin
|
29
|
-
begin
|
30
|
-
mocha_setup
|
31
|
-
run_setup
|
32
|
-
__send__(@method_name)
|
33
|
-
mocha_verify(assertion_counter)
|
34
|
-
rescue Mocha::ExpectationError => e
|
35
|
-
add_failure(e.message, e.backtrace)
|
36
|
-
rescue Exception
|
37
|
-
@interrupted = true
|
38
|
-
raise unless handle_exception($!)
|
39
|
-
ensure
|
40
|
-
begin
|
41
|
-
run_teardown
|
42
|
-
rescue Mocha::ExpectationError => e
|
43
|
-
add_failure(e.message, e.backtrace)
|
44
|
-
rescue Exception
|
45
|
-
raise unless handle_exception($!)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
ensure
|
49
|
-
mocha_teardown
|
50
|
-
end
|
51
|
-
result.add_run
|
52
|
-
yield(Test::Unit::TestCase::FINISHED, name)
|
53
|
-
ensure
|
54
|
-
@_result = nil
|
55
|
-
end
|
56
|
-
end
|
57
|
-
# rubocop:enable all
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,62 +0,0 @@
|
|
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 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
|
-
|
17
|
-
def self.included(mod)
|
18
|
-
MonkeyPatcher.apply(mod, RunMethodPatch)
|
19
|
-
end
|
20
|
-
|
21
|
-
module RunMethodPatch
|
22
|
-
# rubocop:disable all
|
23
|
-
def run(result)
|
24
|
-
assertion_counter = AssertionCounter.new(self)
|
25
|
-
begin
|
26
|
-
@_result = result
|
27
|
-
yield(Test::Unit::TestCase::STARTED, name)
|
28
|
-
begin
|
29
|
-
begin
|
30
|
-
mocha_setup
|
31
|
-
run_setup
|
32
|
-
run_test
|
33
|
-
mocha_verify(assertion_counter)
|
34
|
-
rescue Mocha::ExpectationError => e
|
35
|
-
add_failure(e.message, e.backtrace)
|
36
|
-
rescue Exception
|
37
|
-
@interrupted = true
|
38
|
-
raise unless handle_exception($!)
|
39
|
-
ensure
|
40
|
-
begin
|
41
|
-
run_teardown
|
42
|
-
rescue Mocha::ExpectationError => e
|
43
|
-
add_failure(e.message, e.backtrace)
|
44
|
-
rescue Exception
|
45
|
-
raise unless handle_exception($!)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
ensure
|
49
|
-
mocha_teardown
|
50
|
-
end
|
51
|
-
result.add_run
|
52
|
-
yield(Test::Unit::TestCase::FINISHED, name)
|
53
|
-
ensure
|
54
|
-
@_result = nil
|
55
|
-
end
|
56
|
-
end
|
57
|
-
# rubocop:enable all
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,62 +0,0 @@
|
|
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 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
|
-
|
17
|
-
def self.included(mod)
|
18
|
-
MonkeyPatcher.apply(mod, RunMethodPatch)
|
19
|
-
end
|
20
|
-
|
21
|
-
module RunMethodPatch
|
22
|
-
# rubocop:disable all
|
23
|
-
def run(result)
|
24
|
-
assertion_counter = AssertionCounter.new(self)
|
25
|
-
begin
|
26
|
-
@_result = result
|
27
|
-
yield(Test::Unit::TestCase::STARTED, name)
|
28
|
-
begin
|
29
|
-
begin
|
30
|
-
mocha_setup
|
31
|
-
run_setup
|
32
|
-
run_test
|
33
|
-
mocha_verify(assertion_counter)
|
34
|
-
rescue Mocha::ExpectationError => e
|
35
|
-
add_failure(e.message, e.backtrace)
|
36
|
-
rescue Exception
|
37
|
-
@interrupted = true
|
38
|
-
raise unless handle_exception($!)
|
39
|
-
ensure
|
40
|
-
begin
|
41
|
-
run_teardown
|
42
|
-
rescue Mocha::ExpectationError => e
|
43
|
-
add_failure(e.message, e.backtrace)
|
44
|
-
rescue Exception
|
45
|
-
raise unless handle_exception($!)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
ensure
|
49
|
-
mocha_teardown
|
50
|
-
end
|
51
|
-
result.add_run
|
52
|
-
yield(Test::Unit::TestCase::FINISHED, name)
|
53
|
-
ensure
|
54
|
-
# @_result = nil # For test-spec's after_all :<
|
55
|
-
end
|
56
|
-
end
|
57
|
-
# rubocop:enable all
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,68 +0,0 @@
|
|
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
|
-
# rubocop:disable all
|
23
|
-
def run(result)
|
24
|
-
assertion_counter = AssertionCounter.new(self)
|
25
|
-
begin
|
26
|
-
@internal_data.test_started
|
27
|
-
@_result = result
|
28
|
-
yield(Test::Unit::TestCase::STARTED, name)
|
29
|
-
yield(Test::Unit::TestCase::STARTED_OBJECT, self)
|
30
|
-
begin
|
31
|
-
begin
|
32
|
-
mocha_setup
|
33
|
-
run_setup
|
34
|
-
run_test
|
35
|
-
run_cleanup
|
36
|
-
mocha_verify(assertion_counter)
|
37
|
-
add_pass
|
38
|
-
rescue Mocha::ExpectationError => e
|
39
|
-
add_failure(e.message, e.backtrace)
|
40
|
-
rescue Exception
|
41
|
-
@internal_data.interrupted
|
42
|
-
raise unless handle_exception($!)
|
43
|
-
ensure
|
44
|
-
begin
|
45
|
-
run_teardown
|
46
|
-
rescue Mocha::ExpectationError => e
|
47
|
-
add_failure(e.message, e.backtrace)
|
48
|
-
rescue Exception
|
49
|
-
raise unless handle_exception($!)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
ensure
|
53
|
-
mocha_teardown
|
54
|
-
end
|
55
|
-
@internal_data.test_finished
|
56
|
-
result.add_run
|
57
|
-
yield(Test::Unit::TestCase::FINISHED, name)
|
58
|
-
yield(Test::Unit::TestCase::FINISHED_OBJECT, self)
|
59
|
-
ensure
|
60
|
-
# @_result = nil # For test-spec's after_all :<
|
61
|
-
end
|
62
|
-
end
|
63
|
-
# rubocop:enable all
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,19 +0,0 @@
|
|
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
|
@@ -1,61 +0,0 @@
|
|
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 RubyVersion185AndBelow
|
9
|
-
def self.applicable_to?(test_unit_version, ruby_version)
|
10
|
-
Gem::Requirement.new('<= 1.2.3').satisfied_by?(test_unit_version) && Gem::Requirement.new('<= 1.8.5').satisfied_by?(ruby_version)
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.description
|
14
|
-
'monkey patch for standard library in Ruby <= v1.8.5'
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.included(mod)
|
18
|
-
MonkeyPatcher.apply(mod, RunMethodPatch)
|
19
|
-
end
|
20
|
-
|
21
|
-
module RunMethodPatch
|
22
|
-
# rubocop:disable all
|
23
|
-
def run(result)
|
24
|
-
assertion_counter = AssertionCounter.new(self)
|
25
|
-
yield(Test::Unit::TestCase::STARTED, name)
|
26
|
-
@_result = result
|
27
|
-
begin
|
28
|
-
begin
|
29
|
-
mocha_setup
|
30
|
-
setup
|
31
|
-
__send__(@method_name)
|
32
|
-
mocha_verify(assertion_counter)
|
33
|
-
rescue Mocha::ExpectationError => e
|
34
|
-
add_failure(e.message, e.backtrace)
|
35
|
-
rescue Test::Unit::AssertionFailedError => e
|
36
|
-
add_failure(e.message, e.backtrace)
|
37
|
-
rescue StandardError, ScriptError
|
38
|
-
add_error($!)
|
39
|
-
ensure
|
40
|
-
begin
|
41
|
-
teardown
|
42
|
-
rescue Mocha::ExpectationError => e
|
43
|
-
add_failure(e.message, e.backtrace)
|
44
|
-
rescue Test::Unit::AssertionFailedError => e
|
45
|
-
add_failure(e.message, e.backtrace)
|
46
|
-
rescue StandardError, ScriptError
|
47
|
-
add_error($!)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
ensure
|
51
|
-
mocha_teardown
|
52
|
-
end
|
53
|
-
result.add_run
|
54
|
-
yield(Test::Unit::TestCase::FINISHED, name)
|
55
|
-
end
|
56
|
-
# rubocop:enable all
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,63 +0,0 @@
|
|
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 RubyVersion186AndAbove
|
9
|
-
def self.applicable_to?(test_unit_version, ruby_version)
|
10
|
-
Gem::Requirement.new('<= 1.2.3').satisfied_by?(test_unit_version) && Gem::Requirement.new('>= 1.8.6').satisfied_by?(ruby_version)
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.description
|
14
|
-
'monkey patch for standard library Test::Unit in Ruby >= v1.8.6'
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.included(mod)
|
18
|
-
MonkeyPatcher.apply(mod, RunMethodPatch)
|
19
|
-
end
|
20
|
-
|
21
|
-
module RunMethodPatch
|
22
|
-
# rubocop:disable all
|
23
|
-
def run(result)
|
24
|
-
assertion_counter = AssertionCounter.new(self)
|
25
|
-
yield(Test::Unit::TestCase::STARTED, name)
|
26
|
-
@_result = result
|
27
|
-
begin
|
28
|
-
begin
|
29
|
-
mocha_setup
|
30
|
-
setup
|
31
|
-
__send__(@method_name)
|
32
|
-
mocha_verify(assertion_counter)
|
33
|
-
rescue Mocha::ExpectationError => e
|
34
|
-
add_failure(e.message, e.backtrace)
|
35
|
-
rescue Test::Unit::AssertionFailedError => e
|
36
|
-
add_failure(e.message, e.backtrace)
|
37
|
-
rescue Exception
|
38
|
-
raise if Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.include? $!.class
|
39
|
-
add_error($!)
|
40
|
-
ensure
|
41
|
-
begin
|
42
|
-
teardown
|
43
|
-
rescue Mocha::ExpectationError => e
|
44
|
-
add_failure(e.message, e.backtrace)
|
45
|
-
rescue Test::Unit::AssertionFailedError => e
|
46
|
-
add_failure(e.message, e.backtrace)
|
47
|
-
rescue Exception
|
48
|
-
raise if Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.include? $!.class
|
49
|
-
add_error($!)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
ensure
|
53
|
-
mocha_teardown
|
54
|
-
end
|
55
|
-
result.add_run
|
56
|
-
yield(Test::Unit::TestCase::FINISHED, name)
|
57
|
-
end
|
58
|
-
# rubocop:enable all
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
data/lib/mocha/integration.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'mocha/integration/test_unit'
|
2
|
-
require 'mocha/integration/mini_test'
|
3
|
-
|
4
|
-
module Mocha
|
5
|
-
module Integration
|
6
|
-
def self.activate
|
7
|
-
return unless [Integration::TestUnit, Integration::MiniTest].map(&:activate).none?
|
8
|
-
raise "Test::Unit or Minitest must be loaded *before* `require 'mocha/setup'`."
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
data/lib/mocha/setup.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'mocha/integration'
|
2
|
-
require 'mocha/deprecation'
|
3
|
-
|
4
|
-
Mocha::Deprecation.warning(
|
5
|
-
"Require 'mocha/test_unit', 'mocha/minitest' or 'mocha/api' instead of 'mocha/setup'."
|
6
|
-
)
|
7
|
-
|
8
|
-
module Mocha
|
9
|
-
def self.activate
|
10
|
-
Integration.activate
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
Mocha.activate
|