caricature 0.7.2 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/spec/models/ruby_models.rb
CHANGED
@@ -1,151 +1,151 @@
|
|
1
|
-
class Soldier
|
2
|
-
|
3
|
-
def initialize
|
4
|
-
@life = 10
|
5
|
-
end
|
6
|
-
|
7
|
-
def name
|
8
|
-
"Tommy Boy"
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_s
|
12
|
-
"I'm a soldier"
|
13
|
-
end
|
14
|
-
|
15
|
-
def attack(target, weapon)
|
16
|
-
weapon.attack(target)
|
17
|
-
end
|
18
|
-
|
19
|
-
def is_killed_by?(weapon)
|
20
|
-
weapon.damage > 3
|
21
|
-
end
|
22
|
-
|
23
|
-
def survive_attack_with(weapon)
|
24
|
-
@life - weapon.damage
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
class SoldierWithClassMembers
|
30
|
-
def initialize
|
31
|
-
@life = 10
|
32
|
-
end
|
33
|
-
def name
|
34
|
-
"Tommy Boy"
|
35
|
-
end
|
36
|
-
def to_s
|
37
|
-
"I'm a soldier"
|
38
|
-
end
|
39
|
-
def attack(target, weapon)
|
40
|
-
weapon.attack(target)
|
41
|
-
end
|
42
|
-
def is_killed_by?(weapon)
|
43
|
-
weapon.damage > 3
|
44
|
-
end
|
45
|
-
def survive_attack_with(weapon)
|
46
|
-
@life - weapon.damage
|
47
|
-
end
|
48
|
-
def self.class_name
|
49
|
-
"DaggerWithClassMembers"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
class Dagger
|
54
|
-
|
55
|
-
def damage
|
56
|
-
2
|
57
|
-
end
|
58
|
-
|
59
|
-
def attack(target)
|
60
|
-
target.survive_attack_with self
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
class DaggerWithClassMembers
|
67
|
-
def damage
|
68
|
-
2
|
69
|
-
end
|
70
|
-
def attack(target)
|
71
|
-
target.survive_attack_with self
|
72
|
-
end
|
73
|
-
def self.class_name
|
74
|
-
"DaggerWithClassMembers"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
class WithClassMethods
|
79
|
-
|
80
|
-
def hello_world
|
81
|
-
"Hello World!"
|
82
|
-
end
|
83
|
-
|
84
|
-
def self.good_bye_world
|
85
|
-
"Goodbye world!"
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
class Sheath
|
91
|
-
attr_reader :dagger
|
92
|
-
|
93
|
-
def initialize(dagger)
|
94
|
-
@dagger = dagger
|
95
|
-
end
|
96
|
-
|
97
|
-
def insert(dagger)
|
98
|
-
raise "There is already a dagger in here" if @dagger
|
99
|
-
@dagger = dagger
|
100
|
-
end
|
101
|
-
|
102
|
-
def draw
|
103
|
-
raise "Dagger is nowhere to be found" unless @dagger
|
104
|
-
d = @dagger
|
105
|
-
@dagger = nil
|
106
|
-
d
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
if defined? IRONRUBY_VERSION
|
111
|
-
|
112
|
-
module Caricature
|
113
|
-
|
114
|
-
module InterfaceIncludingModule
|
115
|
-
include ClrModels::IWarrior
|
116
|
-
end
|
117
|
-
|
118
|
-
module PureRubyModule
|
119
|
-
|
120
|
-
end
|
121
|
-
|
122
|
-
module RubyModuleIncludingModule
|
123
|
-
include PureRubyModule
|
124
|
-
end
|
125
|
-
|
126
|
-
module InterfaceUpTheWazoo
|
127
|
-
include InterfaceIncludingModule
|
128
|
-
end
|
129
|
-
|
130
|
-
class InterfaceIncludingClass
|
131
|
-
include ClrModels::IWarrior
|
132
|
-
end
|
133
|
-
|
134
|
-
class SubClassingClrClass < ClrModels::Ninja
|
135
|
-
|
136
|
-
end
|
137
|
-
|
138
|
-
class InterfaceUpTheWazooClass
|
139
|
-
include InterfaceUpTheWazoo
|
140
|
-
end
|
141
|
-
|
142
|
-
class SubclassingRubyClass < Soldier
|
143
|
-
|
144
|
-
end
|
145
|
-
|
146
|
-
class ModuleIncludingClass
|
147
|
-
include RubyModuleIncludingModule
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
1
|
+
class Soldier
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
@life = 10
|
5
|
+
end
|
6
|
+
|
7
|
+
def name
|
8
|
+
"Tommy Boy"
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
"I'm a soldier"
|
13
|
+
end
|
14
|
+
|
15
|
+
def attack(target, weapon)
|
16
|
+
weapon.attack(target)
|
17
|
+
end
|
18
|
+
|
19
|
+
def is_killed_by?(weapon)
|
20
|
+
weapon.damage > 3
|
21
|
+
end
|
22
|
+
|
23
|
+
def survive_attack_with(weapon)
|
24
|
+
@life - weapon.damage
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
class SoldierWithClassMembers
|
30
|
+
def initialize
|
31
|
+
@life = 10
|
32
|
+
end
|
33
|
+
def name
|
34
|
+
"Tommy Boy"
|
35
|
+
end
|
36
|
+
def to_s
|
37
|
+
"I'm a soldier"
|
38
|
+
end
|
39
|
+
def attack(target, weapon)
|
40
|
+
weapon.attack(target)
|
41
|
+
end
|
42
|
+
def is_killed_by?(weapon)
|
43
|
+
weapon.damage > 3
|
44
|
+
end
|
45
|
+
def survive_attack_with(weapon)
|
46
|
+
@life - weapon.damage
|
47
|
+
end
|
48
|
+
def self.class_name
|
49
|
+
"DaggerWithClassMembers"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class Dagger
|
54
|
+
|
55
|
+
def damage
|
56
|
+
2
|
57
|
+
end
|
58
|
+
|
59
|
+
def attack(target)
|
60
|
+
target.survive_attack_with self
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
class DaggerWithClassMembers
|
67
|
+
def damage
|
68
|
+
2
|
69
|
+
end
|
70
|
+
def attack(target)
|
71
|
+
target.survive_attack_with self
|
72
|
+
end
|
73
|
+
def self.class_name
|
74
|
+
"DaggerWithClassMembers"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class WithClassMethods
|
79
|
+
|
80
|
+
def hello_world
|
81
|
+
"Hello World!"
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.good_bye_world
|
85
|
+
"Goodbye world!"
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
class Sheath
|
91
|
+
attr_reader :dagger
|
92
|
+
|
93
|
+
def initialize(dagger)
|
94
|
+
@dagger = dagger
|
95
|
+
end
|
96
|
+
|
97
|
+
def insert(dagger)
|
98
|
+
raise "There is already a dagger in here" if @dagger
|
99
|
+
@dagger = dagger
|
100
|
+
end
|
101
|
+
|
102
|
+
def draw
|
103
|
+
raise "Dagger is nowhere to be found" unless @dagger
|
104
|
+
d = @dagger
|
105
|
+
@dagger = nil
|
106
|
+
d
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
if defined? IRONRUBY_VERSION
|
111
|
+
|
112
|
+
module Caricature
|
113
|
+
|
114
|
+
module InterfaceIncludingModule
|
115
|
+
include ClrModels::IWarrior
|
116
|
+
end
|
117
|
+
|
118
|
+
module PureRubyModule
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
module RubyModuleIncludingModule
|
123
|
+
include PureRubyModule
|
124
|
+
end
|
125
|
+
|
126
|
+
module InterfaceUpTheWazoo
|
127
|
+
include InterfaceIncludingModule
|
128
|
+
end
|
129
|
+
|
130
|
+
class InterfaceIncludingClass
|
131
|
+
include ClrModels::IWarrior
|
132
|
+
end
|
133
|
+
|
134
|
+
class SubClassingClrClass < ClrModels::Ninja
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
class InterfaceUpTheWazooClass
|
139
|
+
include InterfaceUpTheWazoo
|
140
|
+
end
|
141
|
+
|
142
|
+
class SubclassingRubyClass < Soldier
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
class ModuleIncludingClass
|
147
|
+
include RubyModuleIncludingModule
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
151
|
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
|