caricature 0.7.5 → 0.7.6
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 +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
@@ -1,98 +1,98 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
-
|
3
|
-
class DoNothingEventArgs < System::EventArgs
|
4
|
-
|
5
|
-
|
6
|
-
end
|
7
|
-
|
8
|
-
shared "an event publisher" do
|
9
|
-
|
10
|
-
it "should not raise an error when subscribing to an event" do
|
11
|
-
lambda { ClrModels::ExposedChangedSubscriber.new(@proxy) }.should.not.raise
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should have 1 event subscription" do
|
15
|
-
@proxy.isolation_context.events.size.should == 1
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should raise an event when no block is given" do
|
19
|
-
@proxy.when_receiving(:explode).return(nil).raise_event(:on_is_exposed_changed)
|
20
|
-
@proxy.explode
|
21
|
-
@subscriber.counter.should == 1
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should raise an event with the provided parameters" do
|
25
|
-
sender = { :the => "sender" }
|
26
|
-
ags = DoNothingEventArgs.new
|
27
|
-
@proxy.when_receiving(:explode).return(nil).raise_event(:on_is_exposed_changed, sender, ags)
|
28
|
-
@proxy.explode
|
29
|
-
@subscriber.sender.should == sender
|
30
|
-
@subscriber.args.should == ags
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should allow overriding the default event handler" do
|
34
|
-
sender = { :the => "sender" }
|
35
|
-
ags = DoNothingEventArgs.new
|
36
|
-
cnt, rsen, rar = 0, nil, nil
|
37
|
-
handler = lambda { |sen, ar| cnt +=1; rsen = sen; rar=ar }
|
38
|
-
@proxy.when_receiving(:explode).return(nil).raise_event(:on_is_exposed_changed, sender, ags, &handler)
|
39
|
-
@proxy.explode
|
40
|
-
rsen.should == sender
|
41
|
-
rar.should == ags
|
42
|
-
cnt.should == 1
|
43
|
-
@subscriber.counter.should == 0
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
it "should allow adding a block to the default event handler" do
|
48
|
-
sender = { :the => "sender" }
|
49
|
-
ags = DoNothingEventArgs.new
|
50
|
-
cnt = 0
|
51
|
-
handler = lambda { |sen, ar| cnt +=1 }
|
52
|
-
@proxy.when_receiving(:explode).return(nil).raise_event(:on_is_exposed_changed, sender, ags, &handler).raise_subscriptions
|
53
|
-
@proxy.explode
|
54
|
-
cnt.should == 1
|
55
|
-
@subscriber.counter.should == 1
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should verify if an event was raised" do
|
59
|
-
@proxy.when_receiving(:explode).return(nil).raise_event(:on_is_exposed_changed)
|
60
|
-
@proxy.explode
|
61
|
-
@proxy.should.have_raised_event?(:on_is_exposed_changed)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should verify if an event was raised with specific parameters" do
|
65
|
-
sender = { :the => "sender" }
|
66
|
-
ags = DoNothingEventArgs.new
|
67
|
-
@proxy.when_receiving(:explode).return(nil).raise_event(:on_is_exposed_changed, sender, ags)
|
68
|
-
@proxy.explode
|
69
|
-
@proxy.should.have_raised_event?(:on_is_exposed_changed) { |ev| ev.with(sender, ags)}
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "CLR event handling" do
|
75
|
-
|
76
|
-
describe "for CLR interfaces" do
|
77
|
-
|
78
|
-
before do
|
79
|
-
@proxy = isolate ClrModels::IExplodingWarrior
|
80
|
-
@subscriber = ClrModels::ExposedChangedSubscriber.new(@proxy)
|
81
|
-
end
|
82
|
-
|
83
|
-
behaves_like "an event publisher"
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
describe "for CLR classes" do
|
88
|
-
|
89
|
-
before do
|
90
|
-
@proxy = isolate ClrModels::ExposingWarrior
|
91
|
-
@subscriber = ClrModels::ExposedChangedSubscriber.new(@proxy)
|
92
|
-
end
|
93
|
-
|
94
|
-
behaves_like "an event publisher"
|
95
|
-
|
96
|
-
end
|
97
|
-
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
class DoNothingEventArgs < System::EventArgs
|
4
|
+
|
5
|
+
|
6
|
+
end
|
7
|
+
|
8
|
+
shared "an event publisher" do
|
9
|
+
|
10
|
+
it "should not raise an error when subscribing to an event" do
|
11
|
+
lambda { ClrModels::ExposedChangedSubscriber.new(@proxy) }.should.not.raise
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have 1 event subscription" do
|
15
|
+
@proxy.isolation_context.events.size.should == 1
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should raise an event when no block is given" do
|
19
|
+
@proxy.when_receiving(:explode).return(nil).raise_event(:on_is_exposed_changed)
|
20
|
+
@proxy.explode
|
21
|
+
@subscriber.counter.should == 1
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should raise an event with the provided parameters" do
|
25
|
+
sender = { :the => "sender" }
|
26
|
+
ags = DoNothingEventArgs.new
|
27
|
+
@proxy.when_receiving(:explode).return(nil).raise_event(:on_is_exposed_changed, sender, ags)
|
28
|
+
@proxy.explode
|
29
|
+
@subscriber.sender.should == sender
|
30
|
+
@subscriber.args.should == ags
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should allow overriding the default event handler" do
|
34
|
+
sender = { :the => "sender" }
|
35
|
+
ags = DoNothingEventArgs.new
|
36
|
+
cnt, rsen, rar = 0, nil, nil
|
37
|
+
handler = lambda { |sen, ar| cnt +=1; rsen = sen; rar=ar }
|
38
|
+
@proxy.when_receiving(:explode).return(nil).raise_event(:on_is_exposed_changed, sender, ags, &handler)
|
39
|
+
@proxy.explode
|
40
|
+
rsen.should == sender
|
41
|
+
rar.should == ags
|
42
|
+
cnt.should == 1
|
43
|
+
@subscriber.counter.should == 0
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
it "should allow adding a block to the default event handler" do
|
48
|
+
sender = { :the => "sender" }
|
49
|
+
ags = DoNothingEventArgs.new
|
50
|
+
cnt = 0
|
51
|
+
handler = lambda { |sen, ar| cnt +=1 }
|
52
|
+
@proxy.when_receiving(:explode).return(nil).raise_event(:on_is_exposed_changed, sender, ags, &handler).raise_subscriptions
|
53
|
+
@proxy.explode
|
54
|
+
cnt.should == 1
|
55
|
+
@subscriber.counter.should == 1
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should verify if an event was raised" do
|
59
|
+
@proxy.when_receiving(:explode).return(nil).raise_event(:on_is_exposed_changed)
|
60
|
+
@proxy.explode
|
61
|
+
@proxy.should.have_raised_event?(:on_is_exposed_changed)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should verify if an event was raised with specific parameters" do
|
65
|
+
sender = { :the => "sender" }
|
66
|
+
ags = DoNothingEventArgs.new
|
67
|
+
@proxy.when_receiving(:explode).return(nil).raise_event(:on_is_exposed_changed, sender, ags)
|
68
|
+
@proxy.explode
|
69
|
+
@proxy.should.have_raised_event?(:on_is_exposed_changed) { |ev| ev.with(sender, ags)}
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "CLR event handling" do
|
75
|
+
|
76
|
+
describe "for CLR interfaces" do
|
77
|
+
|
78
|
+
before do
|
79
|
+
@proxy = isolate ClrModels::IExplodingWarrior
|
80
|
+
@subscriber = ClrModels::ExposedChangedSubscriber.new(@proxy)
|
81
|
+
end
|
82
|
+
|
83
|
+
behaves_like "an event publisher"
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "for CLR classes" do
|
88
|
+
|
89
|
+
before do
|
90
|
+
@proxy = isolate ClrModels::ExposingWarrior
|
91
|
+
@subscriber = ClrModels::ExposedChangedSubscriber.new(@proxy)
|
92
|
+
end
|
93
|
+
|
94
|
+
behaves_like "an event publisher"
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
98
|
end
|
@@ -1,28 +1,28 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
-
|
3
|
-
describe "CLR to CLR interactions" do
|
4
|
-
|
5
|
-
describe "when isolating CLR classes" do
|
6
|
-
|
7
|
-
describe "that have an indexer" do
|
8
|
-
before do
|
9
|
-
@cons = ClrModels::IndexerCaller.new
|
10
|
-
@ind = Caricature::Isolation.for(ClrModels::IndexerContained)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should work without expectations" do
|
14
|
-
@cons.call_index_on_class(@ind, "key1").should.be.nil
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should work with an expectation" do
|
18
|
-
@ind.when_receiving(:get_Item).return("5")
|
19
|
-
|
20
|
-
@cons.call_index_on_class(@ind, "key1").should.equal "5"
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
describe "CLR to CLR interactions" do
|
4
|
+
|
5
|
+
describe "when isolating CLR classes" do
|
6
|
+
|
7
|
+
describe "that have an indexer" do
|
8
|
+
before do
|
9
|
+
@cons = ClrModels::IndexerCaller.new
|
10
|
+
@ind = Caricature::Isolation.for(ClrModels::IndexerContained)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should work without expectations" do
|
14
|
+
@cons.call_index_on_class(@ind, "key1").should.be.nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should work with an expectation" do
|
18
|
+
@ind.when_receiving(:get_Item).return("5")
|
19
|
+
|
20
|
+
@cons.call_index_on_class(@ind, "key1").should.equal "5"
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
28
|
end
|
data/spec/bacon/spec_helper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
# load the bacon library
|
3
|
-
require 'bacon' unless defined? Bacon
|
4
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
# load the bacon library
|
3
|
+
require 'bacon' unless defined? Bacon
|
4
|
+
|
5
5
|
require File.dirname(__FILE__) + "/../spec_helper"
|