mocha 1.9.0 → 1.10.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +7 -30
- data/README.md +10 -11
- data/RELEASE.md +48 -0
- data/Rakefile +9 -3
- data/docs/CNAME +1 -0
- data/docs/Mocha.html +132 -5
- data/docs/Mocha/API.html +289 -216
- data/docs/Mocha/ClassMethods.html +88 -16
- data/docs/Mocha/Configuration.html +931 -174
- data/docs/Mocha/Expectation.html +200 -255
- data/docs/Mocha/ExpectationError.html +5 -10
- data/docs/Mocha/ExpectationErrorFactory.html +9 -18
- data/docs/Mocha/Hooks.html +12 -27
- data/docs/Mocha/Integration.html +3 -3
- data/docs/Mocha/Integration/MiniTest.html +3 -3
- data/docs/Mocha/Integration/MiniTest/Adapter.html +5 -6
- data/docs/Mocha/Integration/TestUnit.html +3 -3
- data/docs/Mocha/Integration/TestUnit/Adapter.html +5 -6
- data/docs/Mocha/Mock.html +202 -162
- data/docs/Mocha/ObjectMethods.html +121 -68
- data/docs/Mocha/ParameterMatchers.html +21 -109
- data/docs/Mocha/ParameterMatchers/AllOf.html +4 -5
- data/docs/Mocha/ParameterMatchers/AnyOf.html +4 -5
- data/docs/Mocha/ParameterMatchers/AnyParameters.html +3 -3
- data/docs/Mocha/ParameterMatchers/Anything.html +3 -3
- data/docs/Mocha/ParameterMatchers/Base.html +8 -15
- data/docs/Mocha/ParameterMatchers/Equals.html +4 -5
- data/docs/Mocha/ParameterMatchers/EquivalentUri.html +3 -3
- data/docs/Mocha/ParameterMatchers/HasEntries.html +4 -5
- data/docs/Mocha/ParameterMatchers/HasEntry.html +4 -5
- data/docs/Mocha/ParameterMatchers/HasKey.html +4 -5
- data/docs/Mocha/ParameterMatchers/HasValue.html +4 -5
- data/docs/Mocha/ParameterMatchers/Includes.html +4 -5
- data/docs/Mocha/ParameterMatchers/InstanceOf.html +4 -5
- data/docs/Mocha/ParameterMatchers/IsA.html +3 -3
- data/docs/Mocha/ParameterMatchers/KindOf.html +4 -5
- data/docs/Mocha/ParameterMatchers/Not.html +4 -5
- data/docs/Mocha/ParameterMatchers/Optionally.html +3 -3
- data/docs/Mocha/ParameterMatchers/RegexpMatches.html +4 -5
- data/docs/Mocha/ParameterMatchers/RespondsWith.html +4 -5
- data/docs/Mocha/ParameterMatchers/YamlEquivalent.html +4 -5
- data/docs/Mocha/Sequence.html +3 -3
- data/docs/Mocha/StateMachine.html +13 -25
- data/docs/Mocha/StateMachine/State.html +4 -5
- data/docs/Mocha/StateMachine/StatePredicate.html +4 -5
- data/docs/Mocha/StubbingError.html +3 -3
- data/docs/_index.html +4 -22
- data/docs/class_list.html +1 -1
- data/docs/file.COPYING.html +3 -3
- data/docs/file.MIT-LICENSE.html +3 -3
- data/docs/file.README.html +18 -15
- data/docs/file.RELEASE.html +58 -3
- data/docs/frames.html +1 -1
- data/docs/index.html +18 -15
- data/docs/method_list.html +103 -39
- data/docs/top-level-namespace.html +3 -3
- data/gemfiles/Gemfile.minitest.5.11.3 +7 -0
- data/init.rb +1 -3
- data/lib/mocha.rb +8 -0
- data/lib/mocha/any_instance_method.rb +9 -25
- data/lib/mocha/api.rb +62 -66
- data/lib/mocha/cardinality.rb +26 -11
- data/lib/mocha/class_methods.rb +16 -15
- data/lib/mocha/configuration.rb +295 -67
- data/lib/mocha/detection/test_unit.rb +1 -3
- data/lib/mocha/exception_raiser.rb +2 -1
- data/lib/mocha/expectation.rb +56 -58
- data/lib/mocha/expectation_error.rb +1 -3
- data/lib/mocha/expectation_list.rb +6 -6
- data/lib/mocha/inspect.rb +28 -26
- data/lib/mocha/instance_method.rb +19 -2
- data/lib/mocha/integration.rb +1 -3
- data/lib/mocha/integration/mini_test.rb +7 -0
- data/lib/mocha/integration/test_unit.rb +7 -0
- data/lib/mocha/invocation.rb +61 -0
- data/lib/mocha/macos_version.rb +5 -0
- data/lib/mocha/minitest.rb +6 -1
- data/lib/mocha/mock.rb +46 -31
- data/lib/mocha/mockery.rb +28 -61
- data/lib/mocha/names.rb +1 -1
- data/lib/mocha/object_methods.rb +13 -19
- data/lib/mocha/parameter_matchers.rb +1 -1
- data/lib/mocha/parameter_matchers/all_of.rb +1 -1
- data/lib/mocha/parameter_matchers/any_of.rb +1 -1
- data/lib/mocha/parameter_matchers/equivalent_uri.rb +0 -9
- data/lib/mocha/parameter_matchers/includes.rb +2 -0
- data/lib/mocha/parameter_matchers/instance_methods.rb +18 -0
- data/lib/mocha/raised_exception.rb +11 -0
- data/lib/mocha/return_values.rb +3 -3
- data/lib/mocha/setup.rb +5 -0
- data/lib/mocha/single_return_value.rb +2 -1
- data/lib/mocha/singleton_class.rb +9 -0
- data/lib/mocha/{class_method.rb → stubbed_method.rb} +23 -43
- data/lib/mocha/test_unit.rb +6 -1
- data/lib/mocha/thrower.rb +2 -1
- data/lib/mocha/thrown_object.rb +12 -0
- data/lib/mocha/version.rb +1 -1
- data/mocha.gemspec +1 -3
- data/test/acceptance/acceptance_test_helper.rb +6 -0
- data/test/acceptance/bug_18914_test.rb +0 -1
- data/test/acceptance/bug_21465_test.rb +0 -1
- data/test/acceptance/bug_21563_test.rb +0 -1
- data/test/acceptance/display_matching_invocations_alongside_expectations_test.rb +69 -0
- data/test/acceptance/exception_rescue_test.rb +1 -2
- data/test/acceptance/expectations_on_multiple_methods_test.rb +0 -1
- data/test/acceptance/expected_invocation_count_test.rb +2 -3
- data/test/acceptance/failure_messages_test.rb +0 -1
- data/test/acceptance/issue_272_test.rb +1 -2
- data/test/acceptance/issue_65_test.rb +0 -1
- data/test/acceptance/issue_70_test.rb +0 -1
- data/test/acceptance/mocha_example_test.rb +0 -1
- data/test/acceptance/mocha_test_result_test.rb +0 -1
- data/test/acceptance/mock_test.rb +47 -6
- data/test/acceptance/mocked_methods_dispatch_test.rb +0 -1
- data/test/acceptance/multiple_expectations_failure_message_test.rb +0 -1
- data/test/acceptance/optional_parameters_test.rb +0 -1
- data/test/acceptance/parameter_matcher_test.rb +0 -1
- data/test/acceptance/partial_mocks_test.rb +0 -1
- data/test/acceptance/prepend_test.rb +0 -1
- data/test/acceptance/prevent_use_of_mocha_outside_test_test.rb +0 -1
- data/test/acceptance/raise_exception_test.rb +0 -1
- data/test/acceptance/return_value_test.rb +0 -1
- data/test/acceptance/sequence_test.rb +0 -1
- data/test/acceptance/states_test.rb +0 -1
- data/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb +1 -2
- data/test/acceptance/stub_any_instance_method_test.rb +20 -1
- data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +0 -1
- data/test/acceptance/stub_class_method_defined_on_class_test.rb +0 -1
- data/test/acceptance/stub_class_method_defined_on_module_test.rb +0 -1
- data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +1 -2
- data/test/acceptance/stub_everything_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_class_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_module_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +0 -1
- data/test/acceptance/stub_method_defined_on_module_and_aliased_test.rb +0 -1
- data/test/acceptance/stub_module_method_test.rb +0 -1
- data/test/acceptance/stub_test.rb +0 -1
- data/test/acceptance/stubba_example_test.rb +0 -1
- data/test/acceptance/stubba_test_result_test.rb +0 -1
- data/test/acceptance/stubbing_error_backtrace_test.rb +4 -5
- data/test/acceptance/stubbing_frozen_object_test.rb +0 -1
- data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +0 -1
- data/test/acceptance/stubbing_method_unnecessarily_test.rb +5 -5
- data/test/acceptance/stubbing_nil_test.rb +5 -5
- data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_existent_class_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_existent_instance_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +8 -8
- data/test/acceptance/stubbing_non_public_class_method_test.rb +9 -9
- data/test/acceptance/stubbing_non_public_instance_method_test.rb +9 -9
- data/test/acceptance/stubbing_on_non_mock_object_test.rb +5 -5
- data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +0 -1
- data/test/acceptance/throw_test.rb +0 -1
- data/test/acceptance/unexpected_invocation_test.rb +0 -1
- data/test/acceptance/unstubbing_test.rb +0 -1
- data/test/integration/shared_tests.rb +5 -3
- data/test/method_definer.rb +11 -17
- data/test/test_runner.rb +2 -0
- data/test/unit/any_instance_method_test.rb +41 -40
- data/test/unit/cardinality_test.rb +41 -23
- data/test/unit/central_test.rb +0 -1
- data/test/unit/class_methods_test.rb +1 -1
- data/test/unit/configuration_test.rb +12 -12
- data/test/unit/exception_raiser_test.rb +10 -5
- data/test/unit/expectation_list_test.rb +13 -11
- data/test/unit/expectation_test.rb +88 -103
- data/test/unit/instance_method_test.rb +282 -0
- data/test/unit/mock_test.rb +28 -19
- data/test/unit/mockery_test.rb +8 -11
- data/test/unit/module_methods_test.rb +2 -3
- data/test/unit/object_inspect_test.rb +6 -4
- data/test/unit/object_methods_test.rb +3 -2
- data/test/unit/parameter_matchers/equivalent_uri_test.rb +0 -9
- data/test/unit/parameter_matchers/has_entries_test.rb +1 -1
- data/test/unit/parameter_matchers/has_entry_test.rb +1 -1
- data/test/unit/parameter_matchers/has_key_test.rb +1 -1
- data/test/unit/parameter_matchers/has_value_test.rb +1 -1
- data/test/unit/parameter_matchers/includes_test.rb +1 -1
- data/test/unit/parameter_matchers/responds_with_test.rb +1 -1
- data/test/unit/return_values_test.rb +25 -20
- data/test/unit/single_return_value_test.rb +6 -1
- data/test/unit/thrower_test.rb +7 -2
- metadata +16 -30
- data/docs/Mocha/UnexpectedInvocation.html +0 -140
- data/lib/mocha/mini_test.rb +0 -5
- data/lib/mocha/module_method.rb +0 -6
- data/lib/mocha/module_methods.rb +0 -10
- data/lib/mocha/parameter_matchers/object.rb +0 -15
- data/lib/mocha/standalone.rb +0 -4
- data/lib/mocha/unexpected_invocation.rb +0 -24
- data/lib/mocha_standalone.rb +0 -4
- data/test/acceptance/mock_with_initializer_block_test.rb +0 -56
- data/test/unit/class_method_test.rb +0 -276
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.expand_path('../acceptance_test_helper', __FILE__)
|
2
|
-
require 'mocha/
|
2
|
+
require 'mocha/configuration'
|
3
3
|
|
4
4
|
class StubbingNonExistentClassMethodTest < Mocha::TestCase
|
5
5
|
include AcceptanceTest
|
@@ -13,7 +13,7 @@ class StubbingNonExistentClassMethodTest < Mocha::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_should_allow_stubbing_non_existent_class_method
|
16
|
-
Mocha
|
16
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :allow }
|
17
17
|
klass = Class.new
|
18
18
|
test_result = run_as_test do
|
19
19
|
klass.stubs(:non_existent_method)
|
@@ -23,7 +23,7 @@ class StubbingNonExistentClassMethodTest < Mocha::TestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_should_warn_when_stubbing_non_existent_class_method
|
26
|
-
Mocha
|
26
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :warn }
|
27
27
|
klass = Class.new
|
28
28
|
test_result = run_as_test do
|
29
29
|
klass.stubs(:non_existent_method)
|
@@ -33,7 +33,7 @@ class StubbingNonExistentClassMethodTest < Mocha::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_should_prevent_stubbing_non_existent_class_method
|
36
|
-
Mocha
|
36
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
37
37
|
klass = Class.new
|
38
38
|
test_result = run_as_test do
|
39
39
|
klass.stubs(:non_existent_method)
|
@@ -53,7 +53,7 @@ class StubbingNonExistentClassMethodTest < Mocha::TestCase
|
|
53
53
|
|
54
54
|
# rubocop:disable Lint/DuplicateMethods
|
55
55
|
def test_should_allow_stubbing_existing_public_class_method
|
56
|
-
Mocha
|
56
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
57
57
|
klass = Class.new do
|
58
58
|
class << self
|
59
59
|
def existing_public_method; end
|
@@ -67,7 +67,7 @@ class StubbingNonExistentClassMethodTest < Mocha::TestCase
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_should_allow_stubbing_method_to_which_class_responds
|
70
|
-
Mocha
|
70
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
71
71
|
klass = Class.new do
|
72
72
|
class << self
|
73
73
|
def respond_to?(method, _include_private = false)
|
@@ -82,7 +82,7 @@ class StubbingNonExistentClassMethodTest < Mocha::TestCase
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def test_should_allow_stubbing_existing_protected_class_method
|
85
|
-
Mocha
|
85
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
86
86
|
klass = Class.new do
|
87
87
|
class << self
|
88
88
|
def existing_protected_method; end
|
@@ -96,7 +96,7 @@ class StubbingNonExistentClassMethodTest < Mocha::TestCase
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def test_should_allow_stubbing_existing_private_class_method
|
99
|
-
Mocha
|
99
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
100
100
|
klass = Class.new do
|
101
101
|
class << self
|
102
102
|
def existing_private_method; end
|
@@ -110,7 +110,7 @@ class StubbingNonExistentClassMethodTest < Mocha::TestCase
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def test_should_allow_stubbing_existing_public_superclass_method
|
113
|
-
Mocha
|
113
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
114
114
|
superklass = Class.new do
|
115
115
|
class << self
|
116
116
|
def existing_public_method; end
|
@@ -125,7 +125,7 @@ class StubbingNonExistentClassMethodTest < Mocha::TestCase
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def test_should_allow_stubbing_existing_protected_superclass_method
|
128
|
-
Mocha
|
128
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
129
129
|
superklass = Class.new do
|
130
130
|
class << self
|
131
131
|
def existing_protected_method; end
|
@@ -140,7 +140,7 @@ class StubbingNonExistentClassMethodTest < Mocha::TestCase
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def test_should_allow_stubbing_existing_private_superclass_method
|
143
|
-
Mocha
|
143
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
144
144
|
superklass = Class.new do
|
145
145
|
class << self
|
146
146
|
def existing_private_method; end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.expand_path('../acceptance_test_helper', __FILE__)
|
2
|
-
require 'mocha/
|
2
|
+
require 'mocha/configuration'
|
3
3
|
|
4
4
|
class StubbingNonExistentInstanceMethodTest < Mocha::TestCase
|
5
5
|
include AcceptanceTest
|
@@ -13,7 +13,7 @@ class StubbingNonExistentInstanceMethodTest < Mocha::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_should_allow_stubbing_non_existent_instance_method
|
16
|
-
Mocha
|
16
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :allow }
|
17
17
|
instance = Class.new.new
|
18
18
|
test_result = run_as_test do
|
19
19
|
instance.stubs(:non_existent_method)
|
@@ -23,7 +23,7 @@ class StubbingNonExistentInstanceMethodTest < Mocha::TestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_should_warn_when_stubbing_non_existent_instance_method
|
26
|
-
Mocha
|
26
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :warn }
|
27
27
|
instance = Class.new.new
|
28
28
|
test_result = run_as_test do
|
29
29
|
instance.stubs(:non_existent_method)
|
@@ -33,7 +33,7 @@ class StubbingNonExistentInstanceMethodTest < Mocha::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_should_prevent_stubbing_non_existent_instance_method
|
36
|
-
Mocha
|
36
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
37
37
|
instance = Class.new.new
|
38
38
|
test_result = run_as_test do
|
39
39
|
instance.stubs(:non_existent_method)
|
@@ -52,7 +52,7 @@ class StubbingNonExistentInstanceMethodTest < Mocha::TestCase
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_should_allow_stubbing_existing_public_instance_method
|
55
|
-
Mocha
|
55
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
56
56
|
klass = Class.new do
|
57
57
|
def existing_public_method; end
|
58
58
|
public :existing_public_method
|
@@ -65,7 +65,7 @@ class StubbingNonExistentInstanceMethodTest < Mocha::TestCase
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_should_allow_stubbing_method_to_which_instance_responds
|
68
|
-
Mocha
|
68
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
69
69
|
klass = Class.new do
|
70
70
|
def respond_to?(method, _include_private = false)
|
71
71
|
(method == :method_to_which_instance_responds)
|
@@ -79,7 +79,7 @@ class StubbingNonExistentInstanceMethodTest < Mocha::TestCase
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def test_should_allow_stubbing_existing_protected_instance_method
|
82
|
-
Mocha
|
82
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
83
83
|
klass = Class.new do
|
84
84
|
def existing_protected_method; end
|
85
85
|
protected :existing_protected_method
|
@@ -92,7 +92,7 @@ class StubbingNonExistentInstanceMethodTest < Mocha::TestCase
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def test_should_allow_stubbing_existing_private_instance_method
|
95
|
-
Mocha
|
95
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
96
96
|
klass = Class.new do
|
97
97
|
def existing_private_method; end
|
98
98
|
private :existing_private_method
|
@@ -105,7 +105,7 @@ class StubbingNonExistentInstanceMethodTest < Mocha::TestCase
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def test_should_allow_stubbing_existing_public_instance_superclass_method
|
108
|
-
Mocha
|
108
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
109
109
|
superklass = Class.new do
|
110
110
|
def existing_public_method; end
|
111
111
|
public :existing_public_method
|
@@ -118,7 +118,7 @@ class StubbingNonExistentInstanceMethodTest < Mocha::TestCase
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def test_should_allow_stubbing_existing_protected_instance_superclass_method
|
121
|
-
Mocha
|
121
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
122
122
|
superklass = Class.new do
|
123
123
|
def existing_protected_method; end
|
124
124
|
protected :existing_protected_method
|
@@ -131,7 +131,7 @@ class StubbingNonExistentInstanceMethodTest < Mocha::TestCase
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def test_should_allow_stubbing_existing_private_instance_superclass_method
|
134
|
-
Mocha
|
134
|
+
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
|
135
135
|
superklass = Class.new do
|
136
136
|
def existing_private_method; end
|
137
137
|
private :existing_private_method
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.expand_path('../acceptance_test_helper', __FILE__)
|
2
|
-
require 'mocha/
|
2
|
+
require 'mocha/configuration'
|
3
3
|
|
4
4
|
class StubbingNonPublicAnyInstanceMethodTest < Mocha::TestCase
|
5
5
|
include AcceptanceTest
|
@@ -13,7 +13,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Mocha::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_should_allow_stubbing_private_any_instance_method
|
16
|
-
Mocha
|
16
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :allow }
|
17
17
|
klass = Class.new do
|
18
18
|
def private_method; end
|
19
19
|
private :private_method
|
@@ -26,7 +26,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Mocha::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_should_allow_stubbing_protected_any_instance_method
|
29
|
-
Mocha
|
29
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :allow }
|
30
30
|
klass = Class.new do
|
31
31
|
def protected_method; end
|
32
32
|
protected :protected_method
|
@@ -39,7 +39,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Mocha::TestCase
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_should_warn_when_stubbing_private_any_instance_method
|
42
|
-
Mocha
|
42
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :warn }
|
43
43
|
klass = Class.new do
|
44
44
|
def private_method; end
|
45
45
|
private :private_method
|
@@ -52,7 +52,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Mocha::TestCase
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_should_warn_when_stubbing_protected_any_instance_method
|
55
|
-
Mocha
|
55
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :warn }
|
56
56
|
klass = Class.new do
|
57
57
|
def protected_method; end
|
58
58
|
protected :protected_method
|
@@ -65,7 +65,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Mocha::TestCase
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_should_prevent_stubbing_private_any_instance_method
|
68
|
-
Mocha
|
68
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :prevent }
|
69
69
|
klass = Class.new do
|
70
70
|
def private_method; end
|
71
71
|
private :private_method
|
@@ -78,7 +78,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Mocha::TestCase
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def test_should_prevent_stubbing_protected_any_instance_method
|
81
|
-
Mocha
|
81
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :prevent }
|
82
82
|
klass = Class.new do
|
83
83
|
def protected_method; end
|
84
84
|
protected :protected_method
|
@@ -115,7 +115,7 @@ class StubbingNonPublicAnyInstanceMethodTest < Mocha::TestCase
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def test_should_allow_stubbing_public_any_instance_method
|
118
|
-
Mocha
|
118
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :prevent }
|
119
119
|
klass = Class.new do
|
120
120
|
def public_method; end
|
121
121
|
public :public_method
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.expand_path('../acceptance_test_helper', __FILE__)
|
2
|
-
require 'mocha/
|
2
|
+
require 'mocha/configuration'
|
3
3
|
|
4
4
|
class StubbingNonPublicClassMethodTest < Mocha::TestCase
|
5
5
|
include AcceptanceTest
|
@@ -14,7 +14,7 @@ class StubbingNonPublicClassMethodTest < Mocha::TestCase
|
|
14
14
|
|
15
15
|
# rubocop:disable Lint/DuplicateMethods
|
16
16
|
def test_should_allow_stubbing_private_class_method
|
17
|
-
Mocha
|
17
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :allow }
|
18
18
|
klass = Class.new do
|
19
19
|
class << self
|
20
20
|
def private_method; end
|
@@ -29,7 +29,7 @@ class StubbingNonPublicClassMethodTest < Mocha::TestCase
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_should_allow_stubbing_protected_class_method
|
32
|
-
Mocha
|
32
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :allow }
|
33
33
|
klass = Class.new do
|
34
34
|
class << self
|
35
35
|
def protected_method; end
|
@@ -44,7 +44,7 @@ class StubbingNonPublicClassMethodTest < Mocha::TestCase
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_should_warn_when_stubbing_private_class_method
|
47
|
-
Mocha
|
47
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :warn }
|
48
48
|
klass = Class.new do
|
49
49
|
class << self
|
50
50
|
def private_method; end
|
@@ -59,7 +59,7 @@ class StubbingNonPublicClassMethodTest < Mocha::TestCase
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_should_warn_when_stubbing_protected_class_method
|
62
|
-
Mocha
|
62
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :warn }
|
63
63
|
klass = Class.new do
|
64
64
|
class << self
|
65
65
|
def protected_method; end
|
@@ -74,7 +74,7 @@ class StubbingNonPublicClassMethodTest < Mocha::TestCase
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def test_should_prevent_stubbing_private_class_method
|
77
|
-
Mocha
|
77
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :prevent }
|
78
78
|
klass = Class.new do
|
79
79
|
class << self
|
80
80
|
def private_method; end
|
@@ -89,7 +89,7 @@ class StubbingNonPublicClassMethodTest < Mocha::TestCase
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def test_should_prevent_stubbing_protected_class_method
|
92
|
-
Mocha
|
92
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :prevent }
|
93
93
|
klass = Class.new do
|
94
94
|
class << self
|
95
95
|
def protected_method; end
|
@@ -132,7 +132,7 @@ class StubbingNonPublicClassMethodTest < Mocha::TestCase
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def test_should_allow_stubbing_public_class_method
|
135
|
-
Mocha
|
135
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :prevent }
|
136
136
|
klass = Class.new do
|
137
137
|
class << self
|
138
138
|
def public_method; end
|
@@ -147,7 +147,7 @@ class StubbingNonPublicClassMethodTest < Mocha::TestCase
|
|
147
147
|
# rubocop:enable Lint/DuplicateMethods
|
148
148
|
|
149
149
|
def test_should_allow_stubbing_method_to_which_class_responds
|
150
|
-
Mocha
|
150
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :prevent }
|
151
151
|
klass = Class.new do
|
152
152
|
class << self
|
153
153
|
def respond_to?(method, _include_private_methods = false)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.expand_path('../acceptance_test_helper', __FILE__)
|
2
|
-
require 'mocha/
|
2
|
+
require 'mocha/configuration'
|
3
3
|
|
4
4
|
class StubbingNonPublicInstanceMethodTest < Mocha::TestCase
|
5
5
|
include AcceptanceTest
|
@@ -13,7 +13,7 @@ class StubbingNonPublicInstanceMethodTest < Mocha::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_should_allow_stubbing_private_instance_method
|
16
|
-
Mocha
|
16
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :allow }
|
17
17
|
instance = Class.new do
|
18
18
|
def private_method; end
|
19
19
|
private :private_method
|
@@ -26,7 +26,7 @@ class StubbingNonPublicInstanceMethodTest < Mocha::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_should_allow_stubbing_protected_instance_method
|
29
|
-
Mocha
|
29
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :allow }
|
30
30
|
instance = Class.new do
|
31
31
|
def protected_method; end
|
32
32
|
protected :protected_method
|
@@ -39,7 +39,7 @@ class StubbingNonPublicInstanceMethodTest < Mocha::TestCase
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_should_warn_when_stubbing_private_instance_method
|
42
|
-
Mocha
|
42
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :warn }
|
43
43
|
instance = Class.new do
|
44
44
|
def private_method; end
|
45
45
|
private :private_method
|
@@ -52,7 +52,7 @@ class StubbingNonPublicInstanceMethodTest < Mocha::TestCase
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_should_warn_when_stubbing_protected_instance_method
|
55
|
-
Mocha
|
55
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :warn }
|
56
56
|
instance = Class.new do
|
57
57
|
def protected_method; end
|
58
58
|
protected :protected_method
|
@@ -65,7 +65,7 @@ class StubbingNonPublicInstanceMethodTest < Mocha::TestCase
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_should_prevent_stubbing_private_instance_method
|
68
|
-
Mocha
|
68
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :prevent }
|
69
69
|
instance = Class.new do
|
70
70
|
def private_method; end
|
71
71
|
private :private_method
|
@@ -78,7 +78,7 @@ class StubbingNonPublicInstanceMethodTest < Mocha::TestCase
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def test_should_prevent_stubbing_protected_instance_method
|
81
|
-
Mocha
|
81
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :prevent }
|
82
82
|
instance = Class.new do
|
83
83
|
def protected_method; end
|
84
84
|
protected :protected_method
|
@@ -115,7 +115,7 @@ class StubbingNonPublicInstanceMethodTest < Mocha::TestCase
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def test_should_allow_stubbing_public_instance_method
|
118
|
-
Mocha
|
118
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :prevent }
|
119
119
|
instance = Class.new do
|
120
120
|
def public_method; end
|
121
121
|
public :public_method
|
@@ -127,7 +127,7 @@ class StubbingNonPublicInstanceMethodTest < Mocha::TestCase
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def test_should_allow_stubbing_method_to_which_instance_responds
|
130
|
-
Mocha
|
130
|
+
Mocha.configure { |c| c.stubbing_non_public_method = :prevent }
|
131
131
|
instance = Class.new do
|
132
132
|
def respond_to?(method, _include_private_methods = false)
|
133
133
|
(method == :method_to_which_instance_responds)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.expand_path('../acceptance_test_helper', __FILE__)
|
2
|
-
require 'mocha/
|
2
|
+
require 'mocha/configuration'
|
3
3
|
|
4
4
|
class StubbingOnNonMockObjectTest < Mocha::TestCase
|
5
5
|
include AcceptanceTest
|
@@ -13,7 +13,7 @@ class StubbingOnNonMockObjectTest < Mocha::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_should_allow_stubbing_method_on_non_mock_object
|
16
|
-
Mocha
|
16
|
+
Mocha.configure { |c| c.stubbing_method_on_non_mock_object = :allow }
|
17
17
|
non_mock_object = Class.new do
|
18
18
|
def existing_method; end
|
19
19
|
end
|
@@ -25,7 +25,7 @@ class StubbingOnNonMockObjectTest < Mocha::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_should_warn_on_stubbing_method_on_non_mock_object
|
28
|
-
Mocha
|
28
|
+
Mocha.configure { |c| c.stubbing_method_on_non_mock_object = :warn }
|
29
29
|
non_mock_object = Class.new do
|
30
30
|
def existing_method; end
|
31
31
|
end
|
@@ -37,7 +37,7 @@ class StubbingOnNonMockObjectTest < Mocha::TestCase
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_should_prevent_stubbing_method_on_non_mock_object
|
40
|
-
Mocha
|
40
|
+
Mocha.configure { |c| c.stubbing_method_on_non_mock_object = :prevent }
|
41
41
|
non_mock_object = Class.new do
|
42
42
|
def existing_method; end
|
43
43
|
end
|
@@ -60,7 +60,7 @@ class StubbingOnNonMockObjectTest < Mocha::TestCase
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_should_allow_stubbing_method_on_mock_object
|
63
|
-
Mocha
|
63
|
+
Mocha.configure { |c| c.stubbing_method_on_non_mock_object = :prevent }
|
64
64
|
test_result = run_as_test do
|
65
65
|
mock = mock('mock')
|
66
66
|
mock.stubs(:any_method)
|