caricature 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +97 -97
- data/Rakefile +309 -310
- data/caricature.gemspec +123 -110
- data/lib/caricature/bacon/integration.rb +75 -75
- data/lib/caricature/bacon.rb +2 -2
- data/lib/caricature/clr/descriptor.rb +159 -159
- data/lib/caricature/clr/event_verification.rb +56 -56
- data/lib/caricature/clr/expectation.rb +100 -100
- data/lib/caricature/clr/isolation.rb +78 -78
- data/lib/caricature/clr/isolator.rb +252 -252
- data/lib/caricature/clr/messenger.rb +51 -49
- data/lib/caricature/clr/method_call_recorder.rb +96 -96
- data/lib/caricature/expectation.rb +1 -1
- data/lib/caricature/method_call_recorder.rb +3 -3
- data/lib/caricature/rspec/integration.rb +118 -118
- data/lib/caricature/version.rb +5 -5
- data/lib/caricature.rb +25 -25
- data/spec/bacon/integration/callback_spec.rb +156 -156
- data/spec/bacon/integration/clr_to_clr_spec.rb +325 -253
- data/spec/bacon/integration/event_spec.rb +97 -97
- data/spec/bacon/integration/indexer_spec.rb +27 -27
- data/spec/bacon/spec_helper.rb +4 -4
- data/spec/bacon/unit/descriptor_spec.rb +212 -212
- data/spec/bacon/unit/sword_spec.rb +39 -39
- data/spec/bacon/unit/verification_spec.rb +103 -103
- data/spec/bin/ClrModels.dll +0 -0
- data/spec/bin/ClrModels.dll.mdb +0 -0
- data/spec/fixtures/ExplodingCar.cs +56 -0
- data/spec/fixtures/ExposedChangedSubscriber.cs +26 -0
- data/spec/fixtures/ExposingWarrior.cs +58 -0
- data/spec/fixtures/IExplodingWarrior.cs +10 -0
- data/spec/fixtures/IExposing.cs +9 -0
- data/spec/fixtures/IExposingBridge.cs +9 -0
- data/spec/fixtures/IExposingWarrior.cs +8 -0
- data/spec/fixtures/IHaveAnIndexer.cs +8 -0
- data/spec/fixtures/IWarrior.cs +13 -0
- data/spec/fixtures/IWeapon.cs +9 -0
- data/spec/fixtures/IndexerCaller.cs +17 -0
- data/spec/fixtures/IndexerContained.cs +20 -0
- data/spec/fixtures/MyClassWithAStatic.cs +16 -0
- data/spec/fixtures/Ninja.cs +34 -0
- data/spec/fixtures/Samurai.cs +29 -0
- data/spec/fixtures/StaticCaller.cs +12 -0
- data/spec/fixtures/Sword.cs +16 -0
- data/spec/fixtures/SwordWithStatics.cs +19 -0
- data/spec/fixtures/clr_interaction.rb +61 -0
- data/spec/fixtures/dagger.rb +11 -0
- data/spec/fixtures/dagger_with_class_members.rb +11 -0
- data/spec/fixtures/sheath.rb +19 -0
- data/spec/fixtures/soldier.rb +29 -0
- data/spec/fixtures/soldier_with_class_members.rb +7 -0
- data/spec/fixtures/swift_cleanup_crew.rb +21 -0
- data/spec/fixtures/with_class_methods.rb +11 -0
- data/spec/{models → models.notused}/ClrModels.cs +241 -241
- data/spec/{models → models.notused}/ruby_models.rb +150 -150
- data/spec/rspec/integration/callback_spec.rb +156 -156
- data/spec/rspec/integration/clr_to_clr_spec.rb +254 -254
- data/spec/rspec/integration/clr_to_ruby_spec.rb +227 -227
- data/spec/rspec/integration/indexer_spec.rb +27 -27
- data/spec/rspec/integration/ruby_to_ruby_spec.rb +271 -271
- data/spec/rspec/spec_helper.rb +12 -12
- data/spec/rspec/unit/core_ext_spec.rb +87 -87
- data/spec/rspec/unit/descriptor_spec.rb +210 -210
- data/spec/rspec/unit/event_spec.rb +16 -16
- data/spec/rspec/unit/expectation_spec.rb +300 -300
- data/spec/rspec/unit/interop_spec.rb +29 -29
- data/spec/rspec/unit/isolation_spec.rb +86 -86
- data/spec/rspec/unit/isolator_spec.rb +219 -219
- data/spec/rspec/unit/messaging_spec.rb +310 -310
- data/spec/rspec/unit/method_call_spec.rb +342 -342
- data/spec/rspec/unit/sword_spec.rb +39 -39
- data/spec/rspec/unit/verification_spec.rb +103 -103
- data/spec/spec_helper.rb +16 -15
- metadata +42 -11
data/caricature.gemspec
CHANGED
@@ -1,111 +1,124 @@
|
|
1
|
-
# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!
|
2
|
-
# RUN : 'rake gem:update_gemspec'
|
3
|
-
|
4
|
-
Gem::Specification.new do |s|
|
5
|
-
s.authors = ["Ivan Porto Carrero"]
|
6
|
-
s.bindir = "bin"
|
7
|
-
s.add_dependency "uuidtools", ">= 2.0.0, runtime"
|
8
|
-
s.description = "Caricature brings simple mocking to Ruby, DLR and CLR."
|
9
|
-
s.email = "ivan@flanders.co.nz"
|
10
|
-
s.extra_rdoc_files = ["README.rdoc"]
|
11
|
-
s.files = ["README.rdoc",
|
12
|
-
"Rakefile",
|
13
|
-
"caricature.gemspec",
|
14
|
-
"lib/caricature",
|
15
|
-
"lib/caricature.rb",
|
16
|
-
"lib/caricature/bacon",
|
17
|
-
"lib/caricature/
|
18
|
-
"lib/caricature/
|
19
|
-
"lib/caricature/clr",
|
20
|
-
"lib/caricature/clr.rb",
|
21
|
-
"lib/caricature/clr/
|
22
|
-
"lib/caricature/clr/
|
23
|
-
"lib/caricature/clr/
|
24
|
-
"lib/caricature/clr/
|
25
|
-
"lib/caricature/clr/
|
26
|
-
"lib/caricature/
|
27
|
-
"lib/caricature/
|
28
|
-
"lib/caricature/
|
29
|
-
"lib/caricature/core_ext",
|
30
|
-
"lib/caricature/core_ext.rb",
|
31
|
-
"lib/caricature/core_ext/
|
32
|
-
"lib/caricature/core_ext/
|
33
|
-
"lib/caricature/core_ext/
|
34
|
-
"lib/caricature/core_ext/
|
35
|
-
"lib/caricature/
|
36
|
-
"lib/caricature/
|
37
|
-
"lib/caricature/
|
38
|
-
"lib/caricature/
|
39
|
-
"lib/caricature/
|
40
|
-
"lib/caricature/
|
41
|
-
"lib/caricature/
|
42
|
-
"lib/caricature/
|
43
|
-
"lib/caricature/
|
44
|
-
"lib/caricature/
|
45
|
-
"
|
46
|
-
"
|
47
|
-
"
|
48
|
-
"
|
49
|
-
"
|
50
|
-
"
|
51
|
-
"spec/bacon",
|
52
|
-
"spec/bacon/
|
53
|
-
"spec/bacon/
|
54
|
-
"spec/bacon/
|
55
|
-
"spec/bacon/
|
56
|
-
"spec/bacon/
|
57
|
-
"spec/bacon/
|
58
|
-
"spec/bacon/
|
59
|
-
"spec/bacon/
|
60
|
-
"spec/bacon/unit",
|
61
|
-
"spec/bacon/unit/
|
62
|
-
"spec/
|
63
|
-
"spec/
|
64
|
-
"spec/
|
65
|
-
"spec/
|
66
|
-
"spec/
|
67
|
-
"spec/
|
68
|
-
"spec/
|
69
|
-
"spec/
|
70
|
-
"spec/
|
71
|
-
"spec/
|
72
|
-
"spec/
|
73
|
-
"spec/
|
74
|
-
"spec/
|
75
|
-
"spec/
|
76
|
-
"spec/
|
77
|
-
"spec/
|
78
|
-
"spec/
|
79
|
-
"spec/
|
80
|
-
"spec/
|
81
|
-
"spec/
|
82
|
-
"spec/
|
83
|
-
"spec/
|
84
|
-
"spec/
|
85
|
-
"spec/
|
86
|
-
"spec/
|
87
|
-
"spec/
|
88
|
-
"spec/
|
89
|
-
"spec/
|
90
|
-
"spec/
|
91
|
-
"spec/
|
92
|
-
"spec/rspec/
|
93
|
-
"spec/rspec/
|
94
|
-
"spec/rspec/
|
95
|
-
"spec/rspec/
|
96
|
-
"spec/
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
s.
|
1
|
+
# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!
|
2
|
+
# RUN : 'rake gem:update_gemspec'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.authors = ["Ivan Porto Carrero"]
|
6
|
+
s.bindir = "bin"
|
7
|
+
s.add_dependency "uuidtools", ">= 2.0.0, runtime"
|
8
|
+
s.description = "Caricature brings simple mocking to Ruby, DLR and CLR."
|
9
|
+
s.email = "ivan@flanders.co.nz"
|
10
|
+
s.extra_rdoc_files = ["README.rdoc"]
|
11
|
+
s.files = ["README.rdoc",
|
12
|
+
"Rakefile",
|
13
|
+
"caricature.gemspec",
|
14
|
+
"lib/caricature.rb",
|
15
|
+
"lib/caricature/bacon.rb",
|
16
|
+
"lib/caricature/bacon/integration.rb",
|
17
|
+
"lib/caricature/clr.rb",
|
18
|
+
"lib/caricature/clr/aspnet_mvc.rb",
|
19
|
+
"lib/caricature/clr/descriptor.rb",
|
20
|
+
"lib/caricature/clr/event_verification.rb",
|
21
|
+
"lib/caricature/clr/expectation.rb",
|
22
|
+
"lib/caricature/clr/isolation.rb",
|
23
|
+
"lib/caricature/clr/isolator.rb",
|
24
|
+
"lib/caricature/clr/messenger.rb",
|
25
|
+
"lib/caricature/clr/method_call_recorder.rb",
|
26
|
+
"lib/caricature/core_ext.rb",
|
27
|
+
"lib/caricature/core_ext/array.rb",
|
28
|
+
"lib/caricature/core_ext/class.rb",
|
29
|
+
"lib/caricature/core_ext/hash.rb",
|
30
|
+
"lib/caricature/core_ext/module.rb",
|
31
|
+
"lib/caricature/core_ext/object.rb",
|
32
|
+
"lib/caricature/core_ext/string.rb",
|
33
|
+
"lib/caricature/core_ext/system/string.rb",
|
34
|
+
"lib/caricature/core_ext/system/type.rb",
|
35
|
+
"lib/caricature/descriptor.rb",
|
36
|
+
"lib/caricature/expectation.rb",
|
37
|
+
"lib/caricature/isolation.rb",
|
38
|
+
"lib/caricature/isolator.rb",
|
39
|
+
"lib/caricature/messenger.rb",
|
40
|
+
"lib/caricature/method_call_recorder.rb",
|
41
|
+
"lib/caricature/rspec.rb",
|
42
|
+
"lib/caricature/rspec/integration.rb",
|
43
|
+
"lib/caricature/verification.rb",
|
44
|
+
"lib/caricature/version.rb",
|
45
|
+
"spec/bacon/integration/callback_spec.rb",
|
46
|
+
"spec/bacon/integration/clr_to_clr_spec.rb",
|
47
|
+
"spec/bacon/integration/clr_to_ruby_spec.rb",
|
48
|
+
"spec/bacon/integration/event_spec.rb",
|
49
|
+
"spec/bacon/integration/indexer_spec.rb",
|
50
|
+
"spec/bacon/integration/ruby_to_ruby_spec.rb",
|
51
|
+
"spec/bacon/spec_helper.rb",
|
52
|
+
"spec/bacon/unit/core_ext_spec.rb",
|
53
|
+
"spec/bacon/unit/descriptor_spec.rb",
|
54
|
+
"spec/bacon/unit/expectation_spec.rb",
|
55
|
+
"spec/bacon/unit/interop_spec.rb",
|
56
|
+
"spec/bacon/unit/isolation_spec.rb",
|
57
|
+
"spec/bacon/unit/isolator_spec.rb",
|
58
|
+
"spec/bacon/unit/messaging_spec.rb",
|
59
|
+
"spec/bacon/unit/method_call_spec.rb",
|
60
|
+
"spec/bacon/unit/sword_spec.rb",
|
61
|
+
"spec/bacon/unit/verification_spec.rb",
|
62
|
+
"spec/bin/ClrModels.dll",
|
63
|
+
"spec/bin/ClrModels.dll.mdb",
|
64
|
+
"spec/fixtures/ExplodingCar.cs",
|
65
|
+
"spec/fixtures/ExposedChangedSubscriber.cs",
|
66
|
+
"spec/fixtures/ExposingWarrior.cs",
|
67
|
+
"spec/fixtures/IExplodingWarrior.cs",
|
68
|
+
"spec/fixtures/IExposing.cs",
|
69
|
+
"spec/fixtures/IExposingBridge.cs",
|
70
|
+
"spec/fixtures/IExposingWarrior.cs",
|
71
|
+
"spec/fixtures/IHaveAnIndexer.cs",
|
72
|
+
"spec/fixtures/IWarrior.cs",
|
73
|
+
"spec/fixtures/IWeapon.cs",
|
74
|
+
"spec/fixtures/IndexerCaller.cs",
|
75
|
+
"spec/fixtures/IndexerContained.cs",
|
76
|
+
"spec/fixtures/MyClassWithAStatic.cs",
|
77
|
+
"spec/fixtures/Ninja.cs",
|
78
|
+
"spec/fixtures/Samurai.cs",
|
79
|
+
"spec/fixtures/StaticCaller.cs",
|
80
|
+
"spec/fixtures/Sword.cs",
|
81
|
+
"spec/fixtures/SwordWithStatics.cs",
|
82
|
+
"spec/fixtures/clr_interaction.rb",
|
83
|
+
"spec/fixtures/dagger.rb",
|
84
|
+
"spec/fixtures/dagger_with_class_members.rb",
|
85
|
+
"spec/fixtures/sheath.rb",
|
86
|
+
"spec/fixtures/soldier.rb",
|
87
|
+
"spec/fixtures/soldier_with_class_members.rb",
|
88
|
+
"spec/fixtures/swift_cleanup_crew.rb",
|
89
|
+
"spec/fixtures/with_class_methods.rb",
|
90
|
+
"spec/models.notused/ClrModels.cs",
|
91
|
+
"spec/models.notused/ruby_models.rb",
|
92
|
+
"spec/rspec/integration/callback_spec.rb",
|
93
|
+
"spec/rspec/integration/clr_to_clr_spec.rb",
|
94
|
+
"spec/rspec/integration/clr_to_ruby_spec.rb",
|
95
|
+
"spec/rspec/integration/indexer_spec.rb",
|
96
|
+
"spec/rspec/integration/ruby_to_ruby_spec.rb",
|
97
|
+
"spec/rspec/spec_helper.rb",
|
98
|
+
"spec/rspec/unit/core_ext_spec.rb",
|
99
|
+
"spec/rspec/unit/descriptor_spec.rb",
|
100
|
+
"spec/rspec/unit/event_spec.rb",
|
101
|
+
"spec/rspec/unit/expectation_spec.rb",
|
102
|
+
"spec/rspec/unit/interop_spec.rb",
|
103
|
+
"spec/rspec/unit/isolation_spec.rb",
|
104
|
+
"spec/rspec/unit/isolator_spec.rb",
|
105
|
+
"spec/rspec/unit/messaging_spec.rb",
|
106
|
+
"spec/rspec/unit/method_call_spec.rb",
|
107
|
+
"spec/rspec/unit/sword_spec.rb",
|
108
|
+
"spec/rspec/unit/verification_spec.rb",
|
109
|
+
"spec/spec_helper.rb"]
|
110
|
+
s.has_rdoc = true
|
111
|
+
s.homepage = "http://casualjim.github.com/caricature"
|
112
|
+
s.loaded = false
|
113
|
+
s.name = "caricature"
|
114
|
+
s.platform = "ruby"
|
115
|
+
s.rdoc_options = ["--quiet", "--title", "Caricature brings simple mocking to Ruby, DLR and CLR.", "--main", "README.rdoc", "--line-numbers"]
|
116
|
+
s.require_paths = ["lib"]
|
117
|
+
s.required_ruby_version = ">= 1.8.6"
|
118
|
+
s.required_rubygems_version = ">= 0"
|
119
|
+
s.rubyforge_project = "caricature"
|
120
|
+
s.rubygems_version = "1.3.5"
|
121
|
+
s.specification_version = 3
|
122
|
+
s.summary = "Caricature brings simple mocking to Ruby, DLR and CLR."
|
123
|
+
s.version = "0.7.6"
|
111
124
|
end
|
@@ -1,75 +1,75 @@
|
|
1
|
-
class Should
|
2
|
-
|
3
|
-
def have_received?(name, &b)
|
4
|
-
be(name) { |obj, *args| obj.did_receive?(name, &b).successful? }
|
5
|
-
end
|
6
|
-
|
7
|
-
def have_raised_event?(name, &b)
|
8
|
-
be(name) { |obj, *args| obj.did_raise_event?(name, &b).successful? }
|
9
|
-
end if defined?(IRONRUBY_VERSION)
|
10
|
-
|
11
|
-
def satisfy(*args, &block)
|
12
|
-
if args.size == 1 && String === args.first
|
13
|
-
description = args.shift
|
14
|
-
else
|
15
|
-
description = ""
|
16
|
-
end
|
17
|
-
r=nil
|
18
|
-
err = nil
|
19
|
-
begin
|
20
|
-
r = block.call(@object, *args)
|
21
|
-
rescue Caricature::ArgumentMatchError => e
|
22
|
-
err =e
|
23
|
-
end
|
24
|
-
if Bacon::Counter[:depth] > 0
|
25
|
-
Bacon::Counter[:requirements] += 1
|
26
|
-
raise (err.is_a?(Caricature::ArgumentMatchError) ? err : Bacon::Error.new(:failed, description)) unless @negated ^ r
|
27
|
-
r
|
28
|
-
else
|
29
|
-
@negated ? !r : !!r
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
module Caricature
|
36
|
-
|
37
|
-
# Describes a verification of a method call.
|
38
|
-
# This corresponds kind of to an assertion
|
39
|
-
class Verification
|
40
|
-
|
41
|
-
|
42
|
-
# indicate that this method verification is successful
|
43
|
-
def successful?
|
44
|
-
a = any_args? ? [:any] : @args
|
45
|
-
res = @recorder.was_called?(@method_name, @block_args, @mode, *a)
|
46
|
-
raise Caricature::ArgumentMatchError.new(:failed, self.error) unless res
|
47
|
-
res
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
if defined?(IRONRUBY_VERSION)
|
53
|
-
class EventVerification
|
54
|
-
|
55
|
-
# indicate that this event verification is successful
|
56
|
-
def successful?
|
57
|
-
a = any_args? ? [:any] : @args
|
58
|
-
res = @recorder.event_raised?(@event_name, @mode, *a)
|
59
|
-
raise Caricature::ArgumentMatchError.new(:failed, self.error) unless res
|
60
|
-
res
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
# class ClrInterfaceIsolator
|
66
|
-
# def
|
67
|
-
# end
|
68
|
-
end
|
69
|
-
|
70
|
-
class ArgumentMatchError < Bacon::Error;
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
|
1
|
+
class Should
|
2
|
+
|
3
|
+
def have_received?(name, &b)
|
4
|
+
be(name) { |obj, *args| obj.did_receive?(name, &b).successful? }
|
5
|
+
end
|
6
|
+
|
7
|
+
def have_raised_event?(name, &b)
|
8
|
+
be(name) { |obj, *args| obj.did_raise_event?(name, &b).successful? }
|
9
|
+
end if defined?(IRONRUBY_VERSION)
|
10
|
+
|
11
|
+
def satisfy(*args, &block)
|
12
|
+
if args.size == 1 && String === args.first
|
13
|
+
description = args.shift
|
14
|
+
else
|
15
|
+
description = ""
|
16
|
+
end
|
17
|
+
r=nil
|
18
|
+
err = nil
|
19
|
+
begin
|
20
|
+
r = block.call(@object, *args)
|
21
|
+
rescue Caricature::ArgumentMatchError => e
|
22
|
+
err =e
|
23
|
+
end
|
24
|
+
if Bacon::Counter[:depth] > 0
|
25
|
+
Bacon::Counter[:requirements] += 1
|
26
|
+
raise (err.is_a?(Caricature::ArgumentMatchError) ? err : Bacon::Error.new(:failed, description)) unless @negated ^ r
|
27
|
+
r
|
28
|
+
else
|
29
|
+
@negated ? !r : !!r
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
module Caricature
|
36
|
+
|
37
|
+
# Describes a verification of a method call.
|
38
|
+
# This corresponds kind of to an assertion
|
39
|
+
class Verification
|
40
|
+
|
41
|
+
|
42
|
+
# indicate that this method verification is successful
|
43
|
+
def successful?
|
44
|
+
a = any_args? ? [:any] : @args
|
45
|
+
res = @recorder.was_called?(@method_name, @block_args, @mode, *a)
|
46
|
+
raise Caricature::ArgumentMatchError.new(:failed, self.error) unless res
|
47
|
+
res
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
end
|
52
|
+
if defined?(IRONRUBY_VERSION)
|
53
|
+
class EventVerification
|
54
|
+
|
55
|
+
# indicate that this event verification is successful
|
56
|
+
def successful?
|
57
|
+
a = any_args? ? [:any] : @args
|
58
|
+
res = @recorder.event_raised?(@event_name, @mode, *a)
|
59
|
+
raise Caricature::ArgumentMatchError.new(:failed, self.error) unless res
|
60
|
+
res
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
# class ClrInterfaceIsolator
|
66
|
+
# def
|
67
|
+
# end
|
68
|
+
end
|
69
|
+
|
70
|
+
class ArgumentMatchError < Bacon::Error;
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
data/lib/caricature/bacon.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require 'caricature/bacon/integration' if defined? Bacon
|
2
|
-
|
1
|
+
require 'caricature/bacon/integration' if defined? Bacon
|
2
|
+
|