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.
Files changed (52) hide show
  1. data/README.rdoc +97 -97
  2. data/Rakefile +310 -310
  3. data/caricature.gemspec +110 -106
  4. data/lib/caricature.rb +3 -1
  5. data/lib/caricature/bacon.rb +2 -2
  6. data/lib/caricature/bacon/integration.rb +75 -55
  7. data/lib/caricature/clr.rb +4 -3
  8. data/lib/caricature/clr/aspnet_mvc.rb +3 -3
  9. data/lib/caricature/clr/descriptor.rb +106 -39
  10. data/lib/caricature/clr/event_verification.rb +57 -0
  11. data/lib/caricature/clr/expectation.rb +101 -0
  12. data/lib/caricature/clr/isolation.rb +49 -13
  13. data/lib/caricature/clr/isolator.rb +141 -5
  14. data/lib/caricature/clr/messenger.rb +6 -0
  15. data/lib/caricature/clr/method_call_recorder.rb +97 -0
  16. data/lib/caricature/core_ext.rb +11 -0
  17. data/lib/{core_ext → caricature/core_ext}/array.rb +0 -0
  18. data/lib/{core_ext → caricature/core_ext}/class.rb +0 -0
  19. data/lib/{core_ext → caricature/core_ext}/hash.rb +0 -0
  20. data/lib/{core_ext → caricature/core_ext}/module.rb +0 -0
  21. data/lib/{core_ext → caricature/core_ext}/object.rb +0 -0
  22. data/lib/{core_ext → caricature/core_ext}/string.rb +0 -0
  23. data/lib/{core_ext → caricature/core_ext}/system/string.rb +0 -0
  24. data/lib/{core_ext → caricature/core_ext}/system/type.rb +6 -0
  25. data/lib/caricature/expectation.rb +108 -66
  26. data/lib/caricature/isolator.rb +3 -3
  27. data/lib/caricature/method_call_recorder.rb +32 -4
  28. data/lib/caricature/rspec/integration.rb +118 -77
  29. data/lib/caricature/version.rb +5 -5
  30. data/spec/bacon/integration/callback_spec.rb +156 -156
  31. data/spec/bacon/integration/clr_to_clr_spec.rb +1 -2
  32. data/spec/bacon/integration/event_spec.rb +98 -0
  33. data/spec/bacon/integration/indexer_spec.rb +1 -1
  34. data/spec/bacon/spec_helper.rb +4 -4
  35. data/spec/bacon/unit/descriptor_spec.rb +95 -42
  36. data/spec/bacon/unit/expectation_spec.rb +2 -2
  37. data/spec/bacon/unit/interop_spec.rb +1 -14
  38. data/spec/bacon/unit/isolation_spec.rb +1 -1
  39. data/spec/bacon/unit/isolator_spec.rb +5 -5
  40. data/spec/bin/ClrModels.dll +0 -0
  41. data/spec/models/ClrModels.cs +32 -8
  42. data/spec/models/ruby_models.rb +150 -150
  43. data/spec/rspec/integration/callback_spec.rb +156 -156
  44. data/spec/rspec/integration/indexer_spec.rb +1 -1
  45. data/spec/rspec/spec_helper.rb +12 -6
  46. data/spec/rspec/unit/descriptor_spec.rb +93 -42
  47. data/spec/rspec/unit/event_spec.rb +17 -0
  48. data/spec/rspec/unit/interop_spec.rb +0 -13
  49. data/spec/spec_helper.rb +14 -14
  50. metadata +20 -22
  51. data/lib/core_ext/core_ext.rb +0 -8
  52. data/spec/bin/ClrModels.dll.mdb +0 -0
@@ -15,7 +15,7 @@ describe "CLR to CLR interactions" do
15
15
  end
16
16
 
17
17
  it "should work with an expectation" do
18
- @ind.when_receiving(:__getitem__).return("5")
18
+ @ind.when_receiving(:Item).return("5")
19
19
 
20
20
  @cons.call_index_on_class(@ind, "key1").should == "5"
21
21
  end
@@ -1,6 +1,12 @@
1
-
2
- require 'rubygems'
3
- # load the rspec library
4
- require 'spec' unless defined? Spec
5
-
6
- require File.dirname(__FILE__) + "/../spec_helper"
1
+
2
+ require 'rubygems'
3
+ # load the rspec library
4
+ require 'spec' unless defined? Spec
5
+
6
+ require File.dirname(__FILE__) + "/../spec_helper"
7
+
8
+
9
+ Spec::Runner.configure do |config|
10
+ config.mock_with Caricature::RSpecAdapter
11
+ config.include Caricature::RSpecMatchers
12
+ end
@@ -66,71 +66,122 @@ describe "Caricature::MemberDescriptor" do
66
66
 
67
67
  end
68
68
 
69
- describe "Caricature::ClrInterfaceDescriptor" do
69
+ describe Caricature::ClrEventDescriptor do
70
70
 
71
- before do
72
- @des = Caricature::ClrInterfaceDescriptor.new ClrModels::IWeapon
71
+ it "should have an event name" do
72
+ des = Caricature::ClrEventDescriptor.new "EventName"
73
+ des.event_name.should == "EventName"
73
74
  end
74
75
 
75
- it "should have 2 instance members" do
76
- @des.instance_members.size.should == 2
76
+ it "should correctly identify when it's not an instance member" do
77
+ des = Caricature::ClrEventDescriptor.new "EventName", false
78
+ des.should_not be_instance_member
77
79
  end
78
80
 
79
- it "should contain only instance members" do
80
- result = true
81
- @des.instance_members.each do |mem|
82
- result = false unless mem.instance_member?
81
+ end
82
+
83
+ describe Caricature::ClrInterfaceDescriptor do
84
+
85
+ context "when collecting methods" do
86
+ before do
87
+ @des = Caricature::ClrInterfaceDescriptor.new ClrModels::IWeapon
83
88
  end
84
89
 
85
- result.should be_true
86
- end
90
+ it "should have 2 instance members" do
91
+ @des.instance_members.size.should == 2
92
+ end
87
93
 
88
- it "should have a damage instance member" do
89
- @des.instance_members.select { |mem| mem.name == "damage" }.should_not be_empty
90
- end
94
+ it "should contain only instance members" do
95
+ result = true
96
+ @des.instance_members.each do |mem|
97
+ result = false unless mem.instance_member?
98
+ end
99
+
100
+ result.should be_true
101
+ end
102
+
103
+ it "should have a damage instance member" do
104
+ @des.instance_members.select { |mem| mem.name == "damage" }.should_not be_empty
105
+ end
91
106
 
92
- it "should correctly identify indexers" do
93
- des = Caricature::ClrInterfaceDescriptor.new ClrModels::IHaveAnIndexer
94
- des.instance_members.select { |mem| mem.name == "__getitem__" }.should_not be_empty
107
+ it "should correctly identify indexers" do
108
+ des = Caricature::ClrInterfaceDescriptor.new ClrModels::IHaveAnIndexer
109
+ des.instance_members.select { |mem| mem.name == "get_Item" }.should_not be_empty
110
+ end
111
+
112
+ it "should correctly identify indexers" do
113
+ des = Caricature::ClrInterfaceDescriptor.new ClrModels::IHaveAnIndexer
114
+ des.instance_members.select { |mem| mem.name == "set_Item" }.should_not be_empty
115
+ end
95
116
  end
96
117
 
97
- it "should correctly identify indexers" do
98
- des = Caricature::ClrInterfaceDescriptor.new ClrModels::IHaveAnIndexer
99
- des.instance_members.select { |mem| mem.name == "__setitem__" }.should_not be_empty
118
+ context "when collecting events" do
119
+
120
+ before do
121
+ @des = Caricature::ClrInterfaceDescriptor.new ClrModels::IExplodingWarrior
122
+ end
123
+
124
+ it "should have collected 2 events" do
125
+ @des.events.size.should == 2
126
+ end
127
+
128
+ it "should have collected 2 instance events" do
129
+ @des.events.all? { |ev| ev.instance_member? }.should be_true
130
+ end
131
+
100
132
  end
101
-
133
+
102
134
  end
103
135
 
104
136
  describe "Caricature::ClrClassDescriptor" do
105
137
 
106
- before do
107
- @des = Caricature::ClrClassDescriptor.new ClrModels::SwordWithStatics
108
- end
138
+ context "when collecting methods" do
109
139
 
110
- it "should have 11 instance members" do
111
- @des.instance_members.size.should == 11
112
- end
140
+ before do
141
+ @des = Caricature::ClrClassDescriptor.new ClrModels::SwordWithStatics
142
+ end
113
143
 
114
- it "should have 5 static members" do
115
- @des.class_members.size.should == 5
116
- end
144
+ it "should have 11 instance members" do
145
+ @des.instance_members.size.should == 11
146
+ end
117
147
 
118
- it "should have a damage instance member" do
119
- @des.instance_members.select { |mem| mem.name == "damage" }.should_not be_empty
120
- end
148
+ it "should have 5 static members" do
149
+ @des.class_members.size.should == 5
150
+ end
121
151
 
122
- it "should have a another method instance member" do
123
- @des.instance_members.select { |mem| mem.name == "another_method" }.should_not be_empty
124
- end
152
+ it "should have a damage instance member" do
153
+ @des.instance_members.select { |mem| mem.name == "damage" }.should_not be_empty
154
+ end
125
155
 
126
- it "should correctly identify indexers" do
127
- des = Caricature::ClrClassDescriptor.new ClrModels::IndexerContained
128
- des.instance_members.select { |mem| mem.name == "__getitem__" }.should_not be_empty
156
+ it "should have a another method instance member" do
157
+ @des.instance_members.select { |mem| mem.name == "another_method" }.should_not be_empty
158
+ end
159
+
160
+ it "should correctly identify indexers" do
161
+ des = Caricature::ClrClassDescriptor.new ClrModels::IndexerContained
162
+ des.instance_members.select { |mem| mem.name == "get_Item" }.should_not be_empty
163
+ end
164
+
165
+ it "should correctly identify indexers" do
166
+ des = Caricature::ClrClassDescriptor.new ClrModels::IndexerContained
167
+ des.instance_members.select { |mem| mem.name == "set_Item" }.should_not be_empty
168
+ end
129
169
  end
130
170
 
131
- it "should correctly identify indexers" do
132
- des = Caricature::ClrClassDescriptor.new ClrModels::IndexerContained
133
- des.instance_members.select { |mem| mem.name == "__setitem__" }.should_not be_empty
171
+ context "when collecting events" do
172
+
173
+ before do
174
+ @des = Caricature::ClrClassDescriptor.new ClrModels::ExposingWarrior
175
+ end
176
+
177
+ it "should have 2 instance events" do
178
+ @des.events.size.should == 2
179
+ end
180
+
181
+ it "should should have 1 class event" do
182
+ @des.class_events.size.should == 1
183
+ end
184
+
134
185
  end
135
186
 
136
187
  end
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ describe "CLR event handling" do
4
+
5
+ context "for CLR interfaces" do
6
+
7
+ before do
8
+ @proxy = isolate ClrModels::IExplodingWarrior
9
+ end
10
+
11
+ it "should not raise an error when subcribing to an event" do
12
+ lambda { ClrModels::ExposedChangedSubscriber.new(@proxy) }.should_not raise_error
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -27,17 +27,4 @@ describe "Event handling" do
27
27
 
28
28
  end
29
29
 
30
- describe "for an IR generated interface proxy" do
31
-
32
- before do
33
- @proxy = isolate ClrModels::IExposingWarrior
34
- end
35
-
36
- # apparently events don't work yet in IronRuby.. keeping this spec here to find out when it does
37
- # it "should not raise an error when subcribing to an event" do
38
- # lambda { ClrModels::ExposedChangedSubscriber.new(@proxy) }.should_not raise_error
39
- # end
40
-
41
- end
42
-
43
30
  end
@@ -1,15 +1,15 @@
1
- # add some search paths to ironruby
2
- # this first one adds the path with the assemblies
3
- # this enables us not to have to specify a path to the assemblies everywhere.
4
- $: << File.dirname(__FILE__) + "/bin"
5
- # adds the path to the caricature library.
6
- $: << File.dirname(__FILE__) + "/../lib"
7
-
8
- # load the caricature library
9
- require "caricature"
10
-
11
- # load the assembly with the C# code
12
- require 'ClrModels.dll' if defined? IRONRUBY_VERSION
13
-
14
- # Load the ruby models
1
+ # add some search paths to ironruby
2
+ # this first one adds the path with the assemblies
3
+ # this enables us not to have to specify a path to the assemblies everywhere.
4
+ $: << File.dirname(__FILE__) + "/bin"
5
+ # adds the path to the caricature library.
6
+ $: << File.dirname(__FILE__) + "/../lib"
7
+
8
+ # load the caricature library
9
+ require "caricature"
10
+
11
+ # load the assembly with the C# code
12
+ require 'ClrModels.dll' if defined? IRONRUBY_VERSION
13
+
14
+ # Load the ruby models
15
15
  require File.dirname(__FILE__) + "/models/ruby_models"
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caricature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Porto Carrero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2009-10-01 00:00:00 +02:00
11
+ date: 2010-01-03 00:00:00 +01:00
13
12
  default_executable:
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
@@ -18,16 +17,14 @@ dependencies:
18
17
  version_requirement:
19
18
  version_requirements: !ruby/object:Gem::Requirement
20
19
  requirements:
21
- - - ">="
20
+ - - '>='
22
21
  - !ruby/object:Gem::Version
23
22
  version: 2.0.0
24
23
  version:
25
24
  description: Caricature brings simple mocking to Ruby, DLR and CLR.
26
25
  email: ivan@flanders.co.nz
27
26
  executables: []
28
-
29
27
  extensions: []
30
-
31
28
  extra_rdoc_files:
32
29
  - README.rdoc
33
30
  files:
@@ -40,9 +37,21 @@ files:
40
37
  - lib/caricature/clr.rb
41
38
  - lib/caricature/clr/aspnet_mvc.rb
42
39
  - lib/caricature/clr/descriptor.rb
40
+ - lib/caricature/clr/event_verification.rb
41
+ - lib/caricature/clr/expectation.rb
43
42
  - lib/caricature/clr/isolation.rb
44
43
  - lib/caricature/clr/isolator.rb
45
44
  - lib/caricature/clr/messenger.rb
45
+ - lib/caricature/clr/method_call_recorder.rb
46
+ - lib/caricature/core_ext.rb
47
+ - lib/caricature/core_ext/array.rb
48
+ - lib/caricature/core_ext/class.rb
49
+ - lib/caricature/core_ext/hash.rb
50
+ - lib/caricature/core_ext/module.rb
51
+ - lib/caricature/core_ext/object.rb
52
+ - lib/caricature/core_ext/string.rb
53
+ - lib/caricature/core_ext/system/string.rb
54
+ - lib/caricature/core_ext/system/type.rb
46
55
  - lib/caricature/descriptor.rb
47
56
  - lib/caricature/expectation.rb
48
57
  - lib/caricature/isolation.rb
@@ -53,18 +62,10 @@ files:
53
62
  - lib/caricature/rspec/integration.rb
54
63
  - lib/caricature/verification.rb
55
64
  - lib/caricature/version.rb
56
- - lib/core_ext/array.rb
57
- - lib/core_ext/class.rb
58
- - lib/core_ext/core_ext.rb
59
- - lib/core_ext/hash.rb
60
- - lib/core_ext/module.rb
61
- - lib/core_ext/object.rb
62
- - lib/core_ext/string.rb
63
- - lib/core_ext/system/string.rb
64
- - lib/core_ext/system/type.rb
65
65
  - spec/bacon/integration/callback_spec.rb
66
66
  - spec/bacon/integration/clr_to_clr_spec.rb
67
67
  - spec/bacon/integration/clr_to_ruby_spec.rb
68
+ - spec/bacon/integration/event_spec.rb
68
69
  - spec/bacon/integration/indexer_spec.rb
69
70
  - spec/bacon/integration/ruby_to_ruby_spec.rb
70
71
  - spec/bacon/spec_helper.rb
@@ -79,7 +80,6 @@ files:
79
80
  - spec/bacon/unit/sword_spec.rb
80
81
  - spec/bacon/unit/verification_spec.rb
81
82
  - spec/bin/ClrModels.dll
82
- - spec/bin/ClrModels.dll.mdb
83
83
  - spec/models/ClrModels.cs
84
84
  - spec/models/ruby_models.rb
85
85
  - spec/rspec/integration/callback_spec.rb
@@ -90,6 +90,7 @@ files:
90
90
  - spec/rspec/spec_helper.rb
91
91
  - spec/rspec/unit/core_ext_spec.rb
92
92
  - spec/rspec/unit/descriptor_spec.rb
93
+ - spec/rspec/unit/event_spec.rb
93
94
  - spec/rspec/unit/expectation_spec.rb
94
95
  - spec/rspec/unit/interop_spec.rb
95
96
  - spec/rspec/unit/isolation_spec.rb
@@ -102,7 +103,6 @@ files:
102
103
  has_rdoc: true
103
104
  homepage: http://casualjim.github.com/caricature
104
105
  licenses: []
105
-
106
106
  post_install_message:
107
107
  rdoc_options:
108
108
  - --quiet
@@ -117,22 +117,20 @@ require_paths:
117
117
  - lib
118
118
  required_ruby_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - ">="
120
+ - - '>='
121
121
  - !ruby/object:Gem::Version
122
122
  version: 1.8.4
123
123
  version:
124
124
  required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - ">="
126
+ - - '>='
127
127
  - !ruby/object:Gem::Version
128
- version: "0"
128
+ version: !str 0
129
129
  version:
130
130
  requirements: []
131
-
132
131
  rubyforge_project: caricature
133
132
  rubygems_version: 1.3.5
134
133
  signing_key:
135
134
  specification_version: 3
136
135
  summary: Caricature brings simple mocking to Ruby, DLR and CLR.
137
136
  test_files: []
138
-
@@ -1,8 +0,0 @@
1
- require File.dirname(__FILE__) + '/string'
2
- require File.dirname(__FILE__) + '/system/string'
3
- require File.dirname(__FILE__) + '/system/type'
4
- require File.dirname(__FILE__) + '/class'
5
- require File.dirname(__FILE__) + '/module'
6
- require File.dirname(__FILE__) + '/object'
7
- require File.dirname(__FILE__) + '/array'
8
- require File.dirname(__FILE__) + '/hash'
Binary file