hardmock 1.2.0 → 1.2.3

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.
@@ -11,72 +11,6 @@ class AutoVerifyTest < Test::Unit::TestCase
11
11
  remove_temp_test_file
12
12
  end
13
13
 
14
- #
15
- # HELPERS
16
- #
17
-
18
- def temp_test_file
19
- File.expand_path(File.dirname(__FILE__) + "/tear_down_verification_test.rb")
20
- end
21
-
22
- def run_test(tbody)
23
- File.open(temp_test_file,"w") { |f| f.print(tbody) }
24
- @test_output = `ruby #{temp_test_file} 2>&1`
25
- # puts "------------------------"
26
- # puts @test_output
27
- # puts "------------------------"
28
- end
29
-
30
- def remove_temp_test_file
31
- FileUtils::rm_f temp_test_file
32
- end
33
-
34
- def assert_results(h)
35
- assert_match(/#{h[:tests]} tests, [0-9]+ assertions, #{h[:failures]} failures, #{h[:errors]} errors/,
36
- @test_output)
37
- end
38
-
39
- def assert_output_contains(*patterns)
40
- patterns.each do |pattern|
41
- assert_match(pattern,@test_output)
42
- end
43
- end
44
-
45
- def assert_output_doesnt_contain(*patterns)
46
- patterns.each do |pattern|
47
- assert @test_output !~ pattern, "Output shouldn't match #{pattern.inspect} but it does."
48
- end
49
- end
50
-
51
- def write_and_execute_test
52
- @test_code ||=<<-EOM
53
- def test_setup_doomed_expectation
54
- create_mock :automobile
55
- @automobile.expects.start
56
- end
57
- EOM
58
- @full_code ||=<<-EOTEST
59
- require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
60
- require 'hardmock'
61
- class DummyTest < Test::Unit::TestCase
62
- #{@teardown_code}
63
- #{@test_code}
64
- end
65
- EOTEST
66
- run_test @full_code
67
-
68
- if @expect_unmet_expectations
69
- assert_output_contains(/unmet expectations/i, /automobile/, /start/)
70
- else
71
- assert_output_doesnt_contain(/unmet expectations/i, /automobile/, /start/)
72
- end
73
-
74
- @expect_tests ||= 1
75
- @expect_failures ||= 0
76
- @expect_errors ||= 1
77
- assert_results :tests => @expect_tests, :failures => @expect_failures, :errors => @expect_errors
78
- end
79
-
80
14
  #
81
15
  # TESTS
82
16
  #
@@ -189,4 +123,71 @@ class AutoVerifyTest < Test::Unit::TestCase
189
123
  write_and_execute_test
190
124
  assert_output_contains(/Test helper teardown/, /User teardown/)
191
125
  end
126
+
127
+ #
128
+ # HELPERS
129
+ #
130
+
131
+ def temp_test_file
132
+ File.expand_path(File.dirname(__FILE__) + "/tear_down_verification_test.rb")
133
+ end
134
+
135
+ def run_test(tbody)
136
+ File.open(temp_test_file,"w") { |f| f.print(tbody) }
137
+ @test_output = `ruby #{temp_test_file} 2>&1`
138
+ # puts "------------------------"
139
+ # puts @test_output
140
+ # puts "------------------------"
141
+ end
142
+
143
+ def remove_temp_test_file
144
+ FileUtils::rm_f temp_test_file
145
+ end
146
+
147
+ def assert_results(h)
148
+ assert_match(/#{h[:tests]} tests, [0-9]+ assertions, #{h[:failures]} failures, #{h[:errors]} errors/,
149
+ @test_output)
150
+ end
151
+
152
+ def assert_output_contains(*patterns)
153
+ patterns.each do |pattern|
154
+ assert_match(pattern,@test_output)
155
+ end
156
+ end
157
+
158
+ def assert_output_doesnt_contain(*patterns)
159
+ patterns.each do |pattern|
160
+ assert @test_output !~ pattern, "Output shouldn't match #{pattern.inspect} but it does."
161
+ end
162
+ end
163
+
164
+ def write_and_execute_test
165
+ @test_code ||=<<-EOM
166
+ def test_setup_doomed_expectation
167
+ create_mock :automobile
168
+ @automobile.expects.start
169
+ end
170
+ EOM
171
+ @full_code ||=<<-EOTEST
172
+ require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
173
+ require 'hardmock'
174
+ class DummyTest < Test::Unit::TestCase
175
+ #{@teardown_code}
176
+ #{@test_code}
177
+ end
178
+ EOTEST
179
+ run_test @full_code
180
+
181
+ if @expect_unmet_expectations
182
+ assert_output_contains(/unmet expectations/i, /automobile/, /start/)
183
+ else
184
+ assert_output_doesnt_contain(/unmet expectations/i, /automobile/, /start/)
185
+ end
186
+
187
+ @expect_tests ||= 1
188
+ @expect_failures ||= 0
189
+ @expect_errors ||= 1
190
+ assert_results :tests => @expect_tests, :failures => @expect_failures, :errors => @expect_errors
191
+ end
192
+
192
193
  end
@@ -1,5 +1,7 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
2
  require 'hardmock'
3
+ require 'assert_error'
4
+
3
5
  class HardmockTest < Test::Unit::TestCase
4
6
 
5
7
  def setup
@@ -351,8 +353,8 @@ class HardmockTest < Test::Unit::TestCase
351
353
  assert_equal false, @car.ignition_on?, "Should be false"
352
354
  end
353
355
 
354
- def test_should_be_able_to_mock_methods_inherited_from_object
355
- target_methods = %w|to_s instance_eval instance_variables id clone display dup eql? ==|
356
+ def test_should_be_able_to_mock_some_methods_inherited_from_object
357
+ target_methods = %w|id clone display dup eql? ==|
356
358
  create_mock :foo
357
359
  target_methods.each do |m|
358
360
  eval %{@foo.expects(m, "some stuff")}
@@ -360,12 +362,56 @@ class HardmockTest < Test::Unit::TestCase
360
362
  end
361
363
  end
362
364
 
363
- def test_should_support_expect_and_should_receive_as_aliases_for_expects
365
+ def test_should_support_expect_as_an_alias_for_expects
364
366
  create_mock :foo
365
367
  @foo.expect.boomboom
366
368
  @foo.boomboom
367
369
  verify_mocks
368
370
  end
369
371
 
372
+ def test_should_not_raise_expectation_errors_for_some_methods_defined_on_object
373
+ create_mock :foo
374
+ @foo.method(:inspect)
375
+ @foo.inspect
376
+ @foo.to_s
377
+ @foo.instance_variables
378
+ @foo.instance_eval("")
379
+ verify_mocks
380
+ end
381
+
382
+ def test_should_support_raising_errors_within_expectation_blocks
383
+ create_mock :cat
384
+ @cat.expects.meow do |arg|
385
+ assert_equal "mix", arg
386
+ raise 'HAIRBALL'
387
+ end
388
+ assert_error RuntimeError, 'HAIRBALL' do
389
+ @cat.meow("mix")
390
+ end
391
+ end
392
+
393
+ def test_should_support_raising_errors_after_expectation_blocks
394
+ create_mock :cat
395
+ @cat.expects.meow do |arg|
396
+ assert_equal "mix", arg
397
+ end.raises('HAIRBALL')
398
+ assert_error RuntimeError, 'HAIRBALL' do
399
+ @cat.meow("mix")
400
+ end
401
+ end
402
+
403
+ def test_should_raise_when_create_mocks_is_given_a_nil_name
404
+ # I make this mistake all the time: Typing in an instance var name instead of a symbol in create_mocks.
405
+ # When you do that, you're effectively passing nil(s) in as mock names.
406
+ assert_error ArgumentError, /'nil' is not a valid name for a mock/ do
407
+ create_mocks @apples, @oranges
408
+ end
409
+ end
410
+
411
+ def test_should_display_mock_name_in_inspect_output
412
+ create_mock :hay_bailer
413
+ assert_equal "<Mock hay_bailer>", @hay_bailer.inspect, "Wrong output from 'inspect'"
414
+ end
415
+
370
416
  end
371
417
 
@@ -1,14 +1,15 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
- require 'hardmock'
2
+ require 'hardmock/expectation_builder'
3
3
 
4
4
  class ExpectationBuilderTest < Test::Unit::TestCase
5
+ include Hardmock
5
6
 
6
7
  def test_build_expectation
7
8
  builder = ExpectationBuilder.new
8
9
 
9
10
  ex = builder.build_expectation( :stuff => 'inside' )
10
11
  assert_not_nil ex, "Didn't build an expectation"
11
- assert_kind_of SimpleExpectation, ex, "Wrong type!"
12
+ assert_kind_of Expectation, ex, "Wrong type!"
12
13
 
13
14
  # Shhhh... fragile, yes, whatever. The functional tests do the
14
15
  # real testing of this anyway
@@ -1,7 +1,9 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
- require 'hardmock'
2
+ require 'hardmock/expectation'
3
+ require 'hardmock/errors'
3
4
 
4
- class SimpleExpectationTest < Test::Unit::TestCase
5
+ class ExpectationTest < Test::Unit::TestCase
6
+ include Hardmock
5
7
 
6
8
  def setup
7
9
  @mock = TheMock.new
@@ -22,12 +24,12 @@ class SimpleExpectationTest < Test::Unit::TestCase
22
24
  #
23
25
 
24
26
  def test_to_s
25
- ex = SimpleExpectation.new( :mock => @mock, :method => 'a_func', :arguments => [1, "two", :three, { :four => 4 }] )
27
+ ex = Expectation.new( :mock => @mock, :method => 'a_func', :arguments => [1, "two", :three, { :four => 4 }] )
26
28
  assert_equal %|the_mock.a_func(1, "two", :three, {:four=>4})|, ex.to_s
27
29
  end
28
30
 
29
31
  def test_apply_method_call
30
- se = SimpleExpectation.new(:mock => @mock, :method => 'some_func',
32
+ se = Expectation.new(:mock => @mock, :method => 'some_func',
31
33
  :arguments => [1,'two',:three] )
32
34
 
33
35
  # Try it good:
@@ -68,7 +70,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
68
70
  # now with a proc
69
71
  thinger = nil
70
72
  the_proc = Proc.new { thinger = :shaq }
71
- se = SimpleExpectation.new(:mock => @mock, :method => 'some_func',
73
+ se = Expectation.new(:mock => @mock, :method => 'some_func',
72
74
  :block => the_proc)
73
75
 
74
76
  # Try it good:
@@ -88,7 +90,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
88
90
  passed_block = blk
89
91
  }
90
92
 
91
- se = SimpleExpectation.new(:mock => @mock, :method => 'some_func', :block => exp_block,
93
+ se = Expectation.new(:mock => @mock, :method => 'some_func', :block => exp_block,
92
94
  :arguments => [])
93
95
 
94
96
  set_flag = false
@@ -109,7 +111,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
109
111
  end
110
112
 
111
113
  def test_apply_method_call_fails_when_theres_no_expectation_block_to_handle_the_runtime_block
112
- se = SimpleExpectation.new(:mock => @mock, :method => 'some_func', :arguments => [])
114
+ se = Expectation.new(:mock => @mock, :method => 'some_func', :arguments => [])
113
115
  runtime_block = Proc.new { set_flag = true }
114
116
  err = assert_raise ExpectationError do
115
117
  se.apply_method_call( @mock, 'some_func', [], runtime_block)
@@ -119,7 +121,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
119
121
  end
120
122
 
121
123
  def test_returns
122
- se = SimpleExpectation.new(:mock => @mock, :method => 'some_func',
124
+ se = Expectation.new(:mock => @mock, :method => 'some_func',
123
125
  :arguments => [1,'two',:three])
124
126
 
125
127
  se.returns "A value"
@@ -129,7 +131,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
129
131
 
130
132
  def test_apply_method_call_captures_block_value
131
133
  the_proc = lambda { "in the block" }
132
- se = SimpleExpectation.new(:mock => @mock, :method => 'do_it', :arguments => [], :block => the_proc)
134
+ se = Expectation.new(:mock => @mock, :method => 'do_it', :arguments => [], :block => the_proc)
133
135
 
134
136
  assert_nil se.block_value, "Block value starts out nil"
135
137
 
@@ -143,7 +145,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
143
145
  target = false
144
146
  inner_proc = lambda { target = true }
145
147
  the_proc = lambda { inner_proc }
146
- se = SimpleExpectation.new(:mock => @mock, :method => 'do_it', :arguments => [], :block => the_proc)
148
+ se = Expectation.new(:mock => @mock, :method => 'do_it', :arguments => [], :block => the_proc)
147
149
 
148
150
  assert_nil se.block_value, "Block value starts out nil"
149
151
  se.apply_method_call(@mock, 'do_it', [], nil)
@@ -159,7 +161,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
159
161
  target = nil
160
162
  inner_proc = lambda { |one,two| target = [one,two] }
161
163
  the_proc = lambda { inner_proc }
162
- se = SimpleExpectation.new(:mock => @mock, :method => 'do_it', :arguments => [], :block => the_proc)
164
+ se = Expectation.new(:mock => @mock, :method => 'do_it', :arguments => [], :block => the_proc)
163
165
 
164
166
  assert_nil se.block_value, "Block value starts out nil"
165
167
  se.apply_method_call(@mock, 'do_it', [], nil)
@@ -171,7 +173,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
171
173
  end
172
174
 
173
175
  def test_trigger_nil_block_value
174
- se = SimpleExpectation.new(:mock => @mock, :method => 'do_it', :arguments => [])
176
+ se = Expectation.new(:mock => @mock, :method => 'do_it', :arguments => [])
175
177
 
176
178
  assert_nil se.block_value, "Block value starts out nil"
177
179
  se.apply_method_call(@mock, 'do_it', [], nil)
@@ -186,7 +188,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
186
188
 
187
189
  def test_trigger_non_proc_block_value
188
190
  the_block = lambda { "woops" }
189
- se = SimpleExpectation.new(:mock => @mock, :method => 'do_it', :arguments => [], :block => the_block)
191
+ se = Expectation.new(:mock => @mock, :method => 'do_it', :arguments => [], :block => the_block)
190
192
 
191
193
  se.apply_method_call(@mock, 'do_it', [], nil)
192
194
  assert_equal "woops", se.block_value
@@ -203,7 +205,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
203
205
 
204
206
  def test_proc_used_for_return
205
207
  the_proc = lambda { "in the block" }
206
- se = SimpleExpectation.new(:mock => @mock, :method => 'do_it', :arguments => [], :block => the_proc)
208
+ se = Expectation.new(:mock => @mock, :method => 'do_it', :arguments => [], :block => the_proc)
207
209
 
208
210
  assert_equal "in the block", se.apply_method_call(@mock, 'do_it', [], nil)
209
211
  assert_equal "in the block", se.block_value, "Captured block value affected wrongly"
@@ -211,14 +213,14 @@ class SimpleExpectationTest < Test::Unit::TestCase
211
213
 
212
214
  def test_explicit_return_overrides_proc_return
213
215
  the_proc = lambda { "in the block" }
214
- se = SimpleExpectation.new(:mock => @mock, :method => 'do_it', :arguments => [], :block => the_proc)
216
+ se = Expectation.new(:mock => @mock, :method => 'do_it', :arguments => [], :block => the_proc)
215
217
  se.returns "the override"
216
218
  assert_equal "the override", se.apply_method_call(@mock, 'do_it', [], nil)
217
219
  assert_equal "in the block", se.block_value, "Captured block value affected wrongly"
218
220
  end
219
221
 
220
222
  def test_yields
221
- se = SimpleExpectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot] )
223
+ se = Expectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot] )
222
224
  se.yields :bean1, :bean2
223
225
 
224
226
  things = []
@@ -229,7 +231,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
229
231
  end
230
232
 
231
233
  def test_yields_block_takes_no_arguments
232
- se = SimpleExpectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot] )
234
+ se = Expectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot] )
233
235
  se.yields
234
236
 
235
237
  things = []
@@ -239,7 +241,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
239
241
  end
240
242
 
241
243
  def test_yields_params_to_block_takes_no_arguments
242
- se = SimpleExpectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot] )
244
+ se = Expectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot] )
243
245
  se.yields :wont_fit
244
246
 
245
247
  things = []
@@ -254,7 +256,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
254
256
  end
255
257
 
256
258
  def test_yields_with_returns
257
- se = SimpleExpectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot] ,
259
+ se = Expectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot] ,
258
260
  :returns => 'the results')
259
261
 
260
262
  exp = se.yields :bean1, :bean2
@@ -267,7 +269,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
267
269
  end
268
270
 
269
271
  def test_yields_with_raises
270
- se = SimpleExpectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot],
272
+ se = Expectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot],
271
273
  :raises => RuntimeError.new("kerboom"))
272
274
 
273
275
  exp = se.yields :bean1, :bean2
@@ -282,7 +284,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
282
284
  end
283
285
 
284
286
  def test_yields_and_inner_block_explodes
285
- se = SimpleExpectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot])
287
+ se = Expectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot])
286
288
 
287
289
  exp = se.yields :bean1, :bean2
288
290
  assert_same se, exp, "'yields' needs to return a reference to the expectation"
@@ -299,7 +301,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
299
301
  end
300
302
 
301
303
  def test_yields_with_several_arrays
302
- se = SimpleExpectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot] )
304
+ se = Expectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot] )
303
305
  se.yields ['a','b'], ['c','d']
304
306
 
305
307
  things = []
@@ -310,7 +312,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
310
312
  end
311
313
 
312
314
  def test_yields_tuples
313
- se = SimpleExpectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot] )
315
+ se = Expectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot] )
314
316
  se.yields ['a','b','c'], ['d','e','f']
315
317
 
316
318
  things = []
@@ -326,7 +328,7 @@ class SimpleExpectationTest < Test::Unit::TestCase
326
328
  end
327
329
 
328
330
  def test_yields_tuples_size_mismatch
329
- se = SimpleExpectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot] )
331
+ se = Expectation.new(:mock => @mock, :method => 'each_bean', :arguments => [:side_slot] )
330
332
  se.yields ['a','b','c'], ['d','e','f']
331
333
 
332
334
  things = []
@@ -1,7 +1,8 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
- require 'hardmock'
2
+ require 'hardmock/expector'
3
3
 
4
4
  class ExpectorTest < Test::Unit::TestCase
5
+ include Hardmock
5
6
 
6
7
  class MyControl
7
8
  attr_reader :added
@@ -19,19 +20,6 @@ class ExpectorTest < Test::Unit::TestCase
19
20
  end
20
21
  end
21
22
 
22
- #
23
- # TESTS
24
- #
25
-
26
- def test_method_missing
27
- try_it_with 'wonder_bread'
28
- try_it_with 'whatever'
29
- end
30
-
31
- def test_methods_that_wont_trigger_method_missing
32
- try_it_with 'instance_eval'
33
- end
34
-
35
23
  def try_it_with(method_name)
36
24
  mock = Object.new
37
25
  mock_control = MyControl.new
@@ -50,5 +38,20 @@ class ExpectorTest < Test::Unit::TestCase
50
38
  assert_equal "dummy expectation", output, "Expectation should have been returned"
51
39
  end
52
40
 
41
+ #
42
+ # TESTS
43
+ #
44
+ def test_method_missing
45
+ try_it_with 'wonder_bread'
46
+ try_it_with 'whatever'
47
+ end
48
+
49
+ def test_methods_that_wont_trigger_method_missing
50
+ mock = Object.new
51
+ mock_control = MyControl.new
52
+ builder = ExpBuilder.new
53
53
 
54
+ exp = Expector.new(mock, mock_control, builder)
55
+ assert_equal mock, exp.instance_eval("@mock")
56
+ end
54
57
  end
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
- require 'method_cleanout'
2
+ require 'hardmock/method_cleanout'
3
3
 
4
4
  class MethodCleanoutTest < Test::Unit::TestCase
5
5
  class Victim
@@ -27,7 +27,7 @@ class MethodCleanoutTest < Test::Unit::TestCase
27
27
  end
28
28
 
29
29
  def test_should_include_certain_important_methods_in_the_sacred_methods_list
30
- %w|__id__ __send__ send equal? respond_to? nil?|.each do |m|
30
+ %w|__id__ __send__ equal? object_id send nil? class kind_of? respond_to? inspect method to_s instance_variables instance_eval|.each do |m|
31
31
  assert Hardmock::MethodCleanout::SACRED_METHODS.include?(m), "important method #{m} is not included in SACRED_METHODS"
32
32
  end
33
33
  end
@@ -1,7 +1,10 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
- require 'hardmock'
2
+ require 'hardmock/utils'
3
+ require 'hardmock/errors'
4
+ require 'hardmock/mock_control'
3
5
 
4
6
  class MockControlTest < Test::Unit::TestCase
7
+ include Hardmock
5
8
 
6
9
  def setup
7
10
  @unmock = OpenStruct.new( :_name => 'fakemock' )
@@ -1,7 +1,13 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
- require 'hardmock'
2
+ require 'hardmock/method_cleanout'
3
+ require 'hardmock/mock'
4
+ require 'hardmock/mock_control'
5
+ require 'hardmock/expectation_builder'
6
+ require 'hardmock/expector'
7
+ require 'hardmock/trapper'
3
8
 
4
9
  class MockTest < Test::Unit::TestCase
10
+ include Hardmock
5
11
 
6
12
  def test_build_with_control
7
13
  mc1 = MockControl.new
@@ -270,6 +276,4 @@ class MockTest < Test::Unit::TestCase
270
276
  mock._verify
271
277
  end
272
278
 
273
-
274
-
275
279
  end
@@ -1,7 +1,9 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
- require 'hardmock'
2
+ require 'hardmock/method_cleanout'
3
+ require 'hardmock/trapper'
3
4
 
4
5
  class TrapperTest < Test::Unit::TestCase
6
+ include Hardmock
5
7
 
6
8
  def setup
7
9
  @mock = Object.new
@@ -1,7 +1,13 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
- require 'hardmock'
2
+ require 'hardmock/method_cleanout'
3
+ require 'hardmock/mock_control'
4
+ require 'hardmock/errors'
5
+ require 'hardmock/expectation_builder'
6
+ require 'hardmock/expectation'
7
+ require 'hardmock/mock'
3
8
 
4
9
  class VerifyErrorTest < Test::Unit::TestCase
10
+ include Hardmock
5
11
 
6
12
  #
7
13
  # TESTS
@@ -10,8 +16,8 @@ class VerifyErrorTest < Test::Unit::TestCase
10
16
  def test_formatted_list_of_unmet_expectations
11
17
  mock1 = Mock.new('mock1')
12
18
  mock2 = Mock.new('mock2')
13
- exp1 = SimpleExpectation.new( :mock => mock1, :method => 'send_parts', :arguments => [1,2,:a] )
14
- exp2 = SimpleExpectation.new( :mock => mock2, :method => 'grind_it', :arguments => [] )
19
+ exp1 = Expectation.new( :mock => mock1, :method => 'send_parts', :arguments => [1,2,:a] )
20
+ exp2 = Expectation.new( :mock => mock2, :method => 'grind_it', :arguments => [] )
15
21
 
16
22
  exp_list = [ exp1, exp2 ]
17
23
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: hardmock
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.0
7
- date: 2006-12-19 00:00:00 -05:00
6
+ version: 1.2.3
7
+ date: 2007-04-28 00:00:00 -04:00
8
8
  summary: A strict, ordered, expectation-oriented mock object library.
9
9
  require_paths:
10
10
  - lib
@@ -29,36 +29,49 @@ post_install_message:
29
29
  authors:
30
30
  - David Crosby
31
31
  files:
32
+ - lib/assert_error.rb
32
33
  - lib/hardmock.rb
33
- - lib/method_cleanout.rb
34
+ - lib/hardmock/errors.rb
35
+ - lib/hardmock/expectation.rb
36
+ - lib/hardmock/expectation_builder.rb
37
+ - lib/hardmock/expector.rb
38
+ - lib/hardmock/method_cleanout.rb
39
+ - lib/hardmock/mock.rb
40
+ - lib/hardmock/mock_control.rb
41
+ - lib/hardmock/trapper.rb
42
+ - lib/hardmock/utils.rb
43
+ - lib/tasks/rdoc_options.rb
34
44
  - test/test_helper.rb
35
45
  - test/functional/assert_error_test.rb
36
46
  - test/functional/auto_verify_test.rb
37
47
  - test/functional/direct_mock_usage_test.rb
38
48
  - test/functional/hardmock_test.rb
39
49
  - test/unit/expectation_builder_test.rb
50
+ - test/unit/expectation_test.rb
40
51
  - test/unit/expector_test.rb
41
52
  - test/unit/method_cleanout_test.rb
42
53
  - test/unit/mock_control_test.rb
43
54
  - test/unit/mock_test.rb
44
- - test/unit/simple_expectation_test.rb
45
55
  - test/unit/trapper_test.rb
46
56
  - test/unit/verify_error_test.rb
47
- - CHANGES
48
- - LICENSE
49
57
  - Rakefile
58
+ - config/environment.rb
59
+ - lib/tasks/rdoc.rake
60
+ - lib/tasks/test.rake
50
61
  - README
62
+ - CHANGES
63
+ - LICENSE
51
64
  test_files:
52
65
  - test/functional/assert_error_test.rb
53
66
  - test/functional/auto_verify_test.rb
54
67
  - test/functional/direct_mock_usage_test.rb
55
68
  - test/functional/hardmock_test.rb
56
69
  - test/unit/expectation_builder_test.rb
70
+ - test/unit/expectation_test.rb
57
71
  - test/unit/expector_test.rb
58
72
  - test/unit/method_cleanout_test.rb
59
73
  - test/unit/mock_control_test.rb
60
74
  - test/unit/mock_test.rb
61
- - test/unit/simple_expectation_test.rb
62
75
  - test/unit/trapper_test.rb
63
76
  - test/unit/verify_error_test.rb
64
77
  rdoc_options: