flexmock 0.8.9 → 0.8.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +1 -1
- data/Rakefile +1 -1
- data/TAGS +57 -54
- data/lib/flexmock/mock_container.rb +25 -24
- metadata +3 -3
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
data/TAGS
CHANGED
@@ -143,12 +143,12 @@ lib/flexmock/expectation_director.rb,483
|
|
143
143
|
class FlexMockFlexMock15,363
|
144
144
|
class ExpectationDirectorExpectationDirector20,574
|
145
145
|
def initialize(sym)initialize23,658
|
146
|
-
def call(*args)call38,
|
147
|
-
def <<(expectation)<<46,
|
148
|
-
def find_expectation(*args) # :nodoc:find_expectation51,
|
149
|
-
def flexmock_verify # :nodoc:flexmock_verify62,
|
150
|
-
def defaultify_expectation(exp) # :nodoc:defaultify_expectation69,
|
151
|
-
def find_expectation_in(expectations, *args)find_expectation_in81,
|
146
|
+
def call(*args)call38,1206
|
147
|
+
def <<(expectation)<<46,1459
|
148
|
+
def find_expectation(*args) # :nodoc:find_expectation51,1583
|
149
|
+
def flexmock_verify # :nodoc:flexmock_verify62,1957
|
150
|
+
def defaultify_expectation(exp) # :nodoc:defaultify_expectation69,2168
|
151
|
+
def find_expectation_in(expectations, *args)find_expectation_in81,2449
|
152
152
|
|
153
153
|
lib/flexmock/mock_container.rb,944
|
154
154
|
class FlexMockFlexMock16,399
|
@@ -166,7 +166,7 @@ class FlexMockFlexMock16,399
|
|
166
166
|
def make_partial_proxy(container, obj, name, safe_mode)make_partial_proxy241,9002
|
167
167
|
def build_demeter_chain(mock, arg, &block)build_demeter_chain286,10855
|
168
168
|
def check_proper_mock(mock, method_name)check_proper_mock311,11706
|
169
|
-
def check_method_names(names)check_method_names321,
|
169
|
+
def check_method_names(names)check_method_names321,12114
|
170
170
|
|
171
171
|
lib/flexmock/noop.rb,0
|
172
172
|
|
@@ -179,30 +179,30 @@ class FlexMockFlexMock12,312
|
|
179
179
|
def flexmock_current_order=(value)flexmock_current_order=39,1145
|
180
180
|
def flexmock_validate_order(method_name, order_number)flexmock_validate_order43,1231
|
181
181
|
|
182
|
-
lib/flexmock/partial_mock.rb,
|
182
|
+
lib/flexmock/partial_mock.rb,1375
|
183
183
|
class FlexMockFlexMock14,337
|
184
|
-
class PartialMockProxyPartialMockProxy26,
|
185
|
-
def initialize(obj, mock, safe_mode)initialize40,
|
186
|
-
def flexmock_getflexmock_get56,
|
187
|
-
def should_receive(*args)should_receive80,
|
188
|
-
def add_mock_method(
|
189
|
-
def new_instances(*allocators, &block)new_instances
|
190
|
-
def invoke_original(method, args)invoke_original
|
191
|
-
def flexmock_verifyflexmock_verify
|
192
|
-
def flexmock_teardownflexmock_teardown
|
193
|
-
def flexmock_containerflexmock_container
|
194
|
-
def flexmock_container=(container)flexmock_container=
|
195
|
-
def flexmock_expectations_for(method_name)flexmock_expectations_for
|
196
|
-
def sclasssclass
|
197
|
-
def singleton?(method_name)singleton?
|
198
|
-
def hide_existing_method(method_name)hide_existing_method
|
199
|
-
def stow_existing_definition(method_name)stow_existing_definition
|
200
|
-
def create_alias_for_existing_method(method_name)create_alias_for_existing_method
|
201
|
-
def define_proxy_method(method_name)define_proxy_method
|
202
|
-
def restore_original_definition(method_name)restore_original_definition
|
203
|
-
def remove_current_method(method_name)remove_current_method
|
204
|
-
def detached?detached?
|
205
|
-
def new_name(old_name)new_name
|
184
|
+
class PartialMockProxyPartialMockProxy26,966
|
185
|
+
def initialize(obj, mock, safe_mode)initialize40,1303
|
186
|
+
def flexmock_getflexmock_get56,1703
|
187
|
+
def should_receive(*args)should_receive80,2643
|
188
|
+
def add_mock_method(method_name)add_mock_method91,2921
|
189
|
+
def new_instances(*allocators, &block)new_instances123,4137
|
190
|
+
def invoke_original(method, args)invoke_original144,4938
|
191
|
+
def flexmock_verifyflexmock_verify152,5232
|
192
|
+
def flexmock_teardownflexmock_teardown157,5368
|
193
|
+
def flexmock_containerflexmock_container169,5706
|
194
|
+
def flexmock_container=(container)flexmock_container=175,5901
|
195
|
+
def flexmock_expectations_for(method_name)flexmock_expectations_for179,6017
|
196
|
+
def sclasssclass186,6178
|
197
|
+
def singleton?(method_name)singleton?192,6319
|
198
|
+
def hide_existing_method(method_name)hide_existing_method202,6781
|
199
|
+
def stow_existing_definition(method_name)stow_existing_definition209,6998
|
200
|
+
def create_alias_for_existing_method(method_name)create_alias_for_existing_method229,7715
|
201
|
+
def define_proxy_method(method_name)define_proxy_method247,8234
|
202
|
+
def restore_original_definition(method_name)restore_original_definition268,8932
|
203
|
+
def remove_current_method(method_name)remove_current_method280,9296
|
204
|
+
def detached?detached?285,9457
|
205
|
+
def new_name(old_name)new_name290,9565
|
206
206
|
|
207
207
|
lib/flexmock/rails/view_mocking.rb,665
|
208
208
|
class FlexMockFlexMock3,20
|
@@ -226,12 +226,12 @@ class FlexMockFlexMock14,347
|
|
226
226
|
def method_missing(sym, *args, &block)method_missing59,1805
|
227
227
|
|
228
228
|
lib/flexmock/rspec.rb,341
|
229
|
-
class FlexMockFlexMock14,
|
230
|
-
class RSpecFrameworkAdapterRSpecFrameworkAdapter
|
231
|
-
def assert_block(msg, &block)assert_block
|
232
|
-
def assert_equal(a, b, msg=nil)assert_equal
|
233
|
-
class AssertionFailedError < StandardError; endAssertionFailedError
|
234
|
-
def assertion_failed_errorassertion_failed_error
|
229
|
+
class FlexMockFlexMock14,344
|
230
|
+
class RSpecFrameworkAdapterRSpecFrameworkAdapter21,441
|
231
|
+
def assert_block(msg, &block)assert_block22,471
|
232
|
+
def assert_equal(a, b, msg=nil)assert_equal26,573
|
233
|
+
class AssertionFailedError < StandardError; endAssertionFailedError31,736
|
234
|
+
def assertion_failed_errorassertion_failed_error32,788
|
235
235
|
|
236
236
|
lib/flexmock/test_unit.rb,120
|
237
237
|
module TestTest14,354
|
@@ -271,6 +271,9 @@ class FlexMockFlexMock14,337
|
|
271
271
|
|
272
272
|
lib/flexmock.rb,0
|
273
273
|
|
274
|
+
print_tree.rb,47
|
275
|
+
def print_tree(tree, indent=0)print_tree5,44
|
276
|
+
|
274
277
|
test/asserts.rb,139
|
275
278
|
class FlexMockFlexMock12,312
|
276
279
|
module FailureAssertionFailureAssertion15,368
|
@@ -546,19 +549,19 @@ module ActionViewActionView142,3294
|
|
546
549
|
class BaseBase143,3312
|
547
550
|
|
548
551
|
test/test_record_mode.rb,1339
|
549
|
-
class TestRecordMode < Test::Unit::TestCaseTestRecordMode16,
|
550
|
-
def test_recording_mode_workstest_recording_mode_works20,
|
551
|
-
def test_arguments_are_passed_to_recording_mode_blocktest_arguments_are_passed_to_recording_mode_block28,
|
552
|
-
def test_recording_mode_handles_multiple_returnstest_recording_mode_handles_multiple_returns39,
|
553
|
-
def test_recording_mode_does_not_specify_ordertest_recording_mode_does_not_specify_order53,
|
554
|
-
def test_recording_mode_gets_block_args_tootest_recording_mode_gets_block_args_too64,
|
555
|
-
def test_recording_mode_should_validate_args_with_equalstest_recording_mode_should_validate_args_with_equals76,
|
556
|
-
def test_recording_mode_should_allow_arg_contraint_validationtest_recording_mode_should_allow_arg_contraint_validation87,
|
557
|
-
def test_recording_mode_should_handle_multiplicity_contraintstest_recording_mode_should_handle_multiplicity_contraints98,
|
558
|
-
def test_strict_record_mode_requires_exact_argument_matchestest_strict_record_mode_requires_exact_argument_matches110,
|
559
|
-
def test_strict_record_mode_requires_exact_orderingtest_strict_record_mode_requires_exact_ordering122,
|
560
|
-
def test_strict_record_mode_requires_oncetest_strict_record_mode_requires_once136,
|
561
|
-
def test_strict_record_mode_can_not_failtest_strict_record_mode_can_not_fail149,
|
552
|
+
class TestRecordMode < Test::Unit::TestCaseTestRecordMode16,375
|
553
|
+
def test_recording_mode_workstest_recording_mode_works20,486
|
554
|
+
def test_arguments_are_passed_to_recording_mode_blocktest_arguments_are_passed_to_recording_mode_block28,660
|
555
|
+
def test_recording_mode_handles_multiple_returnstest_recording_mode_handles_multiple_returns39,924
|
556
|
+
def test_recording_mode_does_not_specify_ordertest_recording_mode_does_not_specify_order53,1334
|
557
|
+
def test_recording_mode_gets_block_args_tootest_recording_mode_gets_block_args_too64,1569
|
558
|
+
def test_recording_mode_should_validate_args_with_equalstest_recording_mode_should_validate_args_with_equals76,1839
|
559
|
+
def test_recording_mode_should_allow_arg_contraint_validationtest_recording_mode_should_allow_arg_contraint_validation87,2063
|
560
|
+
def test_recording_mode_should_handle_multiplicity_contraintstest_recording_mode_should_handle_multiplicity_contraints98,2292
|
561
|
+
def test_strict_record_mode_requires_exact_argument_matchestest_strict_record_mode_requires_exact_argument_matches110,2547
|
562
|
+
def test_strict_record_mode_requires_exact_orderingtest_strict_record_mode_requires_exact_ordering122,2815
|
563
|
+
def test_strict_record_mode_requires_oncetest_strict_record_mode_requires_once136,3106
|
564
|
+
def test_strict_record_mode_can_not_failtest_strict_record_mode_can_not_fail149,3368
|
562
565
|
|
563
566
|
test/test_samples.rb,2164
|
564
567
|
class TestSamples < Test::Unit::TestCaseTestSamples17,378
|
@@ -734,11 +737,11 @@ class TestFlexMockShoulds < Test::Unit::TestCaseTestFlexMockShoulds34,545
|
|
734
737
|
def test_wicked_and_evil_tricks_with_by_default_are_thwartedtest_wicked_and_evil_tricks_with_by_default_are_thwarted1019,26165
|
735
738
|
def test_mocks_can_handle_multi_parameter_respond_tostest_mocks_can_handle_multi_parameter_respond_tos1031,26570
|
736
739
|
def test_can_mock_operatorstest_can_mock_operators1042,26917
|
737
|
-
def assert_operator(op, &block)assert_operator
|
738
|
-
class TestFlexMockShouldsWithInclude < Test::Unit::TestCaseTestFlexMockShouldsWithInclude
|
739
|
-
def test_include_enables_unqualified_arg_type_referencestest_include_enables_unqualified_arg_type_references
|
740
|
-
class TestFlexMockArgTypesDontLeak < Test::Unit::TestCaseTestFlexMockArgTypesDontLeak
|
741
|
-
def test_unqualified_arg_type_references_are_undefined_by_defaulttest_unqualified_arg_type_references_are_undefined_by_default
|
740
|
+
def assert_operator(op, &block)assert_operator1072,27985
|
741
|
+
class TestFlexMockShouldsWithInclude < Test::Unit::TestCaseTestFlexMockShouldsWithInclude1080,28139
|
742
|
+
def test_include_enables_unqualified_arg_type_referencestest_include_enables_unqualified_arg_type_references1082,28233
|
743
|
+
class TestFlexMockArgTypesDontLeak < Test::Unit::TestCaseTestFlexMockArgTypesDontLeak1090,28397
|
744
|
+
def test_unqualified_arg_type_references_are_undefined_by_defaulttest_unqualified_arg_type_references_are_undefined_by_default1091,28455
|
742
745
|
|
743
746
|
test/test_tu_integration.rb,1570
|
744
747
|
class TestTuIntegrationFlexMockMethod < Test::Unit::TestCaseTestTuIntegrationFlexMockMethod15,352
|
@@ -14,7 +14,7 @@ require 'flexmock/argument_types'
|
|
14
14
|
require 'flexmock/ordering'
|
15
15
|
|
16
16
|
class FlexMock
|
17
|
-
|
17
|
+
|
18
18
|
# ######################################################################
|
19
19
|
# Mock container methods
|
20
20
|
#
|
@@ -22,7 +22,7 @@ class FlexMock
|
|
22
22
|
# is included, mocks may be created with a simple call to the +flexmock+
|
23
23
|
# method. Mocks created with via the method call will automatically be
|
24
24
|
# verified in the teardown of the test case.
|
25
|
-
#
|
25
|
+
#
|
26
26
|
module MockContainer
|
27
27
|
include Ordering
|
28
28
|
|
@@ -40,12 +40,12 @@ class FlexMock
|
|
40
40
|
m.flexmock_verify
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
# List of mocks created in this container
|
45
45
|
def flexmock_created_mocks
|
46
46
|
@flexmock_created_mocks ||= []
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
# Close all the mock objects in the container. Closing a mock object
|
50
50
|
# restores any original behavior that was displaced by the mock.
|
51
51
|
def flexmock_close
|
@@ -54,7 +54,7 @@ class FlexMock
|
|
54
54
|
end
|
55
55
|
@flexmock_created_mocks = []
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
# Create a mocking object in the FlexMock framework. The +flexmock+
|
59
59
|
# method has a number of options available, depending on just what kind of
|
60
60
|
# mocking object your require. Mocks created via +flexmock+ will be
|
@@ -86,9 +86,9 @@ class FlexMock
|
|
86
86
|
# mocks.
|
87
87
|
#
|
88
88
|
# expect_hash ::
|
89
|
-
# Hash table of method names and values. Each method/value pair is
|
89
|
+
# Hash table of method names and values. Each method/value pair is
|
90
90
|
# used to setup a simple expectation so that if the mock object
|
91
|
-
# receives a message matching an entry in the table, it returns
|
91
|
+
# receives a message matching an entry in the table, it returns
|
92
92
|
# the associated value. No argument our call count constraints are
|
93
93
|
# added. Using an expect_hash is identical to calling:
|
94
94
|
#
|
@@ -97,24 +97,24 @@ class FlexMock
|
|
97
97
|
# for each of the method/value pairs in the hash.
|
98
98
|
#
|
99
99
|
# real_object ::
|
100
|
-
# If a real object is given, then a partial mock is constructed
|
101
|
-
# using the real_object as a base. Partial mocks (formally referred
|
102
|
-
# to as stubs) behave as a mock object when an expectation is matched,
|
103
|
-
# and otherwise will behave like the original object. This is useful
|
104
|
-
# when you want to use a real object for testing, but need to mock out
|
105
|
-
# just one or two methods.
|
100
|
+
# If a real object is given, then a partial mock is constructed
|
101
|
+
# using the real_object as a base. Partial mocks (formally referred
|
102
|
+
# to as stubs) behave as a mock object when an expectation is matched,
|
103
|
+
# and otherwise will behave like the original object. This is useful
|
104
|
+
# when you want to use a real object for testing, but need to mock out
|
105
|
+
# just one or two methods.
|
106
106
|
#
|
107
107
|
# :base ::
|
108
108
|
# Forces the following argument to be used as the base of a
|
109
|
-
# partial mock object. This explicit tag is only needed if you
|
109
|
+
# partial mock object. This explicit tag is only needed if you
|
110
110
|
# want to use a string or a symbol as the mock base (string and
|
111
111
|
# symbols would normally be interpretted as the mock name).
|
112
|
-
#
|
112
|
+
#
|
113
113
|
# &block ::
|
114
114
|
# If a block is given, then the mock object is passed to the block and
|
115
115
|
# expectations may be configured within the block. When a block is given
|
116
|
-
# for a partial mock, flexmock will return the domain object rather than
|
117
|
-
# the mock object.
|
116
|
+
# for a partial mock, flexmock will return the domain object rather than
|
117
|
+
# the mock object.
|
118
118
|
#
|
119
119
|
def flexmock(*args)
|
120
120
|
name = nil
|
@@ -156,7 +156,7 @@ class FlexMock
|
|
156
156
|
result
|
157
157
|
end
|
158
158
|
alias flexstub flexmock
|
159
|
-
|
159
|
+
|
160
160
|
# Remember the mock object / stub in the mock container.
|
161
161
|
def flexmock_remember(mocking_object)
|
162
162
|
@flexmock_created_mocks ||= []
|
@@ -240,15 +240,16 @@ class FlexMock
|
|
240
240
|
# the name of the mock object.
|
241
241
|
def make_partial_proxy(container, obj, name, safe_mode)
|
242
242
|
name ||= "flexmock(#{obj.class.to_s})"
|
243
|
-
obj.
|
243
|
+
if !obj.instance_variable_defined?("@flexmock_proxy") || obj.instance_variable_get("@flexmock_proxy").nil?
|
244
244
|
mock = FlexMock.new(name, container)
|
245
|
-
|
246
|
-
|
245
|
+
proxy = PartialMockProxy.new(obj, mock, safe_mode)
|
246
|
+
obj.instance_variable_set("@flexmock_proxy", proxy)
|
247
|
+
end
|
247
248
|
obj.instance_variable_get("@flexmock_proxy")
|
248
249
|
end
|
249
250
|
|
250
251
|
private
|
251
|
-
|
252
|
+
|
252
253
|
# Build the chain of mocks for demeter style mocking.
|
253
254
|
#
|
254
255
|
# Warning: Nasty code ahead.
|
@@ -306,7 +307,7 @@ class FlexMock
|
|
306
307
|
end
|
307
308
|
exp
|
308
309
|
end
|
309
|
-
|
310
|
+
|
310
311
|
# Check that the given mock is a real FlexMock mock.
|
311
312
|
def check_proper_mock(mock, method_name)
|
312
313
|
unless mock.kind_of?(FlexMock)
|
@@ -314,7 +315,7 @@ class FlexMock
|
|
314
315
|
"Conflicting mock declaration for '#{method_name}' in demeter style mock"
|
315
316
|
end
|
316
317
|
end
|
317
|
-
|
318
|
+
|
318
319
|
METHOD_NAME_RE = /^([A-Za-z_][A-Za-z0-9_]*[=!?]?|\[\]=?||\*\*|<<|>>|<=>|[<>=]=|=~|===|[-+]@|[-+\*\/%&^|<>~`])$/
|
319
320
|
|
320
321
|
# Check that all the names in the list are valid method names.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexmock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 43
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 10
|
10
|
+
version: 0.8.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jim Weirich
|