flexmock 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/CHANGELOG +10 -1
  2. data/README +390 -209
  3. data/Rakefile +31 -10
  4. data/doc/GoogleExample.rdoc +275 -0
  5. data/doc/releases/flexmock-0.6.0.rdoc +136 -0
  6. data/lib/flexmock.rb +3 -1160
  7. data/lib/flexmock/argument_matchers.rb +57 -0
  8. data/lib/flexmock/argument_types.rb +42 -0
  9. data/lib/flexmock/base.rb +22 -0
  10. data/lib/flexmock/composite.rb +10 -0
  11. data/lib/flexmock/core.rb +206 -0
  12. data/lib/flexmock/core_class_methods.rb +92 -0
  13. data/lib/flexmock/default_framework_adapter.rb +31 -0
  14. data/lib/flexmock/expectation.rb +334 -0
  15. data/lib/flexmock/expectation_director.rb +59 -0
  16. data/lib/flexmock/mock_container.rb +159 -0
  17. data/lib/flexmock/noop.rb +13 -0
  18. data/lib/flexmock/partial_mock.rb +226 -0
  19. data/lib/flexmock/recorder.rb +71 -0
  20. data/lib/flexmock/rspec.rb +34 -0
  21. data/lib/flexmock/test_unit.rb +32 -0
  22. data/lib/flexmock/test_unit_integration.rb +53 -0
  23. data/lib/flexmock/validators.rb +77 -0
  24. data/test/rspec_integration/integration_spec.rb +36 -0
  25. data/test/test_container_methods.rb +119 -0
  26. data/test/test_default_framework_adapter.rb +39 -0
  27. data/test/test_example.rb +1 -1
  28. data/test/test_extended_should_receive.rb +63 -0
  29. data/test/test_mock.rb +1 -1
  30. data/test/test_naming.rb +1 -1
  31. data/test/{test_any_instance.rb → test_new_instances.rb} +15 -8
  32. data/test/{test_stubbing.rb → test_partial_mock.rb} +44 -44
  33. data/test/test_record_mode.rb +1 -1
  34. data/test/test_samples.rb +6 -8
  35. data/test/test_should_receive.rb +7 -3
  36. data/test/test_tu_integration.rb +1 -1
  37. data/test/test_unit_integration/test_auto_test_unit.rb +34 -0
  38. metadata +30 -5
  39. data/test/test_class_interception.rb +0 -140
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #---
4
+ # Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
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
+ Spec::Runner.configure do |config|
13
+ config.mock_with :flexmock
14
+ end
15
+
16
+ context "FlexMock in a RSpec example" do
17
+ specify "should be able to create a mock" do
18
+ m = flexmock()
19
+ end
20
+
21
+ specify "should have an error when a mock is not called" do
22
+ m = flexmock("Expectation Failured")
23
+ m.should_receive(:hi).with().once
24
+ end
25
+
26
+ specify "should be able to create a stub" do
27
+ s = "Hello World"
28
+ flexmock(:base, s).should_receive(:downcase).with().once.and_return("hello WORLD")
29
+
30
+ s.downcase.should == "hello WORLD"
31
+ end
32
+
33
+ specify "Should show an example failure" do
34
+ 1.should == 2
35
+ end
36
+ end
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #---
4
+ # Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
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/unit"
13
+ require "flexmock"
14
+
15
+ # These tests exercise the interface used to define mocks
16
+ class TestFlexmockContainerMethods < Test::Unit::TestCase
17
+ include FlexMock::TestCase
18
+
19
+ def test_simple_mock_creation
20
+ mock = flexmock
21
+ mock.should_receive(:hi).once.and_return(:lo)
22
+ assert_equal :lo, mock.hi
23
+ end
24
+
25
+ def test_mock_with_name
26
+ mock = flexmock("Danny")
27
+ mock.should_receive(:xxx).with(1)
28
+ ex = assert_raise(Test::Unit::AssertionFailedError) { mock.xxx }
29
+ assert_match(/Danny/, ex.message)
30
+ end
31
+
32
+ def test_mock_with_symbol_name
33
+ mock = flexmock(:Danny)
34
+ mock.should_receive(:xxx).with(1)
35
+ ex = assert_raise(Test::Unit::AssertionFailedError) { mock.xxx }
36
+ assert_match(/Danny/, ex.message)
37
+ end
38
+
39
+ def test_mock_with_hash
40
+ mock = flexmock(:hi => :lo, :good => :bye)
41
+ assert_equal :lo, mock.hi
42
+ assert_equal :bye, mock.good
43
+ end
44
+
45
+ def test_mock_with_name_and_hash
46
+ mock = flexmock("Danny", :hi => :lo, :good => :bye)
47
+ mock.should_receive(:xxx).with(1)
48
+ assert_equal :lo, mock.hi
49
+ assert_equal :bye, mock.good
50
+ ex = assert_raise(Test::Unit::AssertionFailedError) { mock.xxx }
51
+ assert_match(/Danny/, ex.message)
52
+ end
53
+
54
+ def test_mock_with_name_hash_and_block
55
+ mock = flexmock("Danny", :hi => :lo, :good => :bye) do |m|
56
+ m.should_receive(:one).and_return(1)
57
+ end
58
+ assert_equal 1, mock.one
59
+ assert_equal :lo, mock.hi
60
+ end
61
+
62
+ def test_basic_stub
63
+ fido = Object.new
64
+ mock = flexmock(fido)
65
+ mock.should_receive(:wag).and_return(:happy)
66
+ assert_equal :happy, fido.wag
67
+ end
68
+
69
+ def test_basic_stub_with_name
70
+ fido = Object.new
71
+ mock = flexmock(fido, "Danny")
72
+ mock.should_receive(:xxx).with(1).and_return(:happy)
73
+ ex = assert_raise(Test::Unit::AssertionFailedError) { fido.xxx }
74
+ assert_match(/Danny/, ex.message)
75
+ end
76
+
77
+ def test_stub_with_quick_definitions
78
+ fido = Object.new
79
+ mock = flexmock(fido, :wag => :happy)
80
+ assert_equal :happy, fido.wag
81
+ end
82
+
83
+ def test_stub_with_name_quick_definitions
84
+ fido = Object.new
85
+ mock = flexmock(fido, "Danny", :wag => :happy)
86
+ mock.should_receive(:xxx).with(1).and_return(:happy)
87
+ ex = assert_raise(Test::Unit::AssertionFailedError) { fido.xxx }
88
+ assert_match(/Danny/, ex.message)
89
+ assert_equal :happy, fido.wag
90
+ end
91
+
92
+ def test_stubs_are_auto_verified
93
+ fido = Object.new
94
+ mock = flexmock(fido)
95
+ mock.should_receive(:hi).once
96
+ ex = assert_raise(Test::Unit::AssertionFailedError) { flexmock_verify }
97
+ end
98
+
99
+ def test_stubbing_a_string
100
+ s = "hello"
101
+ mock = flexmock(:base, s, :length => 2)
102
+ assert_equal 2, s.length
103
+ end
104
+
105
+ def test_multiple_stubs_work_with_same_PartialMock
106
+ obj = Object.new
107
+ mock1 = flexmock(obj)
108
+ mock2 = flexmock(obj)
109
+ assert_equal mock1, mock2
110
+ end
111
+
112
+ def test_multiple_stubs_layer_behavior
113
+ obj = Object.new
114
+ flexmock(obj, :hi => :lo)
115
+ flexmock(obj, :high => :low)
116
+ assert_equal :lo, obj.hi
117
+ assert_equal :low, obj.high
118
+ end
119
+ end
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #---
4
+ # Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
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/unit"
13
+ require "flexmock"
14
+
15
+ class TestFlexmockDefaultFrameworkAdapter < Test::Unit::TestCase
16
+ def setup
17
+ @adapter = FlexMock::DefaultFrameworkAdapter.new
18
+ end
19
+
20
+ def test_assert_block_raises_exception
21
+ ex = assert_raise(FlexMock::DefaultFrameworkAdapter::AssertionFailedError) {
22
+ @adapter.assert_block("failure message") { false }
23
+ }
24
+ end
25
+
26
+ def test_assert_block_doesnt_raise_exception
27
+ @adapter.assert_block("failure message") { true }
28
+ end
29
+
30
+ def test_assert_equal_doesnt_raise_exception
31
+ @adapter.assert_equal("a", "a", "no message")
32
+ end
33
+
34
+ def test_assert_equal_can_fail
35
+ ex = assert_raise(FlexMock::DefaultFrameworkAdapter::AssertionFailedError) {
36
+ @adapter.assert_equal("a", "b", "a should not equal b")
37
+ }
38
+ end
39
+ end
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  #---
4
- # Copyright 2006 by Jim Weirich (jweirich@one.net).
4
+ # Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
5
5
  # All rights reserved.
6
6
 
7
7
  # Permission is granted for use, copying, modification, distribution,
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #---
4
+ # Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
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/unit"
13
+ require "flexmock"
14
+
15
+ module ExtendedShouldReceiveTests
16
+ def test_accepts_expectation_hash
17
+ @mock.should_receive( :foo => :bar, :baz => :froz )
18
+ assert_equal :bar, @obj.foo
19
+ assert_equal :froz, @obj.baz
20
+ end
21
+
22
+ def test_accepts_list_of_methods
23
+ @mock.should_receive(:foo, :bar, "baz")
24
+ assert_nil @obj.foo
25
+ assert_nil @obj.bar
26
+ assert_nil @obj.baz
27
+ end
28
+
29
+ def test_contraints_apply_to_all_expectations
30
+ @mock.should_receive(:foo, :bar => :baz).with(1)
31
+ ex = assert_raise(Test::Unit::AssertionFailedError) { @obj.foo(2) }
32
+ ex = assert_raise(Test::Unit::AssertionFailedError) { @obj.bar(2) }
33
+ assert_equal :baz, @obj.bar(1)
34
+ end
35
+
36
+ def test_multiple_should_receives_are_allowed
37
+ @mock.should_receive(:hi).and_return(:bye).should_receive(:hello => :goodbye)
38
+ assert_equal :bye, @obj.hi
39
+ assert_equal :goodbye, @obj.hello
40
+ end
41
+ end
42
+
43
+ class TestExtendedShouldReceiveOnFullMocks < Test::Unit::TestCase
44
+ include FlexMock::TestCase
45
+ include ExtendedShouldReceiveTests
46
+
47
+ def setup
48
+ @mock = flexmock("mock")
49
+ @obj = @mock
50
+ end
51
+
52
+ end
53
+
54
+ class TestExtendedShouldReceiveOnPartialMocks < Test::Unit::TestCase
55
+ include FlexMock::TestCase
56
+ include ExtendedShouldReceiveTests
57
+
58
+ def setup
59
+ @obj = Object.new
60
+ @mock = flexmock(@obj, "mock")
61
+ end
62
+
63
+ end
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  #---
4
- # Copyright 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
4
+ # Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
5
5
  # All rights reserved.
6
6
 
7
7
  # Permission is granted for use, copying, modification, distribution,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  #---
4
- # Copyright 2006 by Jim Weirich (jweirich@one.net).
4
+ # Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
5
5
  # All rights reserved.
6
6
 
7
7
  # Permission is granted for use, copying, modification, distribution,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  #---
4
- # Copyright 2006 by Jim Weirich (jweirich@one.net).
4
+ # Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
5
5
  # All rights reserved.
6
6
 
7
7
  # Permission is granted for use, copying, modification, distribution,
@@ -12,7 +12,7 @@
12
12
  require 'test/unit'
13
13
  require 'flexmock'
14
14
 
15
- class TestStubbingOnNew < Test::Unit::TestCase
15
+ class TestNewInstances < Test::Unit::TestCase
16
16
  include FlexMock::TestCase
17
17
 
18
18
  class Dog
@@ -46,12 +46,6 @@ class TestStubbingOnNew < Test::Unit::TestCase
46
46
  :unstubbed
47
47
  end
48
48
  end
49
-
50
- def test_new_instances_requires_block
51
- ex = assert_raise(ArgumentError) {
52
- flexstub(Dog).new_instances
53
- }
54
- end
55
49
 
56
50
  def test_new_instances_allows_stubbing_of_existing_methods
57
51
  flexstub(Dog).new_instances do |obj|
@@ -184,6 +178,19 @@ class TestStubbingOnNew < Test::Unit::TestCase
184
178
  assert block_run
185
179
  end
186
180
 
181
+ def test_new_instances_accept_chained_expectations
182
+ flexmock(Dog).new_instances.
183
+ should_receive(:growl).and_return(:grr).
184
+ should_receive(:roll_over).and_return(:flip)
185
+ assert_equal :grr, Dog.new.growl
186
+ assert_equal :flip, Dog.new.roll_over
187
+ end
188
+
189
+ def test_fancy_use_of_chained_should_received
190
+ flexmock(Dog).new_instances.should_receive(:woof => :grrr)
191
+ assert_equal :grrr, Dog.new.woof
192
+ end
193
+
187
194
  def redirect_error
188
195
  require 'stringio'
189
196
  old_err = $stderr
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  #---
4
- # Copyright 2006 by Jim Weirich (jweirich@one.net).
4
+ # Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
5
5
  # All rights reserved.
6
6
 
7
7
  # Permission is granted for use, copying, modification, distribution,
@@ -27,13 +27,13 @@ class TestStubbing < Test::Unit::TestCase
27
27
 
28
28
  def test_stub_command_add_behavior_to_arbitrary_objects
29
29
  obj = Object.new
30
- flexstub(obj).should_receive(:hi).once.and_return(:stub_hi)
30
+ flexmock(obj).should_receive(:hi).once.and_return(:stub_hi)
31
31
  assert_equal :stub_hi, obj.hi
32
32
  end
33
33
 
34
34
  def test_stub_command_can_configure_via_block
35
35
  obj = Object.new
36
- flexstub(obj) do |m|
36
+ flexmock(obj) do |m|
37
37
  m.should_receive(:hi).once.and_return(:stub_hi)
38
38
  end
39
39
  assert_equal :stub_hi, obj.hi
@@ -41,99 +41,99 @@ class TestStubbing < Test::Unit::TestCase
41
41
 
42
42
  def test_stubbed_methods_can_take_blocks
43
43
  obj = Object.new
44
- flexstub(obj).should_receive(:with_block).once.with(Proc).
44
+ flexmock(obj).should_receive(:with_block).once.with(Proc).
45
45
  and_return { |block| block.call }
46
46
  assert_equal :block, obj.with_block { :block }
47
47
  end
48
48
 
49
- def test_multiple_stubs_on_the_same_object_reuse_the_same_stub_proxy
49
+ def test_multiple_stubs_on_the_same_object_reuse_the_same_partial_mock
50
50
  obj = Object.new
51
- assert_equal flexstub(obj), flexstub(obj)
51
+ assert_equal flexmock(obj), flexmock(obj)
52
52
  end
53
53
 
54
54
  def test_multiple_methods_can_be_stubbed
55
55
  dog = Dog.new
56
- flexstub(dog).should_receive(:bark).and_return(:grrrr)
57
- flexstub(dog).should_receive(:wag).and_return(:happy)
56
+ flexmock(dog).should_receive(:bark).and_return(:grrrr)
57
+ flexmock(dog).should_receive(:wag).and_return(:happy)
58
58
  assert_equal :grrrr, dog.bark
59
59
  assert_equal :happy, dog.wag
60
60
  end
61
61
 
62
62
  def test_original_behavior_can_be_restored
63
63
  dog = Dog.new
64
- stub_proxy = flexstub(dog)
65
- stub_proxy.should_receive(:bark).once.and_return(:growl)
64
+ partial_mock = flexmock(dog)
65
+ partial_mock.should_receive(:bark).once.and_return(:growl)
66
66
  assert_equal :growl, dog.bark
67
- stub_proxy.mock_teardown
67
+ partial_mock.mock_teardown
68
68
  assert_equal :woof, dog.bark
69
69
  assert_equal nil, dog.instance_variable_get("@flexmock_proxy")
70
70
  end
71
71
 
72
72
  def test_original_missing_behavior_can_be_restored
73
73
  obj = Object.new
74
- stub_proxy = flexstub(obj)
75
- stub_proxy.should_receive(:hi).once.and_return(:ok)
74
+ partial_mock = flexmock(obj)
75
+ partial_mock.should_receive(:hi).once.and_return(:ok)
76
76
  assert_equal :ok, obj.hi
77
- stub_proxy.mock_teardown
77
+ partial_mock.mock_teardown
78
78
  assert_raise(NoMethodError) { obj.hi }
79
79
  end
80
80
 
81
81
  def test_multiple_stubs_on_single_method_can_be_restored_missing_method
82
82
  obj = Object.new
83
- stub_proxy = flexstub(obj)
84
- stub_proxy.should_receive(:hi).with(1).once.and_return(:ok)
85
- stub_proxy.should_receive(:hi).with(2).once.and_return(:ok)
83
+ partial_mock = flexmock(obj)
84
+ partial_mock.should_receive(:hi).with(1).once.and_return(:ok)
85
+ partial_mock.should_receive(:hi).with(2).once.and_return(:ok)
86
86
  assert_equal :ok, obj.hi(1)
87
87
  assert_equal :ok, obj.hi(2)
88
- stub_proxy.mock_teardown
88
+ partial_mock.mock_teardown
89
89
  assert_raise(NoMethodError) { obj.hi }
90
90
  end
91
91
 
92
92
  def test_original_behavior_is_restored_when_multiple_methods_are_mocked
93
93
  dog = Dog.new
94
- flexstub(dog).should_receive(:bark).and_return(:grrrr)
95
- flexstub(dog).should_receive(:wag).and_return(:happy)
96
- flexstub(dog).mock_teardown
94
+ flexmock(dog).should_receive(:bark).and_return(:grrrr)
95
+ flexmock(dog).should_receive(:wag).and_return(:happy)
96
+ flexmock(dog).mock_teardown
97
97
  assert_equal :woof, dog.bark
98
98
  assert_raise(NoMethodError) { dog.wag }
99
99
  end
100
100
 
101
101
  def test_original_behavior_is_restored_on_class_objects
102
- flexstub(Dog).should_receive(:create).once.and_return(:new_stub)
102
+ flexmock(Dog).should_receive(:create).once.and_return(:new_stub)
103
103
  assert_equal :new_stub, Dog.create
104
- flexstub(Dog).mock_teardown
104
+ flexmock(Dog).mock_teardown
105
105
  assert_equal :new_dog, Dog.create
106
106
  end
107
107
 
108
108
  def test_original_behavior_is_restored_on_singleton_methods
109
109
  obj = Object.new
110
110
  def obj.hi() :hello end
111
- flexstub(obj).should_receive(:hi).once.and_return(:hola)
111
+ flexmock(obj).should_receive(:hi).once.and_return(:hola)
112
112
 
113
113
  assert_equal :hola, obj.hi
114
- flexstub(obj).mock_teardown
114
+ flexmock(obj).mock_teardown
115
115
  assert_equal :hello, obj.hi
116
116
  end
117
117
 
118
118
  def test_original_behavior_is_restored_on_singleton_methods_with_multiple_stubs
119
119
  obj = Object.new
120
120
  def obj.hi(n) "hello#{n}" end
121
- flexstub(obj).should_receive(:hi).with(1).once.and_return(:hola)
122
- flexstub(obj).should_receive(:hi).with(2).once.and_return(:hola)
121
+ flexmock(obj).should_receive(:hi).with(1).once.and_return(:hola)
122
+ flexmock(obj).should_receive(:hi).with(2).once.and_return(:hola)
123
123
 
124
124
  assert_equal :hola, obj.hi(1)
125
125
  assert_equal :hola, obj.hi(2)
126
- flexstub(obj).mock_teardown
126
+ flexmock(obj).mock_teardown
127
127
  assert_equal "hello3", obj.hi(3)
128
128
  end
129
129
 
130
130
  def test_original_behavior_is_restored_on_nonsingleton_methods_with_multiple_stubs
131
- flexstub(Dir).should_receive(:chdir).with("xx").once.and_return(:ok1)
132
- flexstub(Dir).should_receive(:chdir).with("yy").once.and_return(:ok2)
131
+ flexmock(Dir).should_receive(:chdir).with("xx").once.and_return(:ok1)
132
+ flexmock(Dir).should_receive(:chdir).with("yy").once.and_return(:ok2)
133
133
  assert_equal :ok1, Dir.chdir("xx")
134
134
  assert_equal :ok2, Dir.chdir("yy")
135
135
 
136
- flexstub(Dir).mock_teardown
136
+ flexmock(Dir).mock_teardown
137
137
 
138
138
  x = :not_called
139
139
  Dir.chdir("test") do
@@ -144,9 +144,9 @@ class TestStubbing < Test::Unit::TestCase
144
144
  end
145
145
 
146
146
  def test_stubbing_file_shouldnt_break_writing
147
- flexstub(File).should_receive(:open).with("foo").once.and_return(:ok)
147
+ flexmock(File).should_receive(:open).with("foo").once.and_return(:ok)
148
148
  assert_equal :ok, File.open("foo")
149
- flexstub(File).mock_teardown
149
+ flexmock(File).mock_teardown
150
150
 
151
151
  File.open("dummy.txt", "w") do |out|
152
152
  assert out.is_a?(IO)
@@ -160,44 +160,44 @@ class TestStubbing < Test::Unit::TestCase
160
160
  end
161
161
 
162
162
  def test_original_behavior_is_restored_even_when_errors
163
- flexstub(Dog).should_receive(:create).once.and_return(:mock)
163
+ flexmock(Dog).should_receive(:create).once.and_return(:mock)
164
164
  flexmock_teardown rescue nil
165
165
  assert_equal :new_dog, Dog.create
166
166
 
167
167
  # Now disable the mock so that it doesn't cause errors on normal
168
168
  # test teardown
169
- m = flexstub(Dog).mock
169
+ m = flexmock(Dog).mock
170
170
  def m.mock_verify() end
171
171
  end
172
172
 
173
173
  def test_not_calling_stubbed_method_is_an_error
174
174
  dog = Dog.new
175
- flexstub(dog).should_receive(:bark).once
175
+ flexmock(dog).should_receive(:bark).once
176
176
  assert_raise(Test::Unit::AssertionFailedError) {
177
- flexstub(dog).mock_verify
177
+ flexmock(dog).mock_verify
178
178
  }
179
179
  dog.bark
180
180
  end
181
181
 
182
182
  def test_mock_is_verified_when_the_stub_is_verified
183
183
  obj = Object.new
184
- stub_proxy = flexstub(obj)
185
- stub_proxy.should_receive(:hi).once.and_return(:ok)
184
+ partial_mock = flexmock(obj)
185
+ partial_mock.should_receive(:hi).once.and_return(:ok)
186
186
  assert_raise(Test::Unit::AssertionFailedError) {
187
- stub_proxy.mock_verify
187
+ partial_mock.mock_verify
188
188
  }
189
189
  end
190
190
 
191
191
  def test_stub_can_have_explicit_name
192
192
  obj = Object.new
193
- stub_proxy = flexstub(obj, "Charlie")
194
- assert_equal "Charlie", stub_proxy.mock.mock_name
193
+ partial_mock = flexmock(obj, "Charlie")
194
+ assert_equal "Charlie", partial_mock.mock.mock_name
195
195
  end
196
196
 
197
197
  def test_unamed_stub_will_use_default_naming_convention
198
198
  obj = Object.new
199
- stub_proxy = flexstub(obj)
200
- assert_equal "flexstub(Object)", stub_proxy.mock.mock_name
199
+ partial_mock = flexmock(obj)
200
+ assert_equal "flexmock(Object)", partial_mock.mock.mock_name
201
201
  end
202
202
 
203
203
  end