flexmock 0.8.9 → 0.8.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.rdoc +1 -1
  2. data/Rakefile +1 -1
  3. data/TAGS +57 -54
  4. data/lib/flexmock/mock_container.rb +25 -24
  5. metadata +3 -3
data/README.rdoc CHANGED
@@ -3,7 +3,7 @@
3
3
  FlexMock is a simple, but flexible, mock object library for Ruby unit
4
4
  testing.
5
5
 
6
- Version :: 0.8.9
6
+ Version :: 0.8.10
7
7
 
8
8
  = Links
9
9
 
data/Rakefile CHANGED
@@ -19,7 +19,7 @@ require 'rake/contrib/rubyforgepublisher'
19
19
  CLEAN.include('*.tmp')
20
20
  CLOBBER.include("html", 'pkg')
21
21
 
22
- PKG_VERSION = '0.8.9'
22
+ PKG_VERSION = '0.8.10'
23
23
 
24
24
  PKG_FILES = FileList[
25
25
  '[A-Z]*',
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,1207
147
- def <<(expectation)<<46,1460
148
- def find_expectation(*args) # :nodoc:find_expectation51,1584
149
- def flexmock_verify # :nodoc:flexmock_verify62,1958
150
- def defaultify_expectation(exp) # :nodoc:defaultify_expectation69,2169
151
- def find_expectation_in(expectations, *args)find_expectation_in81,2450
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,12113
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,1380
182
+ lib/flexmock/partial_mock.rb,1375
183
183
  class FlexMockFlexMock14,337
184
- class PartialMockProxyPartialMockProxy26,968
185
- def initialize(obj, mock, safe_mode)initialize40,1310
186
- def flexmock_getflexmock_get56,1722
187
- def should_receive(*args)should_receive80,2662
188
- def add_mock_method(obj, method_name)add_mock_method91,2940
189
- def new_instances(*allocators, &block)new_instances119,3994
190
- def invoke_original(method, args)invoke_original140,4796
191
- def flexmock_verifyflexmock_verify148,5090
192
- def flexmock_teardownflexmock_teardown153,5226
193
- def flexmock_containerflexmock_container165,5564
194
- def flexmock_container=(container)flexmock_container=171,5759
195
- def flexmock_expectations_for(method_name)flexmock_expectations_for175,5875
196
- def sclasssclass182,6036
197
- def singleton?(method_name)singleton?188,6177
198
- def hide_existing_method(method_name)hide_existing_method198,6639
199
- def stow_existing_definition(method_name)stow_existing_definition205,6856
200
- def create_alias_for_existing_method(method_name)create_alias_for_existing_method225,7573
201
- def define_proxy_method(method_name)define_proxy_method243,8092
202
- def restore_original_definition(method_name)restore_original_definition264,8792
203
- def remove_current_method(method_name)remove_current_method276,9156
204
- def detached?detached?281,9317
205
- def new_name(old_name)new_name286,9425
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,337
230
- class RSpecFrameworkAdapterRSpecFrameworkAdapter16,355
231
- def assert_block(msg, &block)assert_block17,385
232
- def assert_equal(a, b, msg=nil)assert_equal21,481
233
- class AssertionFailedError < StandardError; endAssertionFailedError26,644
234
- def assertion_failed_errorassertion_failed_error27,696
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,390
550
- def test_recording_mode_workstest_recording_mode_works20,505
551
- def test_arguments_are_passed_to_recording_mode_blocktest_arguments_are_passed_to_recording_mode_block28,687
552
- def test_recording_mode_handles_multiple_returnstest_recording_mode_handles_multiple_returns39,962
553
- def test_recording_mode_does_not_specify_ordertest_recording_mode_does_not_specify_order53,1386
554
- def test_recording_mode_gets_block_args_tootest_recording_mode_gets_block_args_too64,1632
555
- def test_recording_mode_should_validate_args_with_equalstest_recording_mode_should_validate_args_with_equals76,1914
556
- def test_recording_mode_should_allow_arg_contraint_validationtest_recording_mode_should_allow_arg_contraint_validation87,2149
557
- def test_recording_mode_should_handle_multiplicity_contraintstest_recording_mode_should_handle_multiplicity_contraints98,2390
558
- def test_strict_record_mode_requires_exact_argument_matchestest_strict_record_mode_requires_exact_argument_matches110,2657
559
- def test_strict_record_mode_requires_exact_orderingtest_strict_record_mode_requires_exact_ordering122,2937
560
- def test_strict_record_mode_requires_oncetest_strict_record_mode_requires_once136,3242
561
- def test_strict_record_mode_can_not_failtest_strict_record_mode_can_not_fail149,3517
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_operator1071,27932
738
- class TestFlexMockShouldsWithInclude < Test::Unit::TestCaseTestFlexMockShouldsWithInclude1079,28086
739
- def test_include_enables_unqualified_arg_type_referencestest_include_enables_unqualified_arg_type_references1081,28180
740
- class TestFlexMockArgTypesDontLeak < Test::Unit::TestCaseTestFlexMockArgTypesDontLeak1089,28344
741
- def test_unqualified_arg_type_references_are_undefined_by_defaulttest_unqualified_arg_type_references_are_undefined_by_default1090,28402
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.instance_eval {
243
+ if !obj.instance_variable_defined?("@flexmock_proxy") || obj.instance_variable_get("@flexmock_proxy").nil?
244
244
  mock = FlexMock.new(name, container)
245
- @flexmock_proxy ||= PartialMockProxy.new(obj, mock, safe_mode)
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: 45
4
+ hash: 43
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 9
10
- version: 0.8.9
9
+ - 10
10
+ version: 0.8.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jim Weirich