caricature 0.7.2 → 0.7.5
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 +97 -97
- data/Rakefile +310 -310
- data/caricature.gemspec +110 -106
- data/lib/caricature.rb +3 -1
- data/lib/caricature/bacon.rb +2 -2
- data/lib/caricature/bacon/integration.rb +75 -55
- data/lib/caricature/clr.rb +4 -3
- data/lib/caricature/clr/aspnet_mvc.rb +3 -3
- data/lib/caricature/clr/descriptor.rb +106 -39
- data/lib/caricature/clr/event_verification.rb +57 -0
- data/lib/caricature/clr/expectation.rb +101 -0
- data/lib/caricature/clr/isolation.rb +49 -13
- data/lib/caricature/clr/isolator.rb +141 -5
- data/lib/caricature/clr/messenger.rb +6 -0
- data/lib/caricature/clr/method_call_recorder.rb +97 -0
- data/lib/caricature/core_ext.rb +11 -0
- data/lib/{core_ext → caricature/core_ext}/array.rb +0 -0
- data/lib/{core_ext → caricature/core_ext}/class.rb +0 -0
- data/lib/{core_ext → caricature/core_ext}/hash.rb +0 -0
- data/lib/{core_ext → caricature/core_ext}/module.rb +0 -0
- data/lib/{core_ext → caricature/core_ext}/object.rb +0 -0
- data/lib/{core_ext → caricature/core_ext}/string.rb +0 -0
- data/lib/{core_ext → caricature/core_ext}/system/string.rb +0 -0
- data/lib/{core_ext → caricature/core_ext}/system/type.rb +6 -0
- data/lib/caricature/expectation.rb +108 -66
- data/lib/caricature/isolator.rb +3 -3
- data/lib/caricature/method_call_recorder.rb +32 -4
- data/lib/caricature/rspec/integration.rb +118 -77
- data/lib/caricature/version.rb +5 -5
- data/spec/bacon/integration/callback_spec.rb +156 -156
- data/spec/bacon/integration/clr_to_clr_spec.rb +1 -2
- data/spec/bacon/integration/event_spec.rb +98 -0
- data/spec/bacon/integration/indexer_spec.rb +1 -1
- data/spec/bacon/spec_helper.rb +4 -4
- data/spec/bacon/unit/descriptor_spec.rb +95 -42
- data/spec/bacon/unit/expectation_spec.rb +2 -2
- data/spec/bacon/unit/interop_spec.rb +1 -14
- data/spec/bacon/unit/isolation_spec.rb +1 -1
- data/spec/bacon/unit/isolator_spec.rb +5 -5
- data/spec/bin/ClrModels.dll +0 -0
- data/spec/models/ClrModels.cs +32 -8
- data/spec/models/ruby_models.rb +150 -150
- data/spec/rspec/integration/callback_spec.rb +156 -156
- data/spec/rspec/integration/indexer_spec.rb +1 -1
- data/spec/rspec/spec_helper.rb +12 -6
- data/spec/rspec/unit/descriptor_spec.rb +93 -42
- data/spec/rspec/unit/event_spec.rb +17 -0
- data/spec/rspec/unit/interop_spec.rb +0 -13
- data/spec/spec_helper.rb +14 -14
- metadata +20 -22
- data/lib/core_ext/core_ext.rb +0 -8
- data/spec/bin/ClrModels.dll.mdb +0 -0
@@ -124,13 +124,33 @@ module Caricature
|
|
124
124
|
# finds an argument variation that matches the provided +args+
|
125
125
|
def find_argument_variations(args, block_args)
|
126
126
|
return @variations if args.first.is_a?(Symbol) and args.last == :any
|
127
|
-
return
|
127
|
+
return match_hash(args, block_args) if args.size == 1 and args.last.is_a?(Hash)
|
128
|
+
return @variations.select { |ar| ar.args == args } if block_args.nil?
|
128
129
|
return @variations.select { |ar| ar.args == args and ar.block } if block_args.last == :any
|
129
130
|
return @variations.select do |ar|
|
130
131
|
av = ar.args == args
|
132
|
+
# idx = 0
|
133
|
+
# ags = ar.args
|
134
|
+
# av = args.all? do |ag|
|
135
|
+
# rag = ags[idx]
|
136
|
+
# res = if ag.is_a?(Hash) and rag.is_a?(Hash)
|
137
|
+
# ag.all? { |k, v| ar.args[idx][k] == v }
|
138
|
+
# else
|
139
|
+
# ag == rag
|
140
|
+
# end
|
141
|
+
# idx += 1
|
142
|
+
# res
|
143
|
+
# end
|
131
144
|
av and not ar.find_block_variation(*block_args).empty?
|
132
145
|
end
|
133
146
|
end
|
147
|
+
|
148
|
+
def match_hash(args, block_args)
|
149
|
+
@variations.select do |ar|
|
150
|
+
ags = ar.args.last
|
151
|
+
args.last.all? { |k, v| ags[k] == v }
|
152
|
+
end
|
153
|
+
end
|
134
154
|
end
|
135
155
|
|
136
156
|
# The recorder that will collect method calls and provides an interface for finding those recordings
|
@@ -168,6 +188,7 @@ module Caricature
|
|
168
188
|
res
|
169
189
|
})
|
170
190
|
end
|
191
|
+
|
171
192
|
|
172
193
|
def error
|
173
194
|
@error
|
@@ -177,9 +198,16 @@ module Caricature
|
|
177
198
|
def was_called?(method_name, block_args, mode=:instance, *args)
|
178
199
|
mc = method_calls[mode][method_name.to_s.to_sym]
|
179
200
|
if mc
|
180
|
-
|
181
|
-
|
182
|
-
|
201
|
+
vari = mc.find_argument_variations(args, block_args)
|
202
|
+
result = vari.any? { |agv| agv == args }
|
203
|
+
return result if result
|
204
|
+
if args.size == 1 and args.last.is_a?(Hash)
|
205
|
+
result = vari.any? do |agv|
|
206
|
+
agv.args.last.is_a?(Hash) and args.last.all? { |k, v| agv.args.last[k] == v }
|
207
|
+
end
|
208
|
+
end
|
209
|
+
@error = "Arguments don't match.\nYou expected:\n#{args.join(", ")}.\nI did find the following variations:\n#{mc.args.collect {|ar| ar.args.join(', ') }.join("\nand\n")}" unless result
|
210
|
+
result
|
183
211
|
else
|
184
212
|
@error = "Couldn't find a method with name #{method_name}"
|
185
213
|
return !!mc
|
@@ -1,77 +1,118 @@
|
|
1
|
-
module
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def
|
24
|
-
@
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
self
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
1
|
+
module Caricature
|
2
|
+
module RSpecAdapter
|
3
|
+
|
4
|
+
def setup_mocks_for_rspec
|
5
|
+
# No setup required
|
6
|
+
end
|
7
|
+
|
8
|
+
def verify_mocks_for_rspec
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown_mocks_for_rspec
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module RSpecMatchers
|
16
|
+
|
17
|
+
class HaveReceived
|
18
|
+
def initialize(expected)
|
19
|
+
@expected = expected
|
20
|
+
@block_args, @error, @args = nil, "", [:any]
|
21
|
+
end
|
22
|
+
|
23
|
+
def matches?(target)
|
24
|
+
@target = target
|
25
|
+
|
26
|
+
veri = @target.did_receive?(@expected).with(*@args)
|
27
|
+
veri.with_block_args(*@block_args) if @block_args
|
28
|
+
result = veri.successful?
|
29
|
+
|
30
|
+
@error = "\n#{veri.error}" unless result
|
31
|
+
|
32
|
+
result
|
33
|
+
end
|
34
|
+
|
35
|
+
def failure_message_for_should
|
36
|
+
"expected #{@target.inspect} to have received #{@expected}" + @error
|
37
|
+
end
|
38
|
+
|
39
|
+
def failure_message_for_should_not
|
40
|
+
"expected #{@target.inspect} not to have received #{@expected}" + @error
|
41
|
+
end
|
42
|
+
|
43
|
+
# constrain this verification to the provided arguments
|
44
|
+
def with(*args)
|
45
|
+
ags = *args
|
46
|
+
@args = args
|
47
|
+
@args = [:any] if (args.first.is_a?(Symbol) and args.first == :any) || ags.nil?
|
48
|
+
# @callback = b if b
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
def with_block_args(*args)
|
53
|
+
@block_args = args
|
54
|
+
self
|
55
|
+
end
|
56
|
+
|
57
|
+
# allow any arguments ignore the argument constraint
|
58
|
+
def allow_any_arguments
|
59
|
+
@args = :any
|
60
|
+
self
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class HaveRaised
|
65
|
+
def initialize(expected)
|
66
|
+
@expected = expected
|
67
|
+
@block_args, @error, @args = nil, "", [:any]
|
68
|
+
end
|
69
|
+
|
70
|
+
def matches?(target)
|
71
|
+
@target = target
|
72
|
+
|
73
|
+
veri = @target.did_raise_event?(@expected).with(*@args)
|
74
|
+
result = veri.successful?
|
75
|
+
|
76
|
+
@error = "\n#{veri.error}" unless result
|
77
|
+
|
78
|
+
result
|
79
|
+
end
|
80
|
+
|
81
|
+
def failure_message_for_should
|
82
|
+
"expected #{@target.inspect} to have received #{@expected}" + @error
|
83
|
+
end
|
84
|
+
|
85
|
+
def failure_message_for_should_not
|
86
|
+
"expected #{@target.inspect} not to have received #{@expected}" + @error
|
87
|
+
end
|
88
|
+
|
89
|
+
# constrain this verification to the provided arguments
|
90
|
+
def with(*args)
|
91
|
+
ags = *args
|
92
|
+
@args = args
|
93
|
+
@args = [:any] if (args.first.is_a?(Symbol) and args.first == :any) || ags.nil?
|
94
|
+
# @callback = b if b
|
95
|
+
self
|
96
|
+
end
|
97
|
+
|
98
|
+
# allow any arguments ignore the argument constraint
|
99
|
+
def allow_any_arguments
|
100
|
+
@args = :any
|
101
|
+
self
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def have_received(method_name, *args)
|
106
|
+
HaveReceived.new(method_name).with(*args)
|
107
|
+
end
|
108
|
+
|
109
|
+
def have_raised(event_name, *args)
|
110
|
+
HaveRaised.new(event_name).with(*args)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
#Spec::Runner.configure do |config|
|
116
|
+
# config.mock_with Caricature::RSpecAdapter
|
117
|
+
# config.include Caricature::RSpecMatchers
|
118
|
+
#end
|
data/lib/caricature/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
module Caricature
|
2
|
-
|
3
|
-
# The version number of the +Caricature+ library
|
4
|
-
VERSION = '0.7.
|
5
|
-
|
1
|
+
module Caricature
|
2
|
+
|
3
|
+
# The version number of the +Caricature+ library
|
4
|
+
VERSION = '0.7.5'
|
5
|
+
|
6
6
|
end
|
@@ -1,157 +1,157 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
-
|
3
|
-
describe "Callbacks on expectations" do
|
4
|
-
|
5
|
-
describe "CLR to CLR interactions" do
|
6
|
-
|
7
|
-
describe "when isolating CLR interfaces" do
|
8
|
-
|
9
|
-
before do
|
10
|
-
@ninja = ClrModels::Ninja.new
|
11
|
-
@weapon = Caricature::Isolation.for(ClrModels::IWeapon)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should execute the callback when the expectation is invoked" do
|
15
|
-
ninja = ClrModels::Ninja.new
|
16
|
-
cnt = 0
|
17
|
-
@weapon.when_receiving(:attack).with(:any) do |*args|
|
18
|
-
cnt += 1
|
19
|
-
end
|
20
|
-
@ninja.attack ninja, @weapon
|
21
|
-
|
22
|
-
cnt.should == 1
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "when isolating CLR classes" do
|
28
|
-
|
29
|
-
before do
|
30
|
-
@ninja = ClrModels::Ninja.new
|
31
|
-
@weapon = Caricature::Isolation.for(ClrModels::Sword)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should execute the callback when the expectation is invoked" do
|
35
|
-
ninja = ClrModels::Ninja.new
|
36
|
-
cnt = 0
|
37
|
-
@weapon.when_receiving(:attack).with(:any) do |*args|
|
38
|
-
cnt += 1
|
39
|
-
end
|
40
|
-
@ninja.attack ninja, @weapon
|
41
|
-
|
42
|
-
cnt.should == 1
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "when isolating CLR instances" do
|
48
|
-
before do
|
49
|
-
@ninja = ClrModels::Ninja.new
|
50
|
-
@weapon = Caricature::Isolation.for(ClrModels::Sword.new)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should execute the callback when the expectation is invoked" do
|
54
|
-
ninja = ClrModels::Ninja.new
|
55
|
-
cnt = 0
|
56
|
-
@weapon.when_receiving(:attack).with(ninja) do |*args|
|
57
|
-
cnt += 1
|
58
|
-
end
|
59
|
-
@ninja.attack ninja, @weapon
|
60
|
-
|
61
|
-
cnt.should == 1
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "CLR to ruby interactions" do
|
68
|
-
|
69
|
-
describe "when isolating CLR interfaces" do
|
70
|
-
|
71
|
-
before do
|
72
|
-
@ninja = Soldier.new
|
73
|
-
@weapon = Caricature::Isolation.for(ClrModels::IWeapon)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should execute the callback when the expectation is invoked" do
|
77
|
-
ninja = Soldier.new
|
78
|
-
cnt = 0
|
79
|
-
@weapon.when_receiving(:attack).with(:any) do |*args|
|
80
|
-
cnt += 1
|
81
|
-
end
|
82
|
-
@ninja.attack ninja, @weapon
|
83
|
-
|
84
|
-
cnt.should == 1
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
describe "when isolating CLR classes" do
|
90
|
-
|
91
|
-
before do
|
92
|
-
@ninja = Soldier.new
|
93
|
-
@weapon = Caricature::Isolation.for(ClrModels::Sword)
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should execute the callback when the expectation is invoked" do
|
97
|
-
ninja = Soldier.new
|
98
|
-
cnt = 0
|
99
|
-
@weapon.when_receiving(:attack).with(:any) do |*args|
|
100
|
-
cnt += 1
|
101
|
-
end
|
102
|
-
@ninja.attack ninja, @weapon
|
103
|
-
|
104
|
-
cnt.should == 1
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "when isolating CLR instances" do
|
110
|
-
before do
|
111
|
-
@ninja = Soldier.new
|
112
|
-
@weapon = Caricature::Isolation.for(ClrModels::Sword.new)
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should execute the callback when the expectation is invoked" do
|
116
|
-
ninja = Soldier.new
|
117
|
-
cnt = 0
|
118
|
-
@weapon.when_receiving(:attack).with(ninja) do |*args|
|
119
|
-
cnt += 1
|
120
|
-
end
|
121
|
-
@ninja.attack ninja, @weapon
|
122
|
-
|
123
|
-
cnt.should == 1
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
describe "Ruby to Ruby interactions" do
|
131
|
-
|
132
|
-
it "should execute a callback when an expectation is being invoked and with is not defined in a block" do
|
133
|
-
iso = Caricature::Isolation.for(Dagger)
|
134
|
-
cnt = 0
|
135
|
-
iso.when_receiving(:damage).with(:any) do |*args|
|
136
|
-
cnt += 1
|
137
|
-
end
|
138
|
-
iso.damage
|
139
|
-
cnt.should == 1
|
140
|
-
end
|
141
|
-
|
142
|
-
it "should execute a callback when an expectation is being invoked and with is defined in a block" do
|
143
|
-
cnt = 0
|
144
|
-
iso = Caricature::Isolation.for(Dagger)
|
145
|
-
iso.when_receiving(:damage) do |exp|
|
146
|
-
exp.with(:any) do |*args|
|
147
|
-
cnt += 1
|
148
|
-
end
|
149
|
-
end
|
150
|
-
iso.damage
|
151
|
-
cnt.should == 1
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
|
156
|
-
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
describe "Callbacks on expectations" do
|
4
|
+
|
5
|
+
describe "CLR to CLR interactions" do
|
6
|
+
|
7
|
+
describe "when isolating CLR interfaces" do
|
8
|
+
|
9
|
+
before do
|
10
|
+
@ninja = ClrModels::Ninja.new
|
11
|
+
@weapon = Caricature::Isolation.for(ClrModels::IWeapon)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should execute the callback when the expectation is invoked" do
|
15
|
+
ninja = ClrModels::Ninja.new
|
16
|
+
cnt = 0
|
17
|
+
@weapon.when_receiving(:attack).with(:any) do |*args|
|
18
|
+
cnt += 1
|
19
|
+
end
|
20
|
+
@ninja.attack ninja, @weapon
|
21
|
+
|
22
|
+
cnt.should == 1
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "when isolating CLR classes" do
|
28
|
+
|
29
|
+
before do
|
30
|
+
@ninja = ClrModels::Ninja.new
|
31
|
+
@weapon = Caricature::Isolation.for(ClrModels::Sword)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should execute the callback when the expectation is invoked" do
|
35
|
+
ninja = ClrModels::Ninja.new
|
36
|
+
cnt = 0
|
37
|
+
@weapon.when_receiving(:attack).with(:any) do |*args|
|
38
|
+
cnt += 1
|
39
|
+
end
|
40
|
+
@ninja.attack ninja, @weapon
|
41
|
+
|
42
|
+
cnt.should == 1
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "when isolating CLR instances" do
|
48
|
+
before do
|
49
|
+
@ninja = ClrModels::Ninja.new
|
50
|
+
@weapon = Caricature::Isolation.for(ClrModels::Sword.new)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should execute the callback when the expectation is invoked" do
|
54
|
+
ninja = ClrModels::Ninja.new
|
55
|
+
cnt = 0
|
56
|
+
@weapon.when_receiving(:attack).with(ninja) do |*args|
|
57
|
+
cnt += 1
|
58
|
+
end
|
59
|
+
@ninja.attack ninja, @weapon
|
60
|
+
|
61
|
+
cnt.should == 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "CLR to ruby interactions" do
|
68
|
+
|
69
|
+
describe "when isolating CLR interfaces" do
|
70
|
+
|
71
|
+
before do
|
72
|
+
@ninja = Soldier.new
|
73
|
+
@weapon = Caricature::Isolation.for(ClrModels::IWeapon)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should execute the callback when the expectation is invoked" do
|
77
|
+
ninja = Soldier.new
|
78
|
+
cnt = 0
|
79
|
+
@weapon.when_receiving(:attack).with(:any) do |*args|
|
80
|
+
cnt += 1
|
81
|
+
end
|
82
|
+
@ninja.attack ninja, @weapon
|
83
|
+
|
84
|
+
cnt.should == 1
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "when isolating CLR classes" do
|
90
|
+
|
91
|
+
before do
|
92
|
+
@ninja = Soldier.new
|
93
|
+
@weapon = Caricature::Isolation.for(ClrModels::Sword)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should execute the callback when the expectation is invoked" do
|
97
|
+
ninja = Soldier.new
|
98
|
+
cnt = 0
|
99
|
+
@weapon.when_receiving(:attack).with(:any) do |*args|
|
100
|
+
cnt += 1
|
101
|
+
end
|
102
|
+
@ninja.attack ninja, @weapon
|
103
|
+
|
104
|
+
cnt.should == 1
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "when isolating CLR instances" do
|
110
|
+
before do
|
111
|
+
@ninja = Soldier.new
|
112
|
+
@weapon = Caricature::Isolation.for(ClrModels::Sword.new)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should execute the callback when the expectation is invoked" do
|
116
|
+
ninja = Soldier.new
|
117
|
+
cnt = 0
|
118
|
+
@weapon.when_receiving(:attack).with(ninja) do |*args|
|
119
|
+
cnt += 1
|
120
|
+
end
|
121
|
+
@ninja.attack ninja, @weapon
|
122
|
+
|
123
|
+
cnt.should == 1
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "Ruby to Ruby interactions" do
|
131
|
+
|
132
|
+
it "should execute a callback when an expectation is being invoked and with is not defined in a block" do
|
133
|
+
iso = Caricature::Isolation.for(Dagger)
|
134
|
+
cnt = 0
|
135
|
+
iso.when_receiving(:damage).with(:any) do |*args|
|
136
|
+
cnt += 1
|
137
|
+
end
|
138
|
+
iso.damage
|
139
|
+
cnt.should == 1
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should execute a callback when an expectation is being invoked and with is defined in a block" do
|
143
|
+
cnt = 0
|
144
|
+
iso = Caricature::Isolation.for(Dagger)
|
145
|
+
iso.when_receiving(:damage) do |exp|
|
146
|
+
exp.with(:any) do |*args|
|
147
|
+
cnt += 1
|
148
|
+
end
|
149
|
+
end
|
150
|
+
iso.damage
|
151
|
+
cnt.should == 1
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
|
157
157
|
end
|