mocha 1.1.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/FUNDING.yml +1 -0
- data/.rubocop.yml +53 -0
- data/.rubocop_todo.yml +27 -0
- data/.yardopts +1 -1
- data/CONTRIBUTING.md +4 -9
- data/COPYING.md +2 -2
- data/Gemfile +27 -0
- data/MIT-LICENSE.md +1 -1
- data/README.md +120 -30
- data/RELEASE.md +393 -1
- data/Rakefile +61 -50
- data/gemfiles/Gemfile.minitest.latest +1 -0
- data/gemfiles/Gemfile.test-unit.latest +1 -0
- data/lib/mocha/any_instance_method.rb +9 -74
- data/lib/mocha/api.rb +85 -69
- data/lib/mocha/argument_iterator.rb +4 -8
- data/lib/mocha/backtrace_filter.rb +3 -7
- data/lib/mocha/block_matcher.rb +31 -0
- data/lib/mocha/cardinality.rb +60 -49
- data/lib/mocha/central.rb +21 -12
- data/lib/mocha/change_state_side_effect.rb +0 -4
- data/lib/mocha/class_methods.rb +19 -20
- data/lib/mocha/configuration.rb +317 -52
- data/lib/mocha/debug.rb +2 -4
- data/lib/mocha/deprecation.rb +8 -11
- data/lib/mocha/detection/mini_test.rb +0 -2
- data/lib/mocha/detection/test_unit.rb +3 -5
- data/lib/mocha/error_with_filtered_backtrace.rb +13 -0
- data/lib/mocha/exception_raiser.rb +4 -6
- data/lib/mocha/expectation.rb +186 -95
- data/lib/mocha/expectation_error.rb +1 -1
- data/lib/mocha/expectation_error_factory.rb +0 -1
- data/lib/mocha/expectation_list.rb +7 -11
- data/lib/mocha/hooks.rb +1 -3
- data/lib/mocha/in_state_ordering_constraint.rb +0 -4
- data/lib/mocha/inspect.rb +30 -38
- data/lib/mocha/instance_method.rb +11 -8
- data/lib/mocha/integration/mini_test/adapter.rb +3 -5
- data/lib/mocha/integration/mini_test/exception_translation.rb +1 -1
- data/lib/mocha/integration/mini_test.rb +10 -31
- data/lib/mocha/integration/monkey_patcher.rb +8 -2
- data/lib/mocha/integration/test_unit/adapter.rb +8 -9
- data/lib/mocha/integration/test_unit.rb +10 -26
- data/lib/mocha/invocation.rb +73 -0
- data/lib/mocha/is_a.rb +0 -2
- data/lib/mocha/logger.rb +0 -4
- data/lib/mocha/macos_version.rb +5 -0
- data/lib/mocha/method_matcher.rb +1 -5
- data/lib/mocha/minitest.rb +6 -0
- data/lib/mocha/mock.rb +105 -57
- data/lib/mocha/mockery.rb +70 -98
- data/lib/mocha/names.rb +2 -12
- data/lib/mocha/not_initialized_error.rb +7 -0
- data/lib/mocha/object_methods.rb +25 -31
- data/lib/mocha/parameter_matchers/all_of.rb +2 -8
- data/lib/mocha/parameter_matchers/any_of.rb +2 -8
- data/lib/mocha/parameter_matchers/any_parameters.rb +3 -9
- data/lib/mocha/parameter_matchers/anything.rb +2 -8
- data/lib/mocha/parameter_matchers/base.rb +7 -13
- data/lib/mocha/parameter_matchers/equals.rb +1 -7
- data/lib/mocha/parameter_matchers/{query_string.rb → equivalent_uri.rb} +14 -15
- data/lib/mocha/parameter_matchers/has_entries.rb +2 -7
- data/lib/mocha/parameter_matchers/has_entry.rb +26 -21
- data/lib/mocha/parameter_matchers/has_key.rb +2 -7
- data/lib/mocha/parameter_matchers/has_keys.rb +53 -0
- data/lib/mocha/parameter_matchers/has_value.rb +2 -7
- data/lib/mocha/parameter_matchers/includes.rb +50 -8
- data/lib/mocha/parameter_matchers/instance_methods.rb +27 -0
- data/lib/mocha/parameter_matchers/instance_of.rb +0 -6
- data/lib/mocha/parameter_matchers/is_a.rb +2 -7
- data/lib/mocha/parameter_matchers/kind_of.rb +2 -6
- data/lib/mocha/parameter_matchers/not.rb +2 -7
- data/lib/mocha/parameter_matchers/optionally.rb +4 -10
- data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +64 -0
- data/lib/mocha/parameter_matchers/regexp_matches.rb +0 -6
- data/lib/mocha/parameter_matchers/responds_with.rb +3 -8
- data/lib/mocha/parameter_matchers/yaml_equivalent.rb +2 -6
- data/lib/mocha/parameter_matchers.rb +3 -4
- data/lib/mocha/parameters_matcher.rb +8 -11
- data/lib/mocha/raised_exception.rb +11 -0
- data/lib/mocha/receivers.rb +10 -14
- data/lib/mocha/return_values.rb +4 -8
- data/lib/mocha/ruby_version.rb +3 -0
- data/lib/mocha/sequence.rb +4 -9
- data/lib/mocha/single_return_value.rb +2 -5
- data/lib/mocha/state_machine.rb +33 -46
- data/lib/mocha/stubbed_method.rb +88 -0
- data/lib/mocha/stubbing_error.rb +2 -13
- data/lib/mocha/test_unit.rb +5 -2
- data/lib/mocha/thrower.rb +4 -6
- data/lib/mocha/thrown_object.rb +12 -0
- data/lib/mocha/version.rb +1 -1
- data/lib/mocha/yield_parameters.rb +7 -17
- data/mocha.gemspec +16 -43
- metadata +38 -248
- data/bin/build-matrix +0 -71
- 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.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 -3
- data/lib/mocha/class_method.rb +0 -127
- data/lib/mocha/integration/mini_test/nothing.rb +0 -19
- data/lib/mocha/integration/mini_test/version_13.rb +0 -51
- data/lib/mocha/integration/mini_test/version_140.rb +0 -51
- data/lib/mocha/integration/mini_test/version_141.rb +0 -62
- data/lib/mocha/integration/mini_test/version_142_to_172.rb +0 -62
- data/lib/mocha/integration/mini_test/version_200.rb +0 -63
- data/lib/mocha/integration/mini_test/version_201_to_222.rb +0 -63
- data/lib/mocha/integration/mini_test/version_2110_to_2111.rb +0 -67
- data/lib/mocha/integration/mini_test/version_2112_to_320.rb +0 -70
- data/lib/mocha/integration/mini_test/version_230_to_2101.rb +0 -65
- data/lib/mocha/integration/test_unit/gem_version_200.rb +0 -59
- data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +0 -59
- data/lib/mocha/integration/test_unit/gem_version_203_to_220.rb +0 -59
- data/lib/mocha/integration/test_unit/gem_version_230_to_250.rb +0 -65
- data/lib/mocha/integration/test_unit/nothing.rb +0 -19
- data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +0 -58
- data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +0 -60
- data/lib/mocha/integration.rb +0 -14
- data/lib/mocha/mini_test.rb +0 -3
- data/lib/mocha/module_method.rb +0 -16
- data/lib/mocha/module_methods.rb +0 -14
- data/lib/mocha/multiple_yields.rb +0 -20
- data/lib/mocha/no_yields.rb +0 -11
- data/lib/mocha/parameter_matchers/object.rb +0 -17
- data/lib/mocha/pretty_parameters.rb +0 -28
- data/lib/mocha/setup.rb +0 -9
- data/lib/mocha/single_yield.rb +0 -18
- data/lib/mocha/standalone.rb +0 -4
- data/lib/mocha/unexpected_invocation.rb +0 -26
- data/lib/mocha_standalone.rb +0 -4
- data/test/acceptance/acceptance_test_helper.rb +0 -41
- data/test/acceptance/bug_18914_test.rb +0 -43
- data/test/acceptance/bug_21465_test.rb +0 -34
- data/test/acceptance/bug_21563_test.rb +0 -25
- data/test/acceptance/exception_rescue_test.rb +0 -55
- data/test/acceptance/expectations_on_multiple_methods_test.rb +0 -55
- data/test/acceptance/expected_invocation_count_test.rb +0 -232
- data/test/acceptance/failure_messages_test.rb +0 -64
- data/test/acceptance/issue_65_test.rb +0 -63
- data/test/acceptance/issue_70_test.rb +0 -55
- data/test/acceptance/mocha_example_test.rb +0 -98
- data/test/acceptance/mocha_test_result_test.rb +0 -84
- data/test/acceptance/mock_test.rb +0 -100
- data/test/acceptance/mock_with_initializer_block_test.rb +0 -51
- data/test/acceptance/mocked_methods_dispatch_test.rb +0 -78
- data/test/acceptance/multiple_expectations_failure_message_test.rb +0 -68
- data/test/acceptance/optional_parameters_test.rb +0 -70
- data/test/acceptance/parameter_matcher_test.rb +0 -337
- data/test/acceptance/partial_mocks_test.rb +0 -47
- data/test/acceptance/prepend_test.rb +0 -88
- data/test/acceptance/raise_exception_test.rb +0 -39
- data/test/acceptance/return_value_test.rb +0 -52
- data/test/acceptance/sequence_test.rb +0 -192
- data/test/acceptance/states_test.rb +0 -70
- data/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb +0 -34
- data/test/acceptance/stub_any_instance_method_test.rb +0 -238
- data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +0 -106
- 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 -75
- data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +0 -112
- data/test/acceptance/stub_everything_test.rb +0 -56
- data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +0 -93
- data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +0 -69
- data/test/acceptance/stub_instance_method_defined_on_class_test.rb +0 -69
- data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +0 -75
- data/test/acceptance/stub_instance_method_defined_on_module_test.rb +0 -75
- 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 -70
- data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +0 -72
- data/test/acceptance/stub_module_method_test.rb +0 -163
- data/test/acceptance/stub_test.rb +0 -52
- data/test/acceptance/stubba_example_test.rb +0 -102
- data/test/acceptance/stubba_test_result_test.rb +0 -66
- data/test/acceptance/stubbing_error_backtrace_test.rb +0 -64
- data/test/acceptance/stubbing_frozen_object_test.rb +0 -88
- data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +0 -48
- data/test/acceptance/stubbing_method_unnecessarily_test.rb +0 -65
- data/test/acceptance/stubbing_nil_test.rb +0 -59
- data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +0 -130
- data/test/acceptance/stubbing_non_existent_class_method_test.rb +0 -157
- data/test/acceptance/stubbing_non_existent_instance_method_test.rb +0 -147
- data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +0 -130
- data/test/acceptance/stubbing_non_public_class_method_test.rb +0 -163
- data/test/acceptance/stubbing_non_public_instance_method_test.rb +0 -143
- data/test/acceptance/stubbing_on_non_mock_object_test.rb +0 -64
- data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +0 -35
- data/test/acceptance/throw_test.rb +0 -45
- data/test/acceptance/unexpected_invocation_test.rb +0 -25
- data/test/acceptance/unstubbing_test.rb +0 -168
- data/test/assertions.rb +0 -6
- 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 -174
- data/test/integration/test_unit_test.rb +0 -8
- data/test/method_definer.rb +0 -24
- data/test/mini_test_result.rb +0 -90
- data/test/minitest_result.rb +0 -49
- data/test/simple_counter.rb +0 -13
- data/test/test_helper.rb +0 -50
- data/test/test_runner.rb +0 -58
- data/test/test_unit_result.rb +0 -20
- data/test/unit/any_instance_method_test.rb +0 -132
- data/test/unit/array_inspect_test.rb +0 -16
- data/test/unit/backtrace_filter_test.rb +0 -19
- data/test/unit/cardinality_test.rb +0 -56
- data/test/unit/central_test.rb +0 -100
- data/test/unit/change_state_side_effect_test.rb +0 -41
- data/test/unit/class_method_test.rb +0 -223
- data/test/unit/class_methods_test.rb +0 -40
- data/test/unit/configuration_test.rb +0 -38
- data/test/unit/date_time_inspect_test.rb +0 -21
- data/test/unit/exception_raiser_test.rb +0 -42
- data/test/unit/expectation_list_test.rb +0 -82
- data/test/unit/expectation_test.rb +0 -497
- data/test/unit/hash_inspect_test.rb +0 -16
- data/test/unit/hooks_test.rb +0 -29
- data/test/unit/in_state_ordering_constraint_test.rb +0 -43
- data/test/unit/method_matcher_test.rb +0 -28
- data/test/unit/mock_test.rb +0 -341
- data/test/unit/mockery_test.rb +0 -151
- data/test/unit/module_methods_test.rb +0 -19
- data/test/unit/multiple_yields_test.rb +0 -18
- data/test/unit/no_yields_test.rb +0 -18
- data/test/unit/object_inspect_test.rb +0 -38
- data/test/unit/object_methods_test.rb +0 -46
- data/test/unit/parameter_matchers/all_of_test.rb +0 -26
- data/test/unit/parameter_matchers/any_of_test.rb +0 -26
- data/test/unit/parameter_matchers/anything_test.rb +0 -21
- data/test/unit/parameter_matchers/equals_test.rb +0 -25
- data/test/unit/parameter_matchers/has_entries_test.rb +0 -51
- data/test/unit/parameter_matchers/has_entry_test.rb +0 -129
- data/test/unit/parameter_matchers/has_key_test.rb +0 -55
- data/test/unit/parameter_matchers/has_value_test.rb +0 -57
- data/test/unit/parameter_matchers/includes_test.rb +0 -59
- data/test/unit/parameter_matchers/instance_of_test.rb +0 -25
- data/test/unit/parameter_matchers/is_a_test.rb +0 -25
- data/test/unit/parameter_matchers/kind_of_test.rb +0 -25
- data/test/unit/parameter_matchers/not_test.rb +0 -26
- data/test/unit/parameter_matchers/regexp_matches_test.rb +0 -46
- data/test/unit/parameter_matchers/responds_with_test.rb +0 -32
- data/test/unit/parameter_matchers/stub_matcher.rb +0 -27
- data/test/unit/parameter_matchers/yaml_equivalent_test.rb +0 -25
- data/test/unit/parameters_matcher_test.rb +0 -121
- data/test/unit/receivers_test.rb +0 -66
- data/test/unit/return_values_test.rb +0 -63
- data/test/unit/sequence_test.rb +0 -104
- data/test/unit/single_return_value_test.rb +0 -14
- data/test/unit/single_yield_test.rb +0 -18
- data/test/unit/state_machine_test.rb +0 -98
- data/test/unit/string_inspect_test.rb +0 -11
- data/test/unit/thrower_test.rb +0 -20
- data/test/unit/yield_parameters_test.rb +0 -93
- data/yard-templates/default/layout/html/google_analytics.erb +0 -11
- data/yard-templates/default/layout/html/setup.rb +0 -6
data/RELEASE.md
CHANGED
@@ -1,5 +1,397 @@
|
|
1
1
|
# Release Notes
|
2
2
|
|
3
|
+
## 2.1.0
|
4
|
+
|
5
|
+
### External changes
|
6
|
+
|
7
|
+
* Fix compatibility with Minitest (#614) - thanks to @kyrofa & @manewitz for reporting and to @zenspider for his input
|
8
|
+
|
9
|
+
### Internal changes
|
10
|
+
|
11
|
+
* Update URLs for links to Ruby & MIT licenses (d6470af4)
|
12
|
+
|
13
|
+
## 2.0.4
|
14
|
+
|
15
|
+
### Internal changes
|
16
|
+
|
17
|
+
* Update `README.md` (e8c21e1b)
|
18
|
+
|
19
|
+
## 2.0.3
|
20
|
+
|
21
|
+
### External changes
|
22
|
+
|
23
|
+
* Fix `BacktraceFilter` to handle special characters (e242033f, #592) - thanks to @casperisfine
|
24
|
+
|
25
|
+
### Internal changes
|
26
|
+
|
27
|
+
* Add Ruby v3.1 to the CircleCI build (3e460489)
|
28
|
+
* DRY up `regexp_matches` test (ae9fed4a)
|
29
|
+
* Fix regexp_matches tests in Ruby v3.2 (26b106a5, #590)
|
30
|
+
* Use Ruby 1.9 hash syntax (8bc0ad2f, #598, #537) - thanks to @herwinw
|
31
|
+
* Simplify storage of `MOCHA_OPTIONS` (b70507a1, #600) - thanks to @herwinw
|
32
|
+
* Pin JRuby to v9.3.9.0 in CircleCI builds (b8e6d064, #591)
|
33
|
+
* Rubocop: enable Style/FormatStringToken cop (089a688e, #603) - thanks to @herwinw
|
34
|
+
* Remove Ruby version check from `RespondsLikeTest` (21583129)
|
35
|
+
* Add Ruby v3.2 to CircleCI build (f7e17636, #601)
|
36
|
+
* Use Ruby v2.6 vs v2.2 to run lint CI job (af40b7db)
|
37
|
+
* Pin yard version to v0.9.28 to avoid `ArgumentError` (12f1eef7)
|
38
|
+
* Revert "Pin JRuby to v9.3.9.0 in CircleCI builds" (4f5bb2f0, #591)
|
39
|
+
* Remove invalid CircleCI token from badge URL (7078e76a)
|
40
|
+
* Revert "Pin yard version to v0.9.28 to avoid ArgumentError" (7c6c10c5, #609)
|
41
|
+
* Remove Google Analytics tracking code (2279c49d, #612)
|
42
|
+
* Update `MIT-LICENSE.md` (48162b4e)
|
43
|
+
* Update `COPYING.md` (f3152376)
|
44
|
+
|
45
|
+
## 2.0.2
|
46
|
+
|
47
|
+
### External changes
|
48
|
+
|
49
|
+
* Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,ba4d619e)
|
50
|
+
|
51
|
+
## 2.0.1
|
52
|
+
|
53
|
+
### External changes
|
54
|
+
|
55
|
+
* Fix `LoadError` when using v2.0.0 with Ruby < v2.7 by moving declaration of runtime dependency on `ruby2_keywords` gem from `Gemfile` to `mocha.gemspec` - thanks to @mishina2228 for reporting (#581, #582, cdeb0356)
|
56
|
+
|
57
|
+
## 2.0.0
|
58
|
+
|
59
|
+
### External changes
|
60
|
+
|
61
|
+
* Remove support for Ruby v1.9 - thanks to @wasabigeek (#552)
|
62
|
+
* Support strict keyword argument matching - see docs for `Expectation#with` & `Configuration#strict_keyword_argument_matching=` - thanks to @wasabigeek (#446,#535,#544,#562)
|
63
|
+
* Deprecate `Hash` args that don't strictly match (#563,981c31be)
|
64
|
+
* Drop support for older versions of test-unit - gem versions of test-unit earlier than v2.5.1 and versions of test-unit
|
65
|
+
from the Ruby v1.8 standard library are no longer supported (#540,969f4845)
|
66
|
+
* Drop support for older versions of minitest - versions of minitest earlier than v3.3.0 are no longer supported (#541,ca69dc9e)
|
67
|
+
* Remove deprecated `mocha/setup.rb` mechanism (642a0ff4)
|
68
|
+
* Add missing docs for `API#stub` parameter (257b4cb4)
|
69
|
+
* Remove optional reinstatement of v1.9 behaviour (#436,#438,#569,1473ee25)
|
70
|
+
* Remove deprecated methods in `Configuration` (#421,e7ff7528)
|
71
|
+
* Fail fast when mock receives invocations in another test (#440,#442,cb054d59)
|
72
|
+
* Improve docs re using matchers in `Expectation#with` (da7237cd)
|
73
|
+
* Expand `Expectation#with` docs re keyword arguments (fed6808d)
|
74
|
+
* Improve docs for `strict_keyword_argument_matching` (8d8f881d)
|
75
|
+
* Remove deprecated Rails plugin `init.rb` file (1c617175)
|
76
|
+
* Improve strict keyword argument matching deprecation warning by including the source location of the stub definition (77c0d4cc)
|
77
|
+
* Add README section re semantic versioning (00758246)
|
78
|
+
|
79
|
+
### Internal changes
|
80
|
+
|
81
|
+
* Separate linting from tests in terms of Rake tasks & CircleCI jobs - thanks to @wasabigeek (#556)
|
82
|
+
* Remove tests specific to Ruby v1.8 behaviour (46fca7ac, 3b369e99)
|
83
|
+
* Multi-line rubocop disable in `Mock#method_missing` (af2194c4)
|
84
|
+
* Remove unused arg for `HashMethods#mocha_inspect` (4f59e27f)
|
85
|
+
* Improve test runner assertions - failure vs error (eec7200a)
|
86
|
+
* Improve test coverage of `PositionalOrKeywordHash` (c294fe70)
|
87
|
+
* More consistent Test::Unit & Minitest integration (27dd3817)
|
88
|
+
* Remove redundant `require` statements (d82218a8,fa17b114)
|
89
|
+
* Add missing `require` statement (73493761)
|
90
|
+
* Disable Style/Semicolon cop globally (8cd0b705)
|
91
|
+
|
92
|
+
## 1.16.1
|
93
|
+
|
94
|
+
### External changes
|
95
|
+
|
96
|
+
* Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,77af2af1)
|
97
|
+
|
98
|
+
## 1.16.0
|
99
|
+
|
100
|
+
### External changes
|
101
|
+
|
102
|
+
* Default `Configuration#reinstate_undocumented_behaviour_from_v1_9=` to `false` (6fcaf947)
|
103
|
+
* Deprecate `Configuration#reinstate_undocumented_behaviour_from_v1_9=` (a797c5fd)
|
104
|
+
|
105
|
+
### Internal changes
|
106
|
+
|
107
|
+
* Remove redundant deprecation disabling in MockTest (dc8ca969)
|
108
|
+
|
109
|
+
## 1.15.1
|
110
|
+
|
111
|
+
### External changes
|
112
|
+
|
113
|
+
* Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,c586a08c)
|
114
|
+
|
115
|
+
## 1.15.0
|
116
|
+
|
117
|
+
### External changes
|
118
|
+
|
119
|
+
* Fix examples using mock constructor with block (1cc17667)
|
120
|
+
* Add another example for `API#sequence` (b7a7d233, #59)
|
121
|
+
* Remove support for Ruby v1.8 (ddb5d672)
|
122
|
+
* Deprecate support for Ruby versions earlier than v2.0 - thanks to @wasabigeek (#553, #555)
|
123
|
+
|
124
|
+
### Internal changes
|
125
|
+
|
126
|
+
* Update instructions for obtaining Rubygems API key (ed9c040a)
|
127
|
+
* Consistent definitions for `respond_to?` methods (#533)
|
128
|
+
* Run test tasks before release tasks (92a1bc6e, #447)
|
129
|
+
* Fix test:performance Rake task (#538, #539)
|
130
|
+
* Tidying following removal of support for Ruby v1.8 - thanks to @nitishr (#542)
|
131
|
+
* Remove `ParametersMatcher` from `Invocation#call_description` - thanks to @wasabigeek (#543)
|
132
|
+
* Remove unnecessary splatting in Invocation - thanks to @wasabigeek (#549)
|
133
|
+
* Extract `handle_method_call` from `method_missing` - thanks to @wasabigeek (#550)
|
134
|
+
|
135
|
+
## 1.14.0
|
136
|
+
|
137
|
+
### External changes
|
138
|
+
|
139
|
+
* Mock#expects,#stubs should return last expectation - thanks to @vlad-pisanov for #524 (b6b637db)
|
140
|
+
|
141
|
+
### Internal changes
|
142
|
+
|
143
|
+
* Avoid breaking change in psych v4 in ruby v3.1 (08b9f4ca)
|
144
|
+
* Remove broken Dependabot badge from README (d446657a)
|
145
|
+
* Add Ruby 3.0 to the CI matrix - thanks to @mishina2228 for #526 (65bc626e)
|
146
|
+
* Move development dependencies from gemspec to Gemfile - thanks to @mishina2228 for #527 (dd127f7b)
|
147
|
+
|
148
|
+
## 1.13.0
|
149
|
+
|
150
|
+
### External changes
|
151
|
+
|
152
|
+
* Add `ParameterMatchers#has_keys` - thanks to @cstyles for #512 (18d8104)
|
153
|
+
* Fix misleading exception message in `ParameterMatchers#has_entry` - thanks to @cstyles for #513 (9c4ef13)
|
154
|
+
* Only add dependency on rubocop if we're actually going to use it (f2f879f)
|
155
|
+
* Fix rake dependency constraints for older Ruby versions (7ce5f29)
|
156
|
+
|
157
|
+
### Internal changes
|
158
|
+
|
159
|
+
* Check documentation can be generated as part of CircleCI build (b30d9a9)
|
160
|
+
* Add --fail-on-warning option to yard rake task (53a6ee3)
|
161
|
+
* Add a weekly scheduled build to the CircleCI build (fd2a4c6)
|
162
|
+
* Add Ruby v1.8 to the CircleCI build matrix (818ca03)
|
163
|
+
* Add API token to fix CircleCI badge in README (607c5aa)
|
164
|
+
* Provide wrapped option for #mocha_inspect on hashes & arrays (d8f44bc)
|
165
|
+
* Use CircleCI instead of TravisCI for automated builds (c98c6ec)
|
166
|
+
* Switch to newer default Travis CI build env (c78f75c)
|
167
|
+
* Use latest Ruby versions in Travis CI builds (9e0043a)
|
168
|
+
* Use latest JRuby v9.2.18 in Travis CI builds (8c99a1b)
|
169
|
+
* Use consistent JRuby versions in Travis CI builds (0f849aa)
|
170
|
+
* Use more recent version of JRuby in Travis CI build matrix (58653db)
|
171
|
+
|
172
|
+
## 1.12.0
|
173
|
+
|
174
|
+
### External changes
|
175
|
+
|
176
|
+
* Various improvements to README inspired by #207 and #390 - thanks to @nitishr for his work on #390 (fed0eee6)
|
177
|
+
* Improve documentation related to `StateMachine` classes - thanks to @nitishr (#425 & #427)
|
178
|
+
* Fix regression in cardinality introduced in v1.10.0 (59454a8) and reported in #473 - thanks to @srvance for reporting and @nitishr for fixing (#474)
|
179
|
+
* Fix documentation for `Mocha::Expectation#when` - thanks to @olleolleolle (b4f59daa & #477)
|
180
|
+
* Remove `Mocha::Mock#respond_to?` from documentation - thanks to @nitishr (#480)
|
181
|
+
* Improvements to documentation for `Expectation#yields` & `#multiple_yields` - thanks to @andyw8 for reporting in #495 (1b6571c)
|
182
|
+
* Remove documentation & tests from gem to reduce its size by over 50% - thanks to @gabetax (#500)
|
183
|
+
* Update documentation to point to travis-ci.com instead of travis-ci.org
|
184
|
+
|
185
|
+
### Internal changes
|
186
|
+
|
187
|
+
* Refactor `StateMachine`-related classes - thanks to @nitishr (#425 & #427)
|
188
|
+
* Remove redundant test - thanks to @nitishr (8e4f1a7c)
|
189
|
+
* Add Ruby 2.7 to Travis CI matrix - thanks to @bastelfreak (fc5ea2f2)
|
190
|
+
* Simplify `Mockery` - thanks to @nitishr (#449)
|
191
|
+
* Update Travis CI badge to point to main vs master branch (bd8028f8)
|
192
|
+
* Generate docs using newer version of yard (v0.9.25) (c619afac)
|
193
|
+
* Manually upgrade jquery in docs from v1.7.1 -> v1.9.0 to fix CVE-2017-16011 (211098a5, dd5eeedb & 1b76e4d5; also see #492)
|
194
|
+
* Remove reference to non-existent jquery source map to fix error in Chrome developer tools (20156555)
|
195
|
+
* Temporarily ignore Ruby v1.8.7 build failures (e5b9feef)
|
196
|
+
|
197
|
+
## 1.11.2
|
198
|
+
|
199
|
+
### External changes
|
200
|
+
|
201
|
+
* Fix regression introduced in v1.10.0 that meant `Object#inspect` was called unnecessarily (368abd98)
|
202
|
+
* Warn when mock object receives invocations in another test - thanks to @nitishr (#442)
|
203
|
+
* Avoid rubocop comments appearing in YARD-generated docs (d8019eed)
|
204
|
+
|
205
|
+
### Internal changes
|
206
|
+
|
207
|
+
* Replace `StubbedMethod#original_method` & `#original_visibility` attribute reader methods with instance variables - thanks to @nitishr (d917f332)
|
208
|
+
* Set up `MochaExampleTest` & `StubbaExampleTest` as acceptance tests - thanks to @nitishr (4881cc58)
|
209
|
+
* Delete unused `PrettyParameters` class - thanks to @nitishr (314ea922)
|
210
|
+
|
211
|
+
## 1.11.1
|
212
|
+
|
213
|
+
### External changes
|
214
|
+
|
215
|
+
* The `reinstate_undocumented_behaviour_from_v1_9` configuration option is now enabled by default to give people a chance to see and fix the relevant deprecation warnings before the behaviour is removed in a future release (b91b1c9e)
|
216
|
+
|
217
|
+
## 1.11.0
|
218
|
+
|
219
|
+
### External changes
|
220
|
+
|
221
|
+
* Add `Expectation#with_block_given` & `Expectation#with_no_block_given` (#441).
|
222
|
+
* Allows non-deprecated solution for #382. Thanks to @yemartin for reporting and to @techbelly & @nitishr for feedback.
|
223
|
+
* Fix issue with non-Array arguments passed to `Expectation#multiple_yields` (#444).
|
224
|
+
* The undocumented behaviour is now properly supported and documented.
|
225
|
+
|
226
|
+
### Internal changes
|
227
|
+
|
228
|
+
* Move static YARD options from Rake task to `.yardopts` file - thanks to @nitishr (#429)
|
229
|
+
* Simplify implementation of yielding functionality - thanks to @nitishr (#439)
|
230
|
+
* Add missing require statement to `acceptance_test_helper.rb` (1070fc02)
|
231
|
+
* Add some baseline acceptance tests for yielding behaviour (c2cac911)
|
232
|
+
* Display a sponsor button on GitHub repo page (9fc5911b)
|
233
|
+
* Use new Deprecation.warning behaviour in `Invocation#call` (932d1166)
|
234
|
+
|
235
|
+
## 1.10.2
|
236
|
+
|
237
|
+
* Optionally reinstate undocumented behaviour from v1.9. This introduces a new configuration option (`reinstate_undocumented_behaviour_from_v1_9`) to reinstate a couple of bits of undocumented behaviour from v1.9 which were changed in v1.10 without any prior deprecation warning (#438):
|
238
|
+
* The behaviour of `API#mock`, `API#stub` and `API#stub_everything` when called with a symbol as the first argument.
|
239
|
+
* The behaviour of `Expectation#yields` and `Expectation#multiple_yields` when the stubbed method is called without a block.
|
240
|
+
|
241
|
+
## 1.10.1
|
242
|
+
|
243
|
+
* Ensure ObjectMethods & ClassMethods included when API extended (43778756)
|
244
|
+
* Fix regression in `any_instance` stubbing of methods on object which has an implementation of `#respond_to?` that depends on the object's internal state - thanks to @rafaelfranca for reporting & @nitishr for fixing (#432, #434, 469d4b17)
|
245
|
+
|
246
|
+
## 1.10.0
|
247
|
+
|
248
|
+
* Improve deprecation warning when requiring 'mocha/setup' (388f44d7)
|
249
|
+
* Add documentation for Cucumber integration (13ab797b)
|
250
|
+
* Add documentation about an undocumented feature of `API#mock`, `API#stub` & `API#stub_everything` being changed (7ed2e4e7, d30c1717)
|
251
|
+
|
252
|
+
## 1.10.0.beta.1
|
253
|
+
|
254
|
+
* Hide `ClassMethods#method_visibility` & `#method_exists?` methods to avoid clash with Rails (#428)
|
255
|
+
|
256
|
+
## 1.10.0.alpha
|
257
|
+
|
258
|
+
### External changes
|
259
|
+
|
260
|
+
* Remove dependency on metaclass gem (#49, #365)
|
261
|
+
* Accept symbol (as well as a string) as mock/stub name - thanks to @nitishr (#347, #353, #377)
|
262
|
+
* More realistic examples in documentation for `Expectation#yields` and `#multiple_yields` - thanks to @nitishr (#352, #383)
|
263
|
+
* Improve documentation for `Mock#responds_like` & `#responds_like_instance_of` - thanks to @nitishr (#337, #384)
|
264
|
+
* Make `Expectation#yields` & `Expectation#multiple_yields` fail when the caller of the stubbed method does not provide a block. This is a change to an undocumented aspect of the public API's behaviour. If this causes your tests to fail, then fix it by removing the unnecessary call to `Expectation#yields` or `Expectation#multiple_yields` - thanks to @nitishr (#382)
|
265
|
+
* Document `MOCHA_OPTIONS` in README - thanks to @nitishr (#311, #386)
|
266
|
+
* Add documentation to explain how Mocha is intended to be used - thanks to @nitishr (#330, #385)
|
267
|
+
* Deprecation warning if integration using 'mocha/test_unit' or 'mocha/minitest' fails - thanks to @nitishr (#229, #389, c6032d0b)
|
268
|
+
* Require at least one specified sequence for `Expectation#in_sequence` - thanks to @nitishr (#79, #396, 9020248a)
|
269
|
+
* Make signatures of `Mock#unstub` & `ObjectMethods#unstub` consistent - thanks to @nitishr (#397, f04d437)
|
270
|
+
* Deprecate requiring 'mocha/setup' (36adf880)
|
271
|
+
* Optionally display matching invocations alongside expectations - thanks to @nitishr (#178, #394, 00f0540, #410)
|
272
|
+
* Put deprecations into effect (#400, #418):
|
273
|
+
* Remove deprecated 'mocha_standalone.rb' & 'mocha/standalone.rb'
|
274
|
+
* Fail fast if no test library loaded
|
275
|
+
* Removed optional block for `Mocha::API#mock`, `#stub` & `#stub_everything`
|
276
|
+
* Remove deprecated `ParameterMatchers#has_equivalent_query_string` method
|
277
|
+
* Remove deprecated 'mocha/mini_test.rb'
|
278
|
+
* Fix typo in docs for `Mocha::Configuration.prevent` (266ce71c)
|
279
|
+
* New-style configuration (see documentation for `Mocha::Configuration`) (#407, #421)
|
280
|
+
* Deprecate support for Ruby versions earlier than v1.9 (#325, c5f8496d)
|
281
|
+
* Deprecate support for versions of test-unit & minitest which need monkey-patching (a34e1a88)
|
282
|
+
* Deprecate old-style Rails plugin (#403, 2df77134)
|
283
|
+
* Documentation fixes & improvements which also fix YARD warnings (472d5416, a2c0d64a)
|
284
|
+
|
285
|
+
### Internal changes
|
286
|
+
|
287
|
+
* Pin minitest to v5.11.3 for Ruby v1.8.7 to fix build; minitest no longer supports Ruby v1.8.7 (4a0a580)
|
288
|
+
* Upgrade JRuby to v9.2.8.0 in Travis CI builds (aa29b3f)
|
289
|
+
* Only run rubocop for MRI Ruby versions & non-integration test builds (8f1c6af)
|
290
|
+
* Reduce duplication in any instance method class - thanks to @nitishr (#378)
|
291
|
+
* Simplify `AnyInstanceMethod`, `ClassMethod`, `InstanceMethod`, `ModuleMethod` class hierarchy - thanks to @nitishr (#381)
|
292
|
+
* Simplify `ClassMethods#method_exists?` & `ObjectMethods#method_exists?` making them consistent - thanks to @nitishr (#270, #362, #370)
|
293
|
+
* Don't override definition of `singleton_class` in `ClassMethods` - thanks to @nitishr (#391, #392)
|
294
|
+
* Do not include 'method_definer' methods into all objects (#268, #402)
|
295
|
+
* Distinguish different `ObjectMethods` modules (#268, #404)
|
296
|
+
* Pass invocation to expectation list methods - thanks to @nitishr (#408, #409, #411)
|
297
|
+
* Consistently use `assert_raises` - thanks to @nitishr (#405, #412, a66b7bed)
|
298
|
+
* Update Ruby & JRuby versions in Travis CI config (18cb1a93, eb061c53)
|
299
|
+
* Rubocop improvements (aa16ea67...6f4db70b, 2a1240e6...e95716ae)
|
300
|
+
* Fix inconsistency in CardinalityTest (aa10e0a8)
|
301
|
+
* Fix test failures on Mac OSX Catalina - thanks to @nitishr (#413, #417, #419, 8a0f2535)
|
302
|
+
* Remove default argument in `Expectation#invoke` - thanks to @nitishr (#414, #420)
|
303
|
+
|
304
|
+
## 1.9.0
|
305
|
+
|
306
|
+
* Add TruffleRuby to Travis CI build matrix - thanks to @deepj (#354)
|
307
|
+
* Explicitly set Travis CI OS to Ubuntu Trusty 14.04 (ded1fa45)
|
308
|
+
* Expand explanation of thread-safety concerns - thanks to @techbelly (#357)
|
309
|
+
* Refactor class method and any instance method - thanks to @chrisroos (#358)
|
310
|
+
* Rely on default bundler version in Travis CI builds (3352e9c5)
|
311
|
+
* Fix local build-matrix script (11abe231)
|
312
|
+
* No need to install latest bundler in build-matrix script (8247a894)
|
313
|
+
|
314
|
+
## 1.8.0
|
315
|
+
|
316
|
+
* Constrain rubocop version to avoid breaking Travis CI builds (05e507f5)
|
317
|
+
* Avoid calling Kernel#format from ObjectMethods#mocha_inspect - thanks to @hoffmanilya (#345)
|
318
|
+
* Fix build matrix script (#346)
|
319
|
+
* Avoid deprecation warning in gemspec (4976e0bc)
|
320
|
+
* Removed link to documentation translation (ef428ea2)
|
321
|
+
* Don't use the new bundler v2 in builds (683ded9b)
|
322
|
+
* Moved documentation from https://gofreerange.com/mocha/docs to https://mocha.jamesmead.org/ [683ded...a17fde](https://github.com/freerange/mocha/compare/683ded...a17fde)
|
323
|
+
|
324
|
+
## 1.7.0
|
325
|
+
|
326
|
+
* Update Ruby & JRuby versions in Travis CI config (9bf55631 & 3883af7e)
|
327
|
+
* Simplify gemspec (63744f86)
|
328
|
+
* Add rubocop and fix most cop violations (#341)
|
329
|
+
* Use Kernel#warn for deprecations - thanks to @etiennebarrie (#333, 196970a)
|
330
|
+
|
331
|
+
## 1.6.0
|
332
|
+
|
333
|
+
* Fix subtle bug in setting correct visibility of stubbed module methods on `Kernel` or `Object` - thanks to @chrisroos (#295)
|
334
|
+
* Avoid mocks for partial mocking leaking into subsequent tests - thanks to @skliew for reporting (#331)
|
335
|
+
* Remove OpenCollective badge, backers & sponsors (a283a079)
|
336
|
+
* Change gem version badge to SVG format and add SemVer stability badge - thanks to @greysteil (#335)
|
337
|
+
* Improve documentation for Configuration (#236)
|
338
|
+
|
339
|
+
## 1.5.0
|
340
|
+
|
341
|
+
* Prevent use of Mocha outside the context of a test/example - thanks to @andyw8 & @lzap (#327)
|
342
|
+
|
343
|
+
## 1.4.0
|
344
|
+
|
345
|
+
* Fix deprecation warning for `assert_nil` in `ClassMethodTest` (#308 & #309)
|
346
|
+
* Display file and line number in deprecation warning - thanks to @chrisarcand (#310, #312 & #313)
|
347
|
+
* Rename `mocha/mini_test.rb` to `mocha/minitest.rb` - thanks to @grosser (#320 & #322)
|
348
|
+
* Fix warning when delegating to mock in Ruby 2.4 - thanks to @tjvc (#321 & #323)
|
349
|
+
* Updates to Travis CI configuration ([73af600..9732726](https://github.com/freerange/mocha/compare/73af600...9732726) & 0426e5e)
|
350
|
+
|
351
|
+
## 1.3.0
|
352
|
+
|
353
|
+
* Ensure all tests run individually - thanks to @chrisroos (#267)
|
354
|
+
* Update Travis CI build status badge to show master branch status (#264)
|
355
|
+
* Correct RSpec section of the README - thanks to @myronmarston (0cc039c8)
|
356
|
+
* Fix pretty printing of quotes in `String#mocha_inspect` (#215 & #223)
|
357
|
+
* Add release instructions to README - thanks to @chrisroos (70a5febd & 3c664df7)
|
358
|
+
* Require at least Ruby v1.8.7 in gemspec - thanks to @knappe (3e20be8e)
|
359
|
+
* Remove redundant InstanceMethod#method_exists? - thanks to @chrisroos (8f58eddf)
|
360
|
+
* Reduce risk of hitting bug 12832 in Ruby v2.3 - thanks to @chrisroos (#277 & eca7560c)
|
361
|
+
* Fix JRuby build - thanks to @headius (jruby/jruby#4250) & @chrisroos (#274)
|
362
|
+
* Add latest stable version of JRuby to Travis CI build matrix (#288)
|
363
|
+
* Fix Ruby v1.8.7 builds on Travis CI (928b5a40 & 460dce5b)
|
364
|
+
* Deprecate passing block to mock object constructor (#290)
|
365
|
+
* Add a known issue to README for Ruby bug 12876 (#276)
|
366
|
+
* Add Ruby 2.4 and ruby-head to Travis CI build matrix - thanks to @junaruga (#297)
|
367
|
+
* Fix `Mocha::ParameterMatchers#includes` for `Array` values - thanks to @timcraft (#302)
|
368
|
+
* Use faster container-based virtual environments for Travis CI builds (#305)
|
369
|
+
* Rename `Mocha::ParameterMatchers::QueryStringMatches` to `QueryString` (#306)
|
370
|
+
* Handle blank parameter value for query string matcher - thanks to @weynsee (#303 & #304)
|
371
|
+
* Rename `Mocha::ParameterMatchers::QueryString` -> `EquivalentUri` (#307)
|
372
|
+
* Use `do ... end` instead of `{ ... }` in acceptance tests - thanks to @chrisroos (#294)
|
373
|
+
|
374
|
+
## 1.2.1
|
375
|
+
|
376
|
+
* Fixed #272. Workaround Ruby bug 12832 which caused interpreter to hang. See https://bugs.ruby-lang.org/issues/12832. Thanks to @chrisroos & @petems (6f1c8b9b, #273).
|
377
|
+
|
378
|
+
## 1.2.0
|
379
|
+
|
380
|
+
* Always use prepended module to stub class & instance methods for Ruby v2+ - thanks to @grosser & @chrisroos (43d56671, #244)
|
381
|
+
* Always use prepended module to stub AnyInstance methods in Ruby v2+ - thanks to @chrisroos (#262)
|
382
|
+
* Always set visibility of stub method to match stubbed method on included module - thanks to @grosser & @chrisroos (e87c03b0, #248)
|
383
|
+
* Always set visibility to stub method to match stubbed method on superclass - thanks to @chrisroos (38d902ad)
|
384
|
+
* Allow stubbing of method to which any instance responds (#200)
|
385
|
+
* Allow `includes` matcher to take matcher arguments - thanks to @lazyatom (#217)
|
386
|
+
* Avoid exception in older version of Rubygems - thanks to @chrisroos (78d930a7)
|
387
|
+
* Add licenses to gemspec as requested by @coreyhaines (#201)
|
388
|
+
* Fix typo in README - thanks to @jaredbeck (6119460d)
|
389
|
+
* Added section about using Mocha with RSpec & Rails to README (#221)
|
390
|
+
* Fix documentation for Mocha::API#stub method - thanks to @raeno (599b1dcd)
|
391
|
+
* Added backers and sponsors from OpenCollective - thanks to @piamancini (#253)
|
392
|
+
* Fix typo in docs for equals - thanks to @alexcoco (#254)
|
393
|
+
* Add known issue for Ruby v1.8 to README - thanks to @chrisroos (2c642096)
|
394
|
+
|
3
395
|
## 1.1.0
|
4
396
|
|
5
397
|
* Set visibility of any instance stub method.
|
@@ -374,7 +766,7 @@ Hash with wrong number of entries.
|
|
374
766
|
|
375
767
|
## 0.5.0
|
376
768
|
|
377
|
-
- Parameter Matchers - I
|
769
|
+
- Parameter Matchers - I've added a few Hamcrest-style parameter matchers which are designed to be used inside Expectation#with. The following matchers are currently available: anything(), includes(), has_key(), has_value(), has_entry(), all_of() & any_of(). More to follow soon. The idea is eventually to get rid of the nasty parameter_block option on Expectation#with.
|
378
770
|
|
379
771
|
object = mock()
|
380
772
|
object.expects(:method).with(has_key('key_1'))
|
data/Rakefile
CHANGED
@@ -1,15 +1,22 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
1
|
+
require 'bundler'
|
2
|
+
namespace 'rubygems' do
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
end
|
5
|
+
require 'bundler/setup'
|
4
6
|
|
5
7
|
require 'rake/testtask'
|
8
|
+
begin
|
9
|
+
# Only available with default Gemfile and in Ruby >= v2.2
|
10
|
+
require 'rubocop/rake_task'
|
11
|
+
rescue LoadError # rubocop:disable Lint/HandleExceptions
|
12
|
+
end
|
6
13
|
|
7
|
-
desc
|
8
|
-
task 'default' => ['test', 'test:performance']
|
14
|
+
desc 'Run all linters and tests'
|
15
|
+
task 'default' => ['lint', 'test', 'test:performance']
|
9
16
|
|
10
|
-
desc
|
17
|
+
desc 'Run tests'
|
11
18
|
task 'test' do
|
12
|
-
if test_library = ENV['MOCHA_RUN_INTEGRATION_TESTS']
|
19
|
+
if (test_library = ENV['MOCHA_RUN_INTEGRATION_TESTS'])
|
13
20
|
Rake::Task["test:integration:#{test_library}"].invoke
|
14
21
|
else
|
15
22
|
Rake::Task['test:units'].invoke
|
@@ -17,35 +24,25 @@ task 'test' do
|
|
17
24
|
end
|
18
25
|
end
|
19
26
|
|
20
|
-
namespace 'test' do
|
21
|
-
|
22
|
-
unit_tests = FileList['test/unit/**/*_test.rb']
|
23
|
-
all_acceptance_tests = FileList['test/acceptance/*_test.rb']
|
24
|
-
ruby186_incompatible_acceptance_tests = FileList['test/acceptance/stub_class_method_defined_on_*_test.rb'] + FileList['test/acceptance/stub_instance_method_defined_on_*_test.rb']
|
25
|
-
ruby186_compatible_acceptance_tests = all_acceptance_tests - ruby186_incompatible_acceptance_tests
|
26
|
-
|
27
|
-
desc "Run unit tests"
|
27
|
+
namespace 'test' do # rubocop:disable Metrics/BlockLength
|
28
|
+
desc 'Run unit tests'
|
28
29
|
Rake::TestTask.new('units') do |t|
|
29
30
|
t.libs << 'test'
|
30
|
-
t.test_files =
|
31
|
+
t.test_files = FileList['test/unit/**/*_test.rb']
|
31
32
|
t.verbose = true
|
32
33
|
t.warning = true
|
33
34
|
end
|
34
35
|
|
35
|
-
desc
|
36
|
+
desc 'Run acceptance tests'
|
36
37
|
Rake::TestTask.new('acceptance') do |t|
|
37
38
|
t.libs << 'test'
|
38
|
-
|
39
|
-
t.test_files = all_acceptance_tests
|
40
|
-
else
|
41
|
-
t.test_files = ruby186_compatible_acceptance_tests
|
42
|
-
end
|
39
|
+
t.test_files = FileList['test/acceptance/*_test.rb']
|
43
40
|
t.verbose = true
|
44
41
|
t.warning = true
|
45
42
|
end
|
46
43
|
|
47
44
|
namespace 'integration' do
|
48
|
-
desc
|
45
|
+
desc 'Run MiniTest integration tests (intended to be run in its own process)'
|
49
46
|
Rake::TestTask.new('minitest') do |t|
|
50
47
|
t.libs << 'test'
|
51
48
|
t.test_files = FileList['test/integration/mini_test_test.rb']
|
@@ -53,7 +50,7 @@ namespace 'test' do
|
|
53
50
|
t.warning = true
|
54
51
|
end
|
55
52
|
|
56
|
-
desc
|
53
|
+
desc 'Run Test::Unit integration tests (intended to be run in its own process)'
|
57
54
|
Rake::TestTask.new('test-unit') do |t|
|
58
55
|
t.libs << 'test'
|
59
56
|
t.test_files = FileList['test/integration/test_unit_test.rb']
|
@@ -72,7 +69,7 @@ namespace 'test' do
|
|
72
69
|
# t.rcov_opts << '--xref'
|
73
70
|
# end
|
74
71
|
|
75
|
-
desc
|
72
|
+
desc 'Run performance tests'
|
76
73
|
task 'performance' do
|
77
74
|
require File.join(File.dirname(__FILE__), 'test', 'acceptance', 'stubba_example_test')
|
78
75
|
require File.join(File.dirname(__FILE__), 'test', 'acceptance', 'mocha_example_test')
|
@@ -82,58 +79,72 @@ namespace 'test' do
|
|
82
79
|
puts "#{test_case}: #{benchmark_test_case(test_case, iterations)} seconds."
|
83
80
|
end
|
84
81
|
end
|
82
|
+
end
|
85
83
|
|
84
|
+
task 'lint' do
|
85
|
+
if defined?(RuboCop::RakeTask)
|
86
|
+
RuboCop::RakeTask.new
|
87
|
+
Rake::Task['rubocop'].invoke
|
88
|
+
else
|
89
|
+
puts 'RuboCop not available - skipping linting'
|
90
|
+
end
|
86
91
|
end
|
87
92
|
|
93
|
+
# rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
88
94
|
def benchmark_test_case(klass, iterations)
|
89
95
|
require 'benchmark'
|
96
|
+
require 'mocha/detection/mini_test'
|
90
97
|
|
91
98
|
if defined?(MiniTest)
|
92
|
-
|
93
|
-
|
99
|
+
minitest_version = Gem::Version.new(Mocha::Detection::MiniTest.version)
|
100
|
+
if Gem::Requirement.new('>= 5.0.0').satisfied_by?(minitest_version)
|
101
|
+
Minitest.seed = 1
|
102
|
+
result = Benchmark.realtime { iterations.times { |_i| klass.run(MiniTest::CompositeReporter.new) } }
|
103
|
+
MiniTest::Runnable.runnables.delete(klass)
|
104
|
+
result
|
105
|
+
else
|
106
|
+
MiniTest::Unit.output = StringIO.new
|
107
|
+
Benchmark.realtime { iterations.times { |_i| MiniTest::Unit.new.run([klass]) } }
|
108
|
+
end
|
94
109
|
else
|
95
110
|
load 'test/unit/ui/console/testrunner.rb' unless defined?(Test::Unit::UI::Console::TestRunner)
|
96
|
-
unless
|
111
|
+
unless @silent_option
|
97
112
|
begin
|
98
113
|
load 'test/unit/ui/console/outputlevel.rb' unless defined?(Test::Unit::UI::Console::OutputLevel::SILENT)
|
99
|
-
|
114
|
+
@silent_option = { output_level: Test::Unit::UI::Console::OutputLevel::SILENT }
|
100
115
|
rescue LoadError
|
101
|
-
|
116
|
+
@silent_option = Test::Unit::UI::SILENT
|
102
117
|
end
|
103
118
|
end
|
104
|
-
Benchmark.realtime { iterations.times { Test::Unit::UI::Console::TestRunner.run(klass,
|
119
|
+
Benchmark.realtime { iterations.times { Test::Unit::UI::Console::TestRunner.run(klass, @silent_option) } }
|
105
120
|
end
|
106
121
|
end
|
122
|
+
# rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
107
123
|
|
108
|
-
|
124
|
+
if ENV['MOCHA_GENERATE_DOCS']
|
109
125
|
require 'yard'
|
110
126
|
|
111
127
|
desc 'Remove generated documentation'
|
112
128
|
task 'clobber_yardoc' do
|
113
|
-
`rm -rf ./
|
114
|
-
end
|
115
|
-
|
116
|
-
task 'docs_environment' do
|
117
|
-
unless ENV['GOOGLE_ANALYTICS_WEB_PROPERTY_ID']
|
118
|
-
puts "\nWarning: GOOGLE_ANALYTICS_WEB_PROPERTY_ID was not defined\n\n"
|
119
|
-
end
|
129
|
+
`rm -rf ./docs`
|
120
130
|
end
|
121
131
|
|
122
132
|
desc 'Generate documentation'
|
123
|
-
YARD::Rake::YardocTask.new('yardoc'
|
124
|
-
task.options = [
|
133
|
+
YARD::Rake::YardocTask.new('yardoc') do |task|
|
134
|
+
task.options = ['--title', "Mocha #{Mocha::VERSION}", '--fail-on-warning']
|
125
135
|
end
|
126
136
|
|
127
|
-
|
128
|
-
|
137
|
+
task 'checkout_docs_cname' do
|
138
|
+
`git checkout docs/CNAME`
|
139
|
+
end
|
129
140
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
system %{ssh gofreerange.com "sudo rm -fr #{path} && mkdir -p #{path}" && scp -r doc/* gofreerange.com:#{path}}
|
141
|
+
task 'checkout_docs_js' do
|
142
|
+
`git checkout docs/js/app.js`
|
143
|
+
`git checkout docs/js/jquery.js`
|
134
144
|
end
|
135
|
-
end
|
136
145
|
|
137
|
-
|
138
|
-
|
146
|
+
desc 'Generate documentation'
|
147
|
+
task 'generate_docs' => %w[clobber_yardoc yardoc checkout_docs_cname checkout_docs_js]
|
139
148
|
end
|
149
|
+
|
150
|
+
task 'release' => ['default', 'rubygems:release']
|