caricature 0.7.6 → 0.7.7
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/caricature.gemspec +3 -3
- data/lib/bin/Workarounds.dll.mdb +0 -0
- data/lib/caricature.rb +25 -25
- data/lib/caricature/clr.rb +6 -6
- data/lib/caricature/clr/aspnet_mvc.rb +54 -54
- data/lib/caricature/core_ext.rb +10 -10
- data/lib/caricature/core_ext/array.rb +9 -9
- data/lib/caricature/core_ext/class.rb +31 -14
- data/lib/caricature/core_ext/hash.rb +12 -12
- data/lib/caricature/core_ext/module.rb +14 -14
- data/lib/caricature/core_ext/object.rb +76 -18
- data/lib/caricature/core_ext/string.rb +16 -16
- data/lib/caricature/core_ext/system/string.rb +20 -20
- data/lib/caricature/core_ext/system/type.rb +26 -26
- data/lib/caricature/descriptor.rb +73 -73
- data/lib/caricature/expectation.rb +264 -263
- data/lib/caricature/isolation.rb +143 -143
- data/lib/caricature/isolator.rb +302 -302
- data/lib/caricature/messenger.rb +67 -67
- data/lib/caricature/method_call_recorder.rb +228 -228
- data/lib/caricature/verification.rb +60 -60
- data/lib/caricature/version.rb +1 -1
- data/spec/bacon/integration/clr_to_clr_spec.rb +4 -4
- data/spec/bacon/integration/clr_to_ruby_spec.rb +227 -227
- data/spec/bacon/integration/event_spec.rb +2 -2
- data/spec/bacon/integration/ruby_to_ruby_spec.rb +270 -270
- data/spec/bacon/integration/syntax_spec.rb +43 -0
- data/spec/bacon/unit/core_ext_spec.rb +87 -87
- data/spec/bacon/unit/expectation_spec.rb +300 -300
- data/spec/bacon/unit/interop_spec.rb +29 -29
- data/spec/bacon/unit/isolation_spec.rb +86 -86
- data/spec/bacon/unit/isolator_spec.rb +219 -219
- data/spec/bacon/unit/messaging_spec.rb +310 -310
- data/spec/bacon/unit/method_call_spec.rb +342 -342
- data/spec/bin/ClrModels.dll.mdb +0 -0
- data/spec/rspec/unit/event_spec.rb +1 -1
- metadata +31 -11
- data/spec/models.notused/ClrModels.cs +0 -241
- data/spec/models.notused/ruby_models.rb +0 -151
data/spec/bin/ClrModels.dll.mdb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caricature
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 13
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 7
|
9
|
+
- 7
|
10
|
+
version: 0.7.7
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Ivan Porto Carrero
|
@@ -9,19 +15,25 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-07-09 00:00:00 +02:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: uuidtools
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 15
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 0
|
33
|
+
- 0
|
23
34
|
version: 2.0.0
|
24
|
-
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
25
37
|
description: Caricature brings simple mocking to Ruby, DLR and CLR.
|
26
38
|
email: ivan@flanders.co.nz
|
27
39
|
executables: []
|
@@ -34,6 +46,7 @@ files:
|
|
34
46
|
- README.rdoc
|
35
47
|
- Rakefile
|
36
48
|
- caricature.gemspec
|
49
|
+
- lib/bin/Workarounds.dll.mdb
|
37
50
|
- lib/caricature.rb
|
38
51
|
- lib/caricature/bacon.rb
|
39
52
|
- lib/caricature/bacon/integration.rb
|
@@ -71,6 +84,7 @@ files:
|
|
71
84
|
- spec/bacon/integration/event_spec.rb
|
72
85
|
- spec/bacon/integration/indexer_spec.rb
|
73
86
|
- spec/bacon/integration/ruby_to_ruby_spec.rb
|
87
|
+
- spec/bacon/integration/syntax_spec.rb
|
74
88
|
- spec/bacon/spec_helper.rb
|
75
89
|
- spec/bacon/unit/core_ext_spec.rb
|
76
90
|
- spec/bacon/unit/descriptor_spec.rb
|
@@ -110,8 +124,6 @@ files:
|
|
110
124
|
- spec/fixtures/soldier_with_class_members.rb
|
111
125
|
- spec/fixtures/swift_cleanup_crew.rb
|
112
126
|
- spec/fixtures/with_class_methods.rb
|
113
|
-
- spec/models.notused/ClrModels.cs
|
114
|
-
- spec/models.notused/ruby_models.rb
|
115
127
|
- spec/rspec/integration/callback_spec.rb
|
116
128
|
- spec/rspec/integration/clr_to_clr_spec.rb
|
117
129
|
- spec/rspec/integration/clr_to_ruby_spec.rb
|
@@ -145,21 +157,29 @@ rdoc_options:
|
|
145
157
|
require_paths:
|
146
158
|
- lib
|
147
159
|
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
none: false
|
148
161
|
requirements:
|
149
162
|
- - ">="
|
150
163
|
- !ruby/object:Gem::Version
|
164
|
+
hash: 59
|
165
|
+
segments:
|
166
|
+
- 1
|
167
|
+
- 8
|
168
|
+
- 6
|
151
169
|
version: 1.8.6
|
152
|
-
version:
|
153
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
+
none: false
|
154
172
|
requirements:
|
155
173
|
- - ">="
|
156
174
|
- !ruby/object:Gem::Version
|
175
|
+
hash: 3
|
176
|
+
segments:
|
177
|
+
- 0
|
157
178
|
version: "0"
|
158
|
-
version:
|
159
179
|
requirements: []
|
160
180
|
|
161
181
|
rubyforge_project: caricature
|
162
|
-
rubygems_version: 1.3.
|
182
|
+
rubygems_version: 1.3.7
|
163
183
|
signing_key:
|
164
184
|
specification_version: 3
|
165
185
|
summary: Caricature brings simple mocking to Ruby, DLR and CLR.
|
@@ -1,241 +0,0 @@
|
|
1
|
-
using System;
|
2
|
-
using System.Collections.Generic;
|
3
|
-
|
4
|
-
namespace ClrModels{
|
5
|
-
public interface IWeapon{
|
6
|
-
int Attack(IWarrior warrior);
|
7
|
-
int Damage();
|
8
|
-
}
|
9
|
-
|
10
|
-
public interface IWarrior
|
11
|
-
{
|
12
|
-
|
13
|
-
int Id { get; }
|
14
|
-
string Name { get; set; }
|
15
|
-
bool IsKilledBy(IWeapon weapon);
|
16
|
-
int Attack(IWarrior target, IWeapon weapon);
|
17
|
-
int SurviveAttackWith(IWeapon weapon);
|
18
|
-
}
|
19
|
-
|
20
|
-
public interface IExposing {
|
21
|
-
event EventHandler<EventArgs> OnIsExposedChanged;
|
22
|
-
bool IsExposed {get; set; }
|
23
|
-
}
|
24
|
-
|
25
|
-
public interface IExposingBridge : IWarrior, IExposing {
|
26
|
-
void SomeMethod();
|
27
|
-
}
|
28
|
-
|
29
|
-
public interface IExposingWarrior : IExposingBridge {
|
30
|
-
void OwnMethod();
|
31
|
-
}
|
32
|
-
|
33
|
-
public interface IExplodingWarrior : IExposingBridge{
|
34
|
-
event EventHandler<EventArgs> OnExploding;
|
35
|
-
void Explode();
|
36
|
-
|
37
|
-
}
|
38
|
-
|
39
|
-
public class ExposingWarrior : IExposingWarrior{
|
40
|
-
private readonly int _id;
|
41
|
-
|
42
|
-
public string Name { get; set; }
|
43
|
-
public int Id { get { return _id; } }
|
44
|
-
|
45
|
-
public int Attack(IWarrior target, IWeapon weapon){
|
46
|
-
return weapon.Attack(target);
|
47
|
-
}
|
48
|
-
|
49
|
-
public bool IsKilledBy(IWeapon weapon)
|
50
|
-
{
|
51
|
-
return weapon.Damage() > 3;
|
52
|
-
}
|
53
|
-
|
54
|
-
public virtual event EventHandler<EventArgs> OnIsExposedChanged;
|
55
|
-
public bool IsExposed {get; set; }
|
56
|
-
|
57
|
-
|
58
|
-
public event EventHandler<EventArgs> OnIsAliveChanged;
|
59
|
-
|
60
|
-
public void Die(){
|
61
|
-
OnIsAliveChanged(this, EventArgs.Empty);
|
62
|
-
}
|
63
|
-
|
64
|
-
public static event EventHandler<EventArgs> OnCountChanged;
|
65
|
-
|
66
|
-
public static void ChangeCount(){
|
67
|
-
OnCountChanged(null, EventArgs.Empty);
|
68
|
-
}
|
69
|
-
|
70
|
-
|
71
|
-
public void SomeMethod(){}
|
72
|
-
public void OwnMethod(){
|
73
|
-
|
74
|
-
}
|
75
|
-
|
76
|
-
private int _life = 10;
|
77
|
-
public int SurviveAttackWith(IWeapon weapon){
|
78
|
-
return _life - weapon.Damage();
|
79
|
-
}
|
80
|
-
|
81
|
-
public void Explode(){
|
82
|
-
IsExposed = !IsExposed;
|
83
|
-
var handler = OnIsExposedChanged;
|
84
|
-
if(handler != null){
|
85
|
-
handler(this, EventArgs.Empty);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
public bool HasEventSubscriptions{ get { return OnIsExposedChanged != null; } }
|
90
|
-
}
|
91
|
-
|
92
|
-
public class ExposedChangedSubscriber{
|
93
|
-
|
94
|
-
private readonly IExposingBridge _warrior;
|
95
|
-
|
96
|
-
public ExposedChangedSubscriber(IExposingBridge warrior){
|
97
|
-
_warrior = warrior;
|
98
|
-
_warrior.OnIsExposedChanged += OnExposedChanged;
|
99
|
-
}
|
100
|
-
|
101
|
-
public int Counter { get; set; }
|
102
|
-
public object Sender {get; set; }
|
103
|
-
public EventArgs Args { get; set; }
|
104
|
-
|
105
|
-
private void OnExposedChanged(object sender, EventArgs args){
|
106
|
-
Counter++;
|
107
|
-
Sender = sender;
|
108
|
-
Args = args;
|
109
|
-
}
|
110
|
-
|
111
|
-
}
|
112
|
-
|
113
|
-
public class Sword : IWeapon {
|
114
|
-
|
115
|
-
public virtual int Attack(IWarrior warrior){
|
116
|
-
return warrior.SurviveAttackWith(this);
|
117
|
-
}
|
118
|
-
|
119
|
-
public int Damage(){
|
120
|
-
return 4;
|
121
|
-
}
|
122
|
-
}
|
123
|
-
|
124
|
-
public class SwordWithStatics : Sword{
|
125
|
-
|
126
|
-
static SwordWithStatics(){
|
127
|
-
ClassNaming = "Sword with statics";
|
128
|
-
}
|
129
|
-
|
130
|
-
public SwordWithStatics(){ SwordName = "Sword name for statics"; }
|
131
|
-
|
132
|
-
public void AnotherMethod(){}
|
133
|
-
public static void AStaticMethod(){}
|
134
|
-
public static string ClassNaming { get; set; }
|
135
|
-
public string SwordName{get; set;}
|
136
|
-
}
|
137
|
-
|
138
|
-
public class Ninja : IWarrior{
|
139
|
-
|
140
|
-
public Ninja(){
|
141
|
-
Name = "Tony the Ninja";
|
142
|
-
_id = 1;
|
143
|
-
}
|
144
|
-
|
145
|
-
private readonly int _id;
|
146
|
-
|
147
|
-
public string Name { get; set; }
|
148
|
-
public int Id { get { return _id; } }
|
149
|
-
|
150
|
-
public int Attack(IWarrior target, IWeapon weapon){
|
151
|
-
return weapon.Attack(target);
|
152
|
-
}
|
153
|
-
|
154
|
-
public bool IsKilledBy(IWeapon weapon)
|
155
|
-
{
|
156
|
-
return weapon.Damage() > 3;
|
157
|
-
}
|
158
|
-
|
159
|
-
private int _life = 10;
|
160
|
-
public virtual int SurviveAttackWith(IWeapon weapon){
|
161
|
-
return _life - weapon.Damage();
|
162
|
-
}
|
163
|
-
|
164
|
-
|
165
|
-
}
|
166
|
-
|
167
|
-
public sealed class Samurai : IWarrior{
|
168
|
-
|
169
|
-
private readonly int _id;
|
170
|
-
|
171
|
-
public string Name { get; set; }
|
172
|
-
public int Id { get { return _id; } }
|
173
|
-
|
174
|
-
public int Attack(IWarrior target, IWeapon weapon){
|
175
|
-
return weapon.Attack(target);
|
176
|
-
}
|
177
|
-
|
178
|
-
public bool IsKilledBy(IWeapon weapon)
|
179
|
-
{
|
180
|
-
return weapon.Damage() > 5;
|
181
|
-
}
|
182
|
-
|
183
|
-
private int _life = 10;
|
184
|
-
public int SurviveAttackWith(IWeapon weapon){
|
185
|
-
return _life - weapon.Damage();
|
186
|
-
}
|
187
|
-
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
public class MyClassWithAStatic{
|
192
|
-
|
193
|
-
public string HelloWorld(){
|
194
|
-
return "Hello World!";
|
195
|
-
}
|
196
|
-
|
197
|
-
public static string GoodByeWorld(){
|
198
|
-
return "Goodbye world!";
|
199
|
-
}
|
200
|
-
}
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
public class StaticCaller{
|
205
|
-
|
206
|
-
public string CallsStatic(){
|
207
|
-
return MyClassWithAStatic.GoodByeWorld();
|
208
|
-
}
|
209
|
-
}
|
210
|
-
|
211
|
-
public class IndexerContained{
|
212
|
-
|
213
|
-
private Dictionary<string, string> _inner = new Dictionary<string, string>{
|
214
|
-
{ "key1", "value1" },
|
215
|
-
{ "key2", "value2" },
|
216
|
-
{ "key3", "value3" },
|
217
|
-
{ "key4", "value4" }
|
218
|
-
};
|
219
|
-
|
220
|
-
public virtual string this[string name]{
|
221
|
-
get { return _inner[name]; }
|
222
|
-
set { _inner[name] = value; }
|
223
|
-
}
|
224
|
-
}
|
225
|
-
|
226
|
-
public class IndexerCaller{
|
227
|
-
|
228
|
-
public string CallIndexOnClass(IndexerContained klass, string name){
|
229
|
-
return klass[name];
|
230
|
-
}
|
231
|
-
|
232
|
-
public string CallIndexOnInterface(IHaveAnIndexer klass, string name){
|
233
|
-
return klass[name];
|
234
|
-
}
|
235
|
-
|
236
|
-
}
|
237
|
-
|
238
|
-
public interface IHaveAnIndexer{
|
239
|
-
string this[string name]{ get; set; }
|
240
|
-
}
|
241
|
-
}
|
@@ -1,151 +0,0 @@
|
|
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
|
-
end
|