flexmock 1.3.3 → 2.0.0.rc1

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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.autotest +3 -0
  3. data/.gitignore +14 -0
  4. data/.togglerc +7 -0
  5. data/.travis.yml +5 -0
  6. data/.yardopts +2 -0
  7. data/CHANGES +11 -0
  8. data/Gemfile +1 -4
  9. data/README.md +39 -11
  10. data/Rakefile +6 -217
  11. data/doc/examples/rspec_examples_spec.rb +244 -0
  12. data/doc/examples/test_unit_examples_test.rb +240 -0
  13. data/doc/jamis.rb +591 -0
  14. data/flexmock.gemspec +33 -0
  15. data/lib/flexmock.rb +0 -1
  16. data/lib/flexmock/composite_expectation.rb +1 -1
  17. data/lib/flexmock/core.rb +3 -7
  18. data/lib/flexmock/core_class_methods.rb +5 -1
  19. data/lib/flexmock/default_framework_adapter.rb +2 -2
  20. data/lib/flexmock/expectation.rb +29 -3
  21. data/lib/flexmock/expectation_director.rb +1 -1
  22. data/lib/flexmock/minitest.rb +13 -0
  23. data/lib/flexmock/minitest_extensions.rb +26 -0
  24. data/lib/flexmock/minitest_integration.rb +111 -0
  25. data/lib/flexmock/mock_container.rb +1 -2
  26. data/lib/flexmock/partial_mock.rb +61 -104
  27. data/lib/flexmock/recorder.rb +1 -2
  28. data/lib/flexmock/rspec.rb +6 -3
  29. data/lib/flexmock/test_unit_integration.rb +14 -0
  30. data/lib/flexmock/validators.rb +5 -4
  31. data/lib/flexmock/version.rb +1 -9
  32. data/rakelib/metrics.rake +40 -0
  33. data/rakelib/preview.rake +4 -0
  34. data/rakelib/tags.rake +18 -0
  35. data/todo.txt +20 -0
  36. metadata +61 -86
  37. data/Gemfile.lock +0 -20
  38. data/doc/examples/rspec_examples_spec.rdoc +0 -245
  39. data/doc/examples/test_unit_examples_test.rdoc +0 -241
  40. data/test/aliasing_test.rb +0 -66
  41. data/test/assert_spy_called_test.rb +0 -119
  42. data/test/base_class_test.rb +0 -71
  43. data/test/based_partials_test.rb +0 -51
  44. data/test/container_methods_test.rb +0 -118
  45. data/test/default_framework_adapter_test.rb +0 -38
  46. data/test/demeter_mocking_test.rb +0 -191
  47. data/test/deprecated_methods_test.rb +0 -225
  48. data/test/examples_from_readme_test.rb +0 -157
  49. data/test/expectation_description_test.rb +0 -80
  50. data/test/extended_should_receive_test.rb +0 -69
  51. data/test/flexmodel_test.rb +0 -54
  52. data/test/mock_builder_test.rb +0 -68
  53. data/test/naming_test.rb +0 -84
  54. data/test/new_instances_test.rb +0 -215
  55. data/test/object_extensions_test.rb +0 -25
  56. data/test/partial_mock_test.rb +0 -458
  57. data/test/record_mode_test.rb +0 -158
  58. data/test/redirect_error.rb +0 -16
  59. data/test/rspec_integration/integration_spec.rb +0 -56
  60. data/test/rspec_integration/spy_example_spec.rb +0 -207
  61. data/test/samples_test.rb +0 -283
  62. data/test/should_ignore_missing_test.rb +0 -84
  63. data/test/should_receive_test.rb +0 -1155
  64. data/test/spys_test.rb +0 -215
  65. data/test/symbol_extensions_test.rb +0 -8
  66. data/test/test_class_extensions.rb +0 -34
  67. data/test/test_setup.rb +0 -92
  68. data/test/test_unit_integration/auto_test_unit_test.rb +0 -42
  69. data/test/test_unit_integration/minitest_teardown_test.rb +0 -14
  70. data/test/tu_integration_test.rb +0 -99
  71. data/test/undefined_test.rb +0 -87
@@ -1,51 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #---
4
- # Copyright 2003-2013 by Jim Weirich (jim.weirich@gmail.com).
5
- # All rights reserved.
6
-
7
- # Permission is granted for use, copying, modification, distribution,
8
- # and distribution of modified versions of this work as long as the
9
- # above copyright notice is included.
10
- #+++
11
-
12
- require 'test/test_setup'
13
-
14
- class BasedPartialsTest < Test::Unit::TestCase
15
- include FlexMock::TestCase
16
-
17
- def setup
18
- super
19
- FlexMock.partials_are_based = true
20
- end
21
-
22
- def teardown
23
- FlexMock.partials_are_based = false
24
- super
25
- end
26
-
27
- class Dog
28
- def bark
29
- :woof
30
- end
31
- end
32
-
33
- def test_based_partials_allow_stubbing_defined_methods
34
- dog = Dog.new
35
- flexmock(dog).should_receive(:bark => :mock_value)
36
- assert_equal :mock_value, dog.bark
37
- end
38
-
39
- def test_based_partials_disallow_stubbing_undefined_methods
40
- dog = Dog.new
41
- assert_raise(NoMethodError, /cannot stub.*wag.*explicitly/) do
42
- flexmock(dog).should_receive(:wag => :mock_value)
43
- end
44
- end
45
-
46
- def test_based_partials_allow_explicitly_stubbing_undefined_methods
47
- dog = Dog.new
48
- flexmock(dog).should_receive(:wag).explicitly.and_return(:mock_value)
49
- end
50
-
51
- end
@@ -1,118 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #---
4
- # Copyright 2003-2013 by Jim Weirich (jim.weirich@gmail.com).
5
- # All rights reserved.
6
-
7
- # Permission is granted for use, copying, modification, distribution,
8
- # and distribution of modified versions of this work as long as the
9
- # above copyright notice is included.
10
- #+++
11
-
12
- require "test/test_setup"
13
-
14
- # These tests exercise the interface used to define mocks
15
- class TestFlexmockContainerMethods < Test::Unit::TestCase
16
- include FlexMock::TestCase
17
-
18
- def test_simple_mock_creation
19
- mock = flexmock
20
- mock.should_receive(:hi).once.and_return(:lo)
21
- assert_equal :lo, mock.hi
22
- end
23
-
24
- def test_mock_with_name
25
- mock = flexmock("Danny")
26
- mock.should_receive(:xxx).with(1)
27
- ex = assert_raise(assertion_failed_error) { mock.xxx }
28
- assert_match(/Danny/, ex.message)
29
- end
30
-
31
- def test_mock_with_symbol_name
32
- mock = flexmock(:Danny)
33
- mock.should_receive(:xxx).with(1)
34
- ex = assert_raise(assertion_failed_error) { mock.xxx }
35
- assert_match(/Danny/, ex.message)
36
- end
37
-
38
- def test_mock_with_hash
39
- mock = flexmock(:hi => :lo, :good => :bye)
40
- assert_equal :lo, mock.hi
41
- assert_equal :bye, mock.good
42
- end
43
-
44
- def test_mock_with_name_and_hash
45
- mock = flexmock("Danny", :hi => :lo, :good => :bye)
46
- mock.should_receive(:xxx).with(1)
47
- assert_equal :lo, mock.hi
48
- assert_equal :bye, mock.good
49
- ex = assert_raise(assertion_failed_error) { mock.xxx }
50
- assert_match(/Danny/, ex.message)
51
- end
52
-
53
- def test_mock_with_name_hash_and_block
54
- mock = flexmock("Danny", :hi => :lo, :good => :bye) do |m|
55
- m.should_receive(:one).and_return(1)
56
- end
57
- assert_equal 1, mock.one
58
- assert_equal :lo, mock.hi
59
- end
60
-
61
- def test_basic_stub
62
- fido = Object.new
63
- mock = flexmock(fido)
64
- mock.should_receive(:wag).and_return(:happy)
65
- assert_equal :happy, fido.wag
66
- end
67
-
68
- def test_basic_stub_with_name
69
- fido = Object.new
70
- mock = flexmock(fido, "Danny")
71
- mock.should_receive(:xxx).with(1).and_return(:happy)
72
- ex = assert_raise(assertion_failed_error) { fido.xxx }
73
- assert_match(/Danny/, ex.message)
74
- end
75
-
76
- def test_stub_with_quick_definitions
77
- fido = Object.new
78
- flexmock(fido, :wag => :happy)
79
- assert_equal :happy, fido.wag
80
- end
81
-
82
- def test_stub_with_name_quick_definitions
83
- fido = Object.new
84
- mock = flexmock(fido, "Danny", :wag => :happy)
85
- mock.should_receive(:xxx).with(1).and_return(:happy)
86
- ex = assert_raise(assertion_failed_error) { fido.xxx }
87
- assert_match(/Danny/, ex.message)
88
- assert_equal :happy, fido.wag
89
- end
90
-
91
- def test_stubs_are_auto_verified
92
- fido = Object.new
93
- mock = flexmock(fido)
94
- mock.should_receive(:hi).once
95
- assert_raise(assertion_failed_error) { flexmock_verify }
96
- end
97
-
98
- def test_stubbing_a_string
99
- s = "hello"
100
- flexmock(:base, s, :length => 2)
101
- assert_equal 2, s.length
102
- end
103
-
104
- def test_multiple_stubs_work_with_same_partial_mock_proxy
105
- obj = Object.new
106
- mock1 = flexmock(obj)
107
- mock2 = flexmock(obj)
108
- assert_equal mock1, mock2
109
- end
110
-
111
- def test_multiple_stubs_layer_behavior
112
- obj = Object.new
113
- flexmock(obj, :hi => :lo)
114
- flexmock(obj, :high => :low)
115
- assert_equal :lo, obj.hi
116
- assert_equal :low, obj.high
117
- end
118
- end
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #---
4
- # Copyright 2003-2013 by Jim Weirich (jim.weirich@gmail.com).
5
- # All rights reserved.
6
-
7
- # Permission is granted for use, copying, modification, distribution,
8
- # and distribution of modified versions of this work as long as the
9
- # above copyright notice is included.
10
- #+++
11
-
12
- require "test/test_setup"
13
-
14
- class TestFlexmockDefaultFrameworkAdapter < Test::Unit::TestCase
15
- def setup
16
- @adapter = FlexMock::DefaultFrameworkAdapter.new
17
- end
18
-
19
- def test_assert_block_raises_exception
20
- assert_raise(FlexMock::DefaultFrameworkAdapter::AssertionFailedError) {
21
- @adapter.make_assertion("failure message") { false }
22
- }
23
- end
24
-
25
- def test_make_assertion_doesnt_raise_exception_when_making_assertion
26
- @adapter.make_assertion("failure message") { true }
27
- end
28
-
29
- def test_make_assertion_doesnt_raise_exception_when_asserting_equal
30
- @adapter.assert_equal("a", "a", "no message")
31
- end
32
-
33
- def test_assert_equal_can_fail
34
- assert_raise(FlexMock::DefaultFrameworkAdapter::AssertionFailedError) {
35
- @adapter.assert_equal("a", "b", "a should not equal b")
36
- }
37
- end
38
- end
@@ -1,191 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/test_setup'
4
-
5
- class TestDemeterMocking < Test::Unit::TestCase
6
- include FlexMock::TestCase
7
-
8
- def test_demeter_mocking_basics
9
- m = flexmock("A")
10
- m.should_receive("children.first").and_return(:first)
11
- assert_kind_of FlexMock, m
12
- assert_kind_of FlexMock, m.children
13
- assert_equal :first, m.children.first
14
- end
15
-
16
- def test_demeter_mocking_with_operators
17
- m = flexmock("A")
18
- m.should_receive("children.+@.last").and_return(:value)
19
- assert_kind_of FlexMock, m
20
- assert_kind_of FlexMock, m.children
21
- assert_kind_of FlexMock, + m.children
22
- assert_equal :value, (+ m.children).last
23
- end
24
-
25
- def test_demeter_mocking_with_multiple_operators
26
- m = flexmock("A")
27
- m.should_receive("+@.-@.~").and_return(:value)
28
- assert_equal :value, ~-+m
29
- end
30
-
31
- def test_multiple_demeter_mocks_on_same_branch_is_ok
32
- m = flexmock("A")
33
- m.should_receive("child.x.y.z.first").and_return(:first)
34
- m.should_receive("child.x.y.z.last").and_return(:last)
35
- assert_equal :first, m.child.x.y.z.first
36
- assert_equal :last, m.child.x.y.z.last
37
- end
38
-
39
- def test_multi_level_deep_demeter_violation_with_mock
40
- a = flexmock("a")
41
- a.should_receive("b.c.d.e.f.g.h.i.j.k").and_return(:xyzzy)
42
- assert_equal :xyzzy, a.b.c.d.e.f.g.h.i.j.k
43
- end
44
-
45
- def test_partial_with_demeter
46
- a = flexmock(Object.new, "a partial")
47
- a.should_receive("b.c").and_return(:xyzzy)
48
- assert_equal :xyzzy, a.b.c
49
- end
50
-
51
- def test_multi_level_deep_demeter_violation_with_partial
52
- a = flexmock(Object.new, "a")
53
- a.should_receive("b.c.d.e.f.g.h.i.j.k").and_return(:xyzzy)
54
- assert_equal :xyzzy, a.b.c.d.e.f.g.h.i.j.k
55
- end
56
-
57
- def test_final_method_can_have_multiple_expecations
58
- a = flexmock("a")
59
- a.should_receive("b.c.d.last").with(1).and_return(:one).once
60
- a.should_receive("b.c.d.last").with(2).and_return(:two).once
61
- assert_equal :one, a.b.c.d.last(1)
62
- assert_equal :two, a.b.c.d.last(2)
63
- end
64
-
65
- def test_conflicting_mock_declarations_raises_an_error
66
- m = flexmock("A")
67
- ex = assert_raise(FlexMock::UsageError) do
68
- m.should_receive("child").and_return(:xyzzy)
69
- m.should_receive("child.other").and_return(:other)
70
- m.child.other
71
- end
72
- assert_match(/conflicting/i, ex.message)
73
- assert_match(/mock\s+declaration/i, ex.message)
74
- assert_match(/child/i, ex.message)
75
- end
76
-
77
- def test_compatible_mock_declarations_are_ok_full_mock_version
78
- m = flexmock("A")
79
- b = flexmock("B")
80
- c = flexmock("C")
81
- m.should_receive(:b => b)
82
- b.should_receive(:c => c)
83
- c.should_receive(:foo => :bar)
84
- m.should_receive("b.c.baz").and_return(:barg)
85
- m.should_receive("b.zhar").and_return(:zzz)
86
-
87
- assert_equal :bar, m.b.c.foo
88
- assert_equal :barg, m.b.c.baz
89
- assert_equal :zzz, m.b.zhar
90
- end
91
-
92
- def test_compatible_mock_declarations_are_ok_partial_mock_version
93
- m = flexmock("A")
94
- b = flexmock(Object.new, "B")
95
- c = flexmock("C")
96
- m.should_receive(:b => b)
97
- b.should_receive(:c => c)
98
- c.should_receive(:foo => :bar)
99
- m.should_receive("b.c.baz").and_return(:barg)
100
- m.should_receive("b.zhar").and_return(:zzz)
101
-
102
- assert_equal :bar, m.b.c.foo
103
- assert_equal :barg, m.b.c.baz
104
- assert_equal :zzz, m.b.zhar
105
- end
106
-
107
- def test_paths
108
- m = flexmock("A")
109
- b = flexmock("B")
110
- m.should_receive("a.b" => b)
111
- m.should_receive("a.b.c.x" => 1)
112
- m.should_receive("a.b.c.y" => 2)
113
- end
114
-
115
- def test_conflicting_mock_declarations_in_reverse_order_does_not_raise_error
116
- # Not all conflicting definitions can be detected.
117
- m = flexmock("A")
118
- assert_failure do
119
- m.should_receive("child.other").and_return(:other)
120
- m.should_receive("child").and_return(:xyzzy)
121
- assert_equal :xyzzy, m.child.other
122
- end
123
- end
124
-
125
- def test_preestablishing_existing_mock_is_ok
126
- engine = flexmock("engine")
127
- car = flexmock("A")
128
- car.should_receive(:engine).and_return(engine)
129
- car.should_receive("engine.cylinder").and_return(:cyl)
130
- assert_equal :cyl, car.engine.cylinder
131
- end
132
-
133
- def test_quick_defs_can_use_demeter_mocking
134
- a = flexmock("a")
135
- a.should_receive("b.c.d.x").and_return(:x)
136
- a.should_receive("b.c.d.y").and_return(:y)
137
- a.should_receive("b.c.d.z").and_return(:z)
138
- assert_equal :x, a.b.c.d.x
139
- assert_equal :y, a.b.c.d.y
140
- assert_equal :z, a.b.c.d.z
141
- end
142
-
143
- def test_quick_defs_can_use_demeter_mocking_two
144
- a = flexmock("a", "b.c.d.xx" => :x, "b.c.d.yy" => :y, "b.c.d.zz" => :z)
145
- assert_equal :x, a.b.c.d.xx
146
- assert_equal :y, a.b.c.d.yy
147
- assert_equal :z, a.b.c.d.zz
148
- end
149
-
150
- def test_errors_on_ill_formed_method_names
151
- m = flexmock("a")
152
- [
153
- 'a(2)', '0a', 'a-b', 'a b', ' ', 'a ', ' b', 'a!b', "a?b", 'a=b'
154
- ].each do |method|
155
- assert_raise FlexMock::UsageError do m.should_receive(method) end
156
- end
157
- end
158
-
159
- def test_no_errors_on_well_formed_method_names
160
- m = flexmock("a")
161
- [
162
- 'a', 'a?', 'a!', 'a=', 'z0', 'save!'
163
- ].each do |method|
164
- assert_nothing_raised do m.should_receive(method) end
165
- end
166
- end
167
-
168
- def test_readme_example_1
169
- cog = flexmock("cog")
170
- cog.should_receive(:turn).once.and_return(:ok).mock
171
- joint = flexmock("gear", :cog => cog)
172
- axle = flexmock("axle", :universal_joint => joint)
173
- chassis = flexmock("chassis", :axle => axle)
174
- car = flexmock("car", :chassis => chassis)
175
- assert_equal :ok, car.chassis.axle.universal_joint.cog.turn
176
- end
177
-
178
- def test_readme_example_2
179
- car = flexmock("car")
180
- car.should_receive("chassis.axle.universal_joint.cog.turn" => :ok).once
181
- assert_equal :ok, car.chassis.axle.universal_joint.cog.turn
182
- end
183
-
184
- def test_readme_example_3
185
- car = flexmock("car")
186
- car.should_receive("chassis.axle.universal_joint.cog.turn").once.
187
- and_return(:ok)
188
- assert_equal :ok, car.chassis.axle.universal_joint.cog.turn
189
- end
190
-
191
- end
@@ -1,225 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #---
4
- # Copyright 2003-2013 by Jim Weirich (jim.weirich@gmail.com).
5
- # All rights reserved.
6
-
7
- # Permission is granted for use, copying, modification, distribution,
8
- # and distribution of modified versions of this work as long as the
9
- # above copyright notice is included.
10
- #+++
11
-
12
- require 'test/test_setup'
13
- require 'flexmock/deprecated_methods'
14
-
15
- class TestFlexMock < Test::Unit::TestCase
16
- include FlexMock::TestCase
17
- include FlexMock::RedirectError
18
-
19
- def s(&block)
20
- redirect_error(&block)
21
- end
22
-
23
- def setup
24
- @mock = flexmock('mock')
25
- end
26
-
27
- def test_handle
28
- args = nil
29
- s { @mock.mock_handle(:hi) { |a, b| args = [a,b] } }
30
- @mock.hi(1,2)
31
- assert_equal [1,2], args
32
- end
33
-
34
- def test_handle_no_block
35
- s { @mock.mock_handle(:blip) }
36
- @mock.blip
37
- assert true, "just checking for failures"
38
- end
39
-
40
- def test_called_with_block
41
- called = false
42
- s { @mock.mock_handle(:blip) { |block| block.call } }
43
- @mock.blip { called = true }
44
- assert called, "Block to blip should be called"
45
- end
46
-
47
- def test_return_value
48
- s { @mock.mock_handle(:blip) { 10 } }
49
- assert_equal 10, @mock.blip
50
- end
51
-
52
- def test_handle_missing_method
53
- expected_error = (RUBY_VERSION >= "1.8.0") ? NoMethodError : NameError
54
- ex = assert_raises(expected_error) {
55
- @mock.not_defined
56
- }
57
- assert_match(/not_defined/, ex.message)
58
- end
59
-
60
- def test_ignore_missing_method
61
- @mock.mock_ignore_missing
62
- @mock.blip
63
- assert true, "just checking for failures"
64
- end
65
-
66
- def test_good_counts
67
- s { @mock.mock_handle(:blip, 3) }
68
- @mock.blip
69
- @mock.blip
70
- @mock.blip
71
- @mock.flexmock_verify
72
- end
73
-
74
- def test_bad_counts
75
- s { @mock.mock_handle(:blip, 3) }
76
- @mock.blip
77
- @mock.blip
78
- begin
79
- @mock.flexmock_verify
80
- rescue assertion_failed_error => err
81
- end
82
- assert_not_nil err
83
- end
84
-
85
- def test_undetermined_counts
86
- FlexMock.use('fs') { |m|
87
- s { m.mock_handle(:blip) }
88
- m.blip
89
- m.blip
90
- m.blip
91
- }
92
- end
93
-
94
- def test_zero_counts
95
- assert_raises(assertion_failed_error) do
96
- FlexMock.use { |m|
97
- s { m.mock_handle(:blip, 0) }
98
- m.blip
99
- }
100
- end
101
- end
102
-
103
- def test_file_io_with_use
104
- FlexMock.use do |m|
105
- filedata = ["line 1", "line 2"]
106
- s { m.mock_handle(:gets, 3) { filedata.shift } }
107
- assert_equal 2, count_lines(m)
108
- end
109
- end
110
-
111
- def count_lines(stream)
112
- result = 0
113
- while stream.gets
114
- result += 1
115
- end
116
- result
117
- end
118
-
119
- def test_use
120
- assert_raises(assertion_failed_error) {
121
- FlexMock.use do |m|
122
- s { m.mock_handle(:blip, 2) }
123
- m.blip
124
- end
125
- }
126
- end
127
-
128
- def test_failures_during_use
129
- ex = assert_raises(NameError) {
130
- FlexMock.use do |m|
131
- s { m.mock_handle(:blip, 2) }
132
- xyz
133
- end
134
- }
135
- assert_match(/undefined local variable or method/, ex.message)
136
- end
137
-
138
- def test_sequential_values
139
- values = [1,4,9,16]
140
- s { @mock.mock_handle(:get) { values.shift } }
141
- assert_equal 1, @mock.get
142
- assert_equal 4, @mock.get
143
- assert_equal 9, @mock.get
144
- assert_equal 16, @mock.get
145
- end
146
-
147
- def test_respond_to_returns_false_for_non_handled_methods
148
- assert(!@mock.respond_to?(:blah), "should not respond to blah")
149
- end
150
-
151
- def test_respond_to_returns_true_for_explicit_methods
152
- s { @mock.mock_handle(:xyz) }
153
- assert(@mock.respond_to?(:xyz), "should respond to test")
154
- end
155
-
156
- def test_respond_to_returns_true_for_missing_methods_when_ignoring_missing
157
- @mock.mock_ignore_missing
158
- assert(@mock.respond_to?(:yada), "should respond to yada now")
159
- end
160
-
161
- def test_respond_to_returns_true_for_missing_methods_when_ignoring_missing_using_should
162
- @mock.should_ignore_missing
163
- assert(@mock.respond_to?(:yada), "should respond to yada now")
164
- end
165
-
166
- def test_method_proc_raises_error_on_unknown
167
- assert_raises(NameError) {
168
- @mock.method(:xyzzy)
169
- }
170
- end
171
-
172
- def test_method_returns_callable_proc
173
- got_it = false
174
- s { @mock.mock_handle(:xyzzy) { got_it = true } }
175
- method_proc = @mock.method(:xyzzy)
176
- assert_not_nil method_proc
177
- method_proc.call([])
178
- assert(got_it, "method proc should run")
179
- end
180
-
181
- def test_method_returns_do_nothing_proc_for_missing_methods
182
- @mock.mock_ignore_missing
183
- method_proc = @mock.method(:plugh)
184
- assert_not_nil method_proc
185
- assert_equal FlexMock.undefined, method_proc.call
186
- end
187
- end
188
-
189
- class TestDeprecatedOrderingMethods < Test::Unit::TestCase
190
- include FlexMock::TestCase
191
- include FlexMock::RedirectError
192
-
193
- def test_deprecated_ordering_methods
194
- flexmock(:x).should_receive(:msg).globally.ordered(:testgroup)
195
- assert_equal({ :testgroup => 1 }, flexmock_groups)
196
- message = redirect_error do
197
- assert_equal({ :testgroup => 1 }, mock_groups)
198
- end
199
- assert_match(/deprecated/i, message)
200
- assert_match(/\bmock_groups/, message)
201
- assert_match(/\bflexmock_groups/, message)
202
- end
203
- end
204
-
205
- class TestAnyInstance < Test::Unit::TestCase
206
- include FlexMock::TestCase
207
- include FlexMock::RedirectError
208
-
209
- class Dog
210
- def bark
211
- :woof
212
- end
213
- end
214
-
215
- def test_any_instance_still_works_for_backwards_compatibility
216
- message = redirect_error do
217
- flexstub(Dog).any_instance do |obj|
218
- obj.should_receive(:bark).and_return(:whimper)
219
- assert_match(/deprecated/, message)
220
- end
221
- end
222
- m = Dog.new
223
- assert_equal :whimper, m.bark
224
- end
225
- end