flexmock 0.8.11 → 0.9.0
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 +2 -2
- data/Rakefile +23 -65
- data/TAGS +689 -691
- data/doc/releases/flexmock-0.9.0.rdoc +89 -0
- data/lib/flexmock.rb +1 -1
- data/lib/flexmock/argument_matchers.rb +5 -5
- data/lib/flexmock/argument_types.rb +1 -1
- data/lib/flexmock/base.rb +1 -1
- data/lib/flexmock/core.rb +5 -5
- data/lib/flexmock/core_class_methods.rb +6 -6
- data/lib/flexmock/default_framework_adapter.rb +2 -2
- data/lib/flexmock/deprecated_methods.rb +1 -1
- data/lib/flexmock/errors.rb +1 -1
- data/lib/flexmock/expectation.rb +12 -12
- data/lib/flexmock/expectation_director.rb +1 -1
- data/lib/flexmock/mock_container.rb +12 -2
- data/lib/flexmock/noop.rb +2 -2
- data/lib/flexmock/ordering.rb +1 -1
- data/lib/flexmock/partial_mock.rb +10 -3
- data/lib/flexmock/rails.rb +1 -1
- data/lib/flexmock/recorder.rb +1 -1
- data/lib/flexmock/rspec.rb +1 -1
- data/lib/flexmock/test_unit.rb +2 -2
- data/lib/flexmock/test_unit_integration.rb +5 -5
- data/lib/flexmock/undefined.rb +8 -4
- data/lib/flexmock/validators.rb +2 -2
- data/lib/flexmock/version.rb +11 -0
- data/test/{test_aliasing.rb → aliasing_test.rb} +7 -8
- data/test/{test_container_methods.rb → container_methods_test.rb} +21 -22
- data/test/{test_default_framework_adapter.rb → default_framework_adapter_test.rb} +8 -9
- data/test/{test_demeter_mocking.rb → demeter_mocking_test.rb} +1 -4
- data/test/{test_deprecated_methods.rb → deprecated_methods_test.rb} +11 -13
- data/test/{test_examples_from_readme.rb → examples_from_readme_test.rb} +5 -6
- data/test/{test_extended_should_receive.rb → extended_should_receive_test.rb} +11 -12
- data/test/{test_flexmodel.rb → flexmodel_test.rb} +1 -2
- data/test/{test_naming.rb → naming_test.rb} +5 -6
- data/test/{test_new_instances.rb → new_instances_test.rb} +36 -28
- data/test/{test_partial_mock.rb → partial_mock_test.rb} +20 -18
- data/test/{test_rails_view_stub.rb → rails_view_stub_test.rb} +3 -3
- data/test/{test_record_mode.rb → record_mode_test.rb} +2 -5
- data/test/rspec_integration/integration_spec.rb +14 -8
- data/test/{test_samples.rb → samples_test.rb} +13 -14
- data/test/{test_should_ignore_missing.rb → should_ignore_missing_test.rb} +4 -6
- data/test/{test_should_receive.rb → should_receive_test.rb} +39 -42
- data/test/test_setup.rb +30 -0
- data/test/test_unit_integration/{test_auto_test_unit.rb → auto_test_unit_test.rb} +4 -4
- data/test/tu_integration_test.rb +99 -0
- data/test/{test_undefined.rb → undefined_test.rb} +2 -3
- metadata +31 -39
- data/test/asserts.rb +0 -34
- data/test/test_tu_integration.rb +0 -94
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'test/
|
3
|
+
require 'test/test_setup'
|
4
4
|
require 'flexmock/rails/view_mocking'
|
5
5
|
|
6
6
|
module ViewTests
|
@@ -11,7 +11,7 @@ module ViewTests
|
|
11
11
|
|
12
12
|
def test_fails_if_no_render
|
13
13
|
should_render_view
|
14
|
-
assert_raise(
|
14
|
+
assert_raise(assertion_failed_error) do
|
15
15
|
flexmock_verify
|
16
16
|
end
|
17
17
|
end
|
@@ -24,7 +24,7 @@ module ViewTests
|
|
24
24
|
def test_view_mocks_with_expectation_fails_with_different_template
|
25
25
|
should_render_view("new")
|
26
26
|
render "controller/edit"
|
27
|
-
assert_raise(
|
27
|
+
assert_raise(assertion_failed_error) do
|
28
28
|
flexmock_verify
|
29
29
|
end
|
30
30
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
#---
|
4
|
-
# Copyright 2003
|
4
|
+
# Copyright 2003-2011 by Jim Weirich (jim@weirichhouse.org).
|
5
5
|
# All rights reserved.
|
6
6
|
|
7
7
|
# Permission is granted for use, copying, modification, distribution,
|
@@ -9,13 +9,10 @@
|
|
9
9
|
# above copyright notice is included.
|
10
10
|
#+++
|
11
11
|
|
12
|
-
require 'test/
|
13
|
-
require 'flexmock'
|
14
|
-
require 'test/asserts'
|
12
|
+
require 'test/test_setup'
|
15
13
|
|
16
14
|
class TestRecordMode < Test::Unit::TestCase
|
17
15
|
include FlexMock::TestCase
|
18
|
-
include FlexMock::FailureAssertion
|
19
16
|
|
20
17
|
def test_recording_mode_works
|
21
18
|
mock = flexmock("mock")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
#---
|
4
|
-
# Copyright 2003
|
4
|
+
# Copyright 2003-2011 by Jim Weirich (jim@weirichhouse.org).
|
5
5
|
# All rights reserved.
|
6
6
|
|
7
7
|
# Permission is granted for use, copying, modification, distribution,
|
@@ -9,27 +9,33 @@
|
|
9
9
|
# above copyright notice is included.
|
10
10
|
#+++
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
if defined?(RSpec)
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.mock_with :flexmock
|
15
|
+
end
|
16
|
+
else
|
17
|
+
Spec::Runner.configure do |config|
|
18
|
+
config.mock_with :flexmock
|
19
|
+
end
|
14
20
|
end
|
15
21
|
|
16
|
-
|
22
|
+
describe "FlexMock in a RSpec example" do
|
17
23
|
specify "should be able to create a mock" do
|
18
24
|
m = flexmock()
|
19
25
|
end
|
20
|
-
|
26
|
+
|
21
27
|
specify "should have an error when a mock is not called" do
|
22
28
|
m = flexmock("Expectation Failured")
|
23
29
|
m.should_receive(:hi).with().once
|
24
30
|
end
|
25
|
-
|
31
|
+
|
26
32
|
specify "should be able to create a stub" do
|
27
33
|
s = "Hello World"
|
28
34
|
flexmock(:base, s).should_receive(:downcase).with().once.and_return("hello WORLD")
|
29
|
-
|
35
|
+
|
30
36
|
s.downcase.should == "hello WORLD"
|
31
37
|
end
|
32
|
-
|
38
|
+
|
33
39
|
specify "Should show an example failure" do
|
34
40
|
1.should == 2
|
35
41
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
#---
|
4
|
-
# Copyright 2003
|
4
|
+
# Copyright 2003-2011 by Jim Weirich (jim@weirichhouse.org).
|
5
5
|
# All rights reserved.
|
6
6
|
|
7
7
|
# Permission is granted for use, copying, modification, distribution,
|
@@ -9,8 +9,7 @@
|
|
9
9
|
# above copyright notice is included.
|
10
10
|
#+++
|
11
11
|
|
12
|
-
require 'test/
|
13
|
-
require 'flexmock'
|
12
|
+
require 'test/test_setup'
|
14
13
|
|
15
14
|
# Sample FlexMock Usage.
|
16
15
|
|
@@ -64,7 +63,7 @@ end
|
|
64
63
|
|
65
64
|
class TestDog < Test::Unit::TestCase
|
66
65
|
include FlexMock::TestCase
|
67
|
-
|
66
|
+
|
68
67
|
def test_dog_wags
|
69
68
|
tail_mock = flexmock(:wag => :happy)
|
70
69
|
assert_equal :happy, tail_mock.wag
|
@@ -88,14 +87,14 @@ end
|
|
88
87
|
|
89
88
|
class TestDogBarking < Test::Unit::TestCase
|
90
89
|
include FlexMock::TestCase
|
91
|
-
|
92
|
-
# Setup the tests by mocking the +new+ method of
|
90
|
+
|
91
|
+
# Setup the tests by mocking the +new+ method of
|
93
92
|
# Woofer and return a mock woofer.
|
94
93
|
def setup
|
95
94
|
@dog = Dog.new
|
96
95
|
flexmock(@dog, :bark => :grrr)
|
97
96
|
end
|
98
|
-
|
97
|
+
|
99
98
|
def test_dog
|
100
99
|
assert_equal :grrr, @dog.bark # Mocked Method
|
101
100
|
assert_equal :happy, @dog.wag # Normal Method
|
@@ -104,13 +103,13 @@ end
|
|
104
103
|
|
105
104
|
class TestDogBarkingWithNewInstances < Test::Unit::TestCase
|
106
105
|
include FlexMock::TestCase
|
107
|
-
|
106
|
+
|
108
107
|
# Setup the tests by mocking Woofer to always
|
109
108
|
# return partial mocks.
|
110
109
|
def setup
|
111
110
|
flexmock(Woofer).new_instances.should_receive(:woof => :grrr)
|
112
111
|
end
|
113
|
-
|
112
|
+
|
114
113
|
def test_dog
|
115
114
|
assert_equal :grrr, Dog.new.bark # All dog objects
|
116
115
|
assert_equal :grrr, Dog.new.bark # are mocked.
|
@@ -124,13 +123,13 @@ class TestDefaults < Test::Unit::TestCase
|
|
124
123
|
@mock_dog = flexmock("Fido")
|
125
124
|
@mock_dog.should_receive(:tail => :a_tail, :bark => "woof").by_default
|
126
125
|
end
|
127
|
-
|
126
|
+
|
128
127
|
def test_something_where_bark_must_be_called_once
|
129
128
|
@mock_dog.should_receive(:bark => "bow wow").once
|
130
129
|
|
131
130
|
assert_equal "bow wow", @mock_dog.bark
|
132
131
|
assert_equal :a_tail, @mock_dog.tail
|
133
|
-
end
|
132
|
+
end
|
134
133
|
end
|
135
134
|
|
136
135
|
class TestDemeter < Test::Unit::TestCase
|
@@ -180,7 +179,7 @@ class TestDb < Test::Unit::TestCase
|
|
180
179
|
db.should_receive(:query).and_return([1,2,3]).ordered
|
181
180
|
db.should_receive(:update).and_return(nil).ordered
|
182
181
|
# test code here
|
183
|
-
assert_raises(
|
182
|
+
assert_raises(assertion_failed_error) do
|
184
183
|
db.update
|
185
184
|
db.query
|
186
185
|
end
|
@@ -220,7 +219,7 @@ class TestDb < Test::Unit::TestCase
|
|
220
219
|
db.query("asdf")
|
221
220
|
db.finish
|
222
221
|
end
|
223
|
-
|
222
|
+
|
224
223
|
def known_good_way_to_build_xml(builder)
|
225
224
|
builder.html
|
226
225
|
end
|
@@ -237,7 +236,7 @@ class TestDb < Test::Unit::TestCase
|
|
237
236
|
end
|
238
237
|
new_way_to_build_xml(builder) # compare to new way
|
239
238
|
end
|
240
|
-
|
239
|
+
|
241
240
|
end
|
242
241
|
|
243
242
|
class TestMoreSamples < Test::Unit::TestCase
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
#---
|
4
|
-
# Copyright 2003
|
4
|
+
# Copyright 2003-2011 by Jim Weirich (jim@weirichhouse.org).
|
5
5
|
# All rights reserved.
|
6
6
|
|
7
7
|
# Permission is granted for use, copying, modification, distribution,
|
@@ -9,9 +9,7 @@
|
|
9
9
|
# above copyright notice is included.
|
10
10
|
#+++
|
11
11
|
|
12
|
-
require 'test/
|
13
|
-
require 'flexmock'
|
14
|
-
require 'test/asserts'
|
12
|
+
require 'test/test_setup'
|
15
13
|
|
16
14
|
class TestShouldIgnoreMissing < Test::Unit::TestCase
|
17
15
|
include FlexMock::TestCase
|
@@ -19,7 +17,7 @@ class TestShouldIgnoreMissing < Test::Unit::TestCase
|
|
19
17
|
def setup
|
20
18
|
@mock = flexmock("mock")
|
21
19
|
end
|
22
|
-
|
20
|
+
|
23
21
|
def test_mocks_do_not_respond_to_undefined_methods
|
24
22
|
assert !@mock.respond_to?(:unknown_foo)
|
25
23
|
end
|
@@ -67,7 +65,7 @@ class TestShouldIgnoreMissing < Test::Unit::TestCase
|
|
67
65
|
@mock.should_receive(:known_foo).once
|
68
66
|
method_proc = @mock.method(:known_foo)
|
69
67
|
assert_not_nil method_proc
|
70
|
-
assert_raises
|
68
|
+
assert_raises assertion_failed_error do
|
71
69
|
flexmock_teardown
|
72
70
|
end
|
73
71
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
#---
|
4
|
-
# Copyright 2003
|
4
|
+
# Copyright 2003-2011 by Jim Weirich (jim@weirichhouse.org).
|
5
5
|
# All rights reserved.
|
6
6
|
|
7
7
|
# Permission is granted for use, copying, modification, distribution,
|
@@ -9,9 +9,7 @@
|
|
9
9
|
# above copyright notice is included.
|
10
10
|
#+++
|
11
11
|
|
12
|
-
require 'test/
|
13
|
-
require 'flexmock'
|
14
|
-
require 'test/asserts'
|
12
|
+
require 'test/test_setup'
|
15
13
|
|
16
14
|
def mock_top_level_function
|
17
15
|
:mtlf
|
@@ -33,7 +31,6 @@ end
|
|
33
31
|
|
34
32
|
class TestFlexMockShoulds < Test::Unit::TestCase
|
35
33
|
include FlexMock::TestCase
|
36
|
-
include FlexMock::FailureAssertion
|
37
34
|
|
38
35
|
# Expected error messages on failures
|
39
36
|
COUNT_ERROR_MESSAGE = /\bcalled\s+incorrect\s+number\s+of\s+times\b/
|
@@ -42,7 +39,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
42
39
|
AT_MOST_ERROR_MESSAGE = /\bshould\s+be\s+called\s+at\s+most\b/
|
43
40
|
OUT_OF_ORDER_ERROR_MESSAGE = /\bcalled\s+out\s+of\s+order\b/
|
44
41
|
NON_CONTAINER_MESSAGE = /\bis\s+not\s+in\s+a\s+container\b/
|
45
|
-
|
42
|
+
|
46
43
|
def test_defaults
|
47
44
|
FlexMock.use do |m|
|
48
45
|
m.should_receive(:hi)
|
@@ -59,7 +56,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
59
56
|
assert_equal 1, m.hi(123)
|
60
57
|
end
|
61
58
|
end
|
62
|
-
|
59
|
+
|
63
60
|
def test_returns_with_multiple_values
|
64
61
|
FlexMock.use do |m|
|
65
62
|
m.should_receive(:hi).and_return(1,2,3)
|
@@ -241,7 +238,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
241
238
|
def test_raises_is_an_alias_for_and_raise
|
242
239
|
FlexMock.use do |m|
|
243
240
|
m.should_receive(:failure).raises(RuntimeError)
|
244
|
-
|
241
|
+
assert_raise RuntimeError do
|
245
242
|
m.failure
|
246
243
|
end
|
247
244
|
end
|
@@ -308,7 +305,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
308
305
|
FlexMock.use do |m|
|
309
306
|
m.should_receive(:hi).with(1).returns(10)
|
310
307
|
m.should_receive(:hi).with(2).returns(20)
|
311
|
-
|
308
|
+
|
312
309
|
assert_equal 10, m.hi(1)
|
313
310
|
assert_equal 20, m.hi(2)
|
314
311
|
end
|
@@ -322,7 +319,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
322
319
|
end
|
323
320
|
|
324
321
|
def test_with_no_args_but_with_args
|
325
|
-
|
322
|
+
assert_failure(NO_MATCH_ERROR_MESSAGE) do
|
326
323
|
FlexMock.use do |m|
|
327
324
|
m.should_receive(:hi).with_no_args
|
328
325
|
m.hi(1)
|
@@ -425,7 +422,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
425
422
|
FlexMock.use do |m|
|
426
423
|
m.should_receive(:hi).with(/one/).returns(10)
|
427
424
|
m.should_receive(:hi).with(/t/).returns(20)
|
428
|
-
|
425
|
+
|
429
426
|
assert_equal 10, m.hi("one")
|
430
427
|
assert_equal 10, m.hi("done")
|
431
428
|
assert_equal 20, m.hi("two")
|
@@ -444,7 +441,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
444
441
|
FlexMock.use do |m|
|
445
442
|
m.should_receive(:hi).with(Fixnum).returns(10)
|
446
443
|
m.should_receive(:hi).with(Object).returns(20)
|
447
|
-
|
444
|
+
|
448
445
|
assert_equal 10, m.hi(319)
|
449
446
|
assert_equal 10, m.hi(Fixnum)
|
450
447
|
assert_equal 20, m.hi("hi")
|
@@ -512,7 +509,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
512
509
|
end
|
513
510
|
|
514
511
|
def test_never_and_called_once
|
515
|
-
|
512
|
+
assert_failure(COUNT_ERROR_MESSAGE) do
|
516
513
|
FlexMock.use do |m|
|
517
514
|
m.should_receive(:hi).with(1).never
|
518
515
|
m.hi(1)
|
@@ -528,7 +525,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
528
525
|
end
|
529
526
|
|
530
527
|
def test_once_but_never_called
|
531
|
-
|
528
|
+
assert_failure(COUNT_ERROR_MESSAGE) do
|
532
529
|
FlexMock.use do |m|
|
533
530
|
m.should_receive(:hi).with(1).returns(10).once
|
534
531
|
end
|
@@ -536,7 +533,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
536
533
|
end
|
537
534
|
|
538
535
|
def test_once_but_called_twice
|
539
|
-
|
536
|
+
assert_failure(COUNT_ERROR_MESSAGE) do
|
540
537
|
FlexMock.use do |m|
|
541
538
|
m.should_receive(:hi).with(1).returns(10).once
|
542
539
|
m.hi(1)
|
@@ -588,7 +585,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
588
585
|
end
|
589
586
|
|
590
587
|
def test_at_least_but_never_called
|
591
|
-
|
588
|
+
assert_failure(AT_LEAST_ERROR_MESSAGE) do
|
592
589
|
FlexMock.use do |m|
|
593
590
|
m.should_receive(:hi).with(1).returns(10).at_least.once
|
594
591
|
end
|
@@ -604,7 +601,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
604
601
|
end
|
605
602
|
|
606
603
|
def test_at_least_and_exact
|
607
|
-
|
604
|
+
assert_failure(COUNT_ERROR_MESSAGE) do
|
608
605
|
FlexMock.use do |m|
|
609
606
|
m.should_receive(:hi).with(1).returns(10).at_least.once.once
|
610
607
|
m.hi(1)
|
@@ -627,7 +624,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
627
624
|
end
|
628
625
|
|
629
626
|
def test_at_most_called_twice
|
630
|
-
|
627
|
+
assert_failure(AT_MOST_ERROR_MESSAGE) do
|
631
628
|
FlexMock.use do |m|
|
632
629
|
m.should_receive(:hi).with(1).returns(10).at_most.once
|
633
630
|
m.hi(1)
|
@@ -637,7 +634,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
637
634
|
end
|
638
635
|
|
639
636
|
def test_at_most_and_at_least_called_never
|
640
|
-
|
637
|
+
assert_failure(AT_LEAST_ERROR_MESSAGE) do
|
641
638
|
FlexMock.use do |m|
|
642
639
|
m.should_receive(:hi).with(1).returns(10).at_least.once.at_most.twice
|
643
640
|
end
|
@@ -660,7 +657,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
660
657
|
end
|
661
658
|
|
662
659
|
def test_at_most_and_at_least_called_three_times
|
663
|
-
|
660
|
+
assert_failure(AT_MOST_ERROR_MESSAGE) do
|
664
661
|
FlexMock.use do |m|
|
665
662
|
m.should_receive(:hi).with(1).returns(10).at_least.once.at_most.twice
|
666
663
|
m.hi(1)
|
@@ -709,7 +706,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
709
706
|
end
|
710
707
|
|
711
708
|
def test_ordered_calls_out_of_order_will_fail
|
712
|
-
|
709
|
+
assert_failure(OUT_OF_ORDER_ERROR_MESSAGE) do
|
713
710
|
FlexMock.use 'm' do |m|
|
714
711
|
m.should_receive(:hi).ordered
|
715
712
|
m.should_receive(:lo).ordered
|
@@ -724,14 +721,14 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
724
721
|
FlexMock.use 'm' do |m|
|
725
722
|
m.should_receive(:hi).with("one").ordered
|
726
723
|
m.should_receive(:hi).with("two").ordered
|
727
|
-
|
724
|
+
|
728
725
|
m.hi("one")
|
729
726
|
m.hi("two")
|
730
727
|
end
|
731
728
|
end
|
732
729
|
|
733
730
|
def test_order_calls_with_different_arg_lists_and_out_of_order_will_fail
|
734
|
-
|
731
|
+
assert_failure(OUT_OF_ORDER_ERROR_MESSAGE) do
|
735
732
|
FlexMock.use 'm' do |m|
|
736
733
|
m.should_receive(:hi).with("one").ordered
|
737
734
|
m.should_receive(:hi).with("two").ordered
|
@@ -747,7 +744,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
747
744
|
m.should_receive(:blah)
|
748
745
|
m.should_receive(:hi).ordered
|
749
746
|
m.should_receive(:lo).ordered
|
750
|
-
|
747
|
+
|
751
748
|
m.blah
|
752
749
|
m.hi
|
753
750
|
m.blah
|
@@ -760,7 +757,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
760
757
|
FlexMock.use 'm' do |m|
|
761
758
|
m.should_receive(:hi).ordered
|
762
759
|
m.should_receive(:lo).ordered
|
763
|
-
|
760
|
+
|
764
761
|
m.hi
|
765
762
|
m.hi
|
766
763
|
m.lo
|
@@ -774,7 +771,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
774
771
|
m.should_receive(:flip).ordered(2)
|
775
772
|
m.should_receive(:flop).ordered(2)
|
776
773
|
m.should_receive(:final).ordered
|
777
|
-
|
774
|
+
|
778
775
|
m.start
|
779
776
|
m.flop
|
780
777
|
m.flip
|
@@ -789,7 +786,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
789
786
|
m.should_receive(:flip).ordered(:flip_flop_group)
|
790
787
|
m.should_receive(:flop).ordered(:flip_flop_group)
|
791
788
|
m.should_receive(:final).ordered
|
792
|
-
|
789
|
+
|
793
790
|
m.start
|
794
791
|
m.flop
|
795
792
|
m.flip
|
@@ -809,7 +806,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
809
806
|
end
|
810
807
|
|
811
808
|
def test_explicit_ordering_with_explicit_misorders
|
812
|
-
|
809
|
+
assert_failure(OUT_OF_ORDER_ERROR_MESSAGE) do
|
813
810
|
FlexMock.use 'm' do |m|
|
814
811
|
m.should_receive(:hi).ordered(:first_group)
|
815
812
|
m.should_receive(:lo).ordered(:second_group)
|
@@ -822,7 +819,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
822
819
|
# assert_match /first_group/, ex.message
|
823
820
|
# assert_match /second_group/, ex.message
|
824
821
|
end
|
825
|
-
|
822
|
+
|
826
823
|
# Test submitted by Mikael Pahmp to correct expectation matching.
|
827
824
|
def test_ordering_with_explicit_no_args_matches_correctly
|
828
825
|
FlexMock.use("m") do |m|
|
@@ -831,11 +828,11 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
831
828
|
m.should_receive(:foo).with_no_args.once.ordered
|
832
829
|
m.foo
|
833
830
|
m.bar
|
834
|
-
m.foo
|
831
|
+
m.foo
|
835
832
|
end
|
836
833
|
end
|
837
834
|
|
838
|
-
# Test submitted by Mikael Pahmp to correct expectation matching.
|
835
|
+
# Test submitted by Mikael Pahmp to correct expectation matching.
|
839
836
|
def test_ordering_with_any_arg_matching_correctly_matches
|
840
837
|
FlexMock.use("m") do |m|
|
841
838
|
m.should_receive(:foo).with_any_args.once.ordered
|
@@ -843,8 +840,8 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
843
840
|
m.should_receive(:foo).with_any_args.once.ordered
|
844
841
|
m.foo
|
845
842
|
m.bar
|
846
|
-
m.foo
|
847
|
-
end
|
843
|
+
m.foo
|
844
|
+
end
|
848
845
|
end
|
849
846
|
|
850
847
|
def test_ordering_between_mocks_is_not_normally_defined
|
@@ -858,13 +855,13 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
858
855
|
end
|
859
856
|
end
|
860
857
|
end
|
861
|
-
|
858
|
+
|
862
859
|
def test_ordering_between_mocks_is_honored_for_global_ordering
|
863
|
-
|
860
|
+
assert_failure(OUT_OF_ORDER_ERROR_MESSAGE) do
|
864
861
|
FlexMock.use("x", "y") do |x, y|
|
865
862
|
x.should_receive(:one).globally.ordered
|
866
863
|
y.should_receive(:two).globally.ordered
|
867
|
-
|
864
|
+
|
868
865
|
y.two
|
869
866
|
x.one
|
870
867
|
end
|
@@ -930,7 +927,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
930
927
|
m.should_receive(:foo).and_return(:bar).by_default
|
931
928
|
assert_equal :bar, m.foo
|
932
929
|
end
|
933
|
-
|
930
|
+
|
934
931
|
def test_default_expectations_are_search_in_the_proper_order
|
935
932
|
m = flexmock("m")
|
936
933
|
m.should_receive(:foo).with(Integer).once.and_return(:first).by_default
|
@@ -938,11 +935,11 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
938
935
|
assert_equal :first, m.foo(1)
|
939
936
|
assert_equal :second, m.foo(1)
|
940
937
|
end
|
941
|
-
|
938
|
+
|
942
939
|
def test_expectations_with_count_constraints_can_by_marked_as_default
|
943
940
|
m = flexmock("m")
|
944
941
|
m.should_receive(:foo).and_return(:bar).once.by_default
|
945
|
-
assert_raise
|
942
|
+
assert_raise assertion_failed_error do
|
946
943
|
flexmock_teardown
|
947
944
|
end
|
948
945
|
end
|
@@ -959,7 +956,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
959
956
|
m = flexmock("m")
|
960
957
|
m.should_receive(:foo).with(1).and_return(:bar).once.by_default
|
961
958
|
m.should_receive(:foo).with(2).and_return(:baz).once
|
962
|
-
assert_raise
|
959
|
+
assert_raise assertion_failed_error do
|
963
960
|
# This expectation should be hidded by the non-result
|
964
961
|
m.foo(1)
|
965
962
|
end
|
@@ -971,7 +968,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
971
968
|
m.should_receive(:foo).ordered.by_default
|
972
969
|
m.should_receive(:bar).ordered.by_default
|
973
970
|
m.bar
|
974
|
-
assert_raise
|
971
|
+
assert_raise assertion_failed_error do m.foo end
|
975
972
|
end
|
976
973
|
|
977
974
|
def test_ordered_default_expectations_can_be_overridden
|
@@ -1066,7 +1063,7 @@ class TestFlexMockShoulds < Test::Unit::TestCase
|
|
1066
1063
|
assert_operator(:=~) { |m| m =~ :x }
|
1067
1064
|
assert_operator(:"`") { |m| m.`("command") } # `
|
1068
1065
|
end
|
1069
|
-
|
1066
|
+
|
1070
1067
|
private
|
1071
1068
|
|
1072
1069
|
def assert_operator(op, &block)
|