caricature 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/README.rdoc +97 -97
  2. data/Rakefile +309 -310
  3. data/caricature.gemspec +123 -110
  4. data/lib/caricature/bacon/integration.rb +75 -75
  5. data/lib/caricature/bacon.rb +2 -2
  6. data/lib/caricature/clr/descriptor.rb +159 -159
  7. data/lib/caricature/clr/event_verification.rb +56 -56
  8. data/lib/caricature/clr/expectation.rb +100 -100
  9. data/lib/caricature/clr/isolation.rb +78 -78
  10. data/lib/caricature/clr/isolator.rb +252 -252
  11. data/lib/caricature/clr/messenger.rb +51 -49
  12. data/lib/caricature/clr/method_call_recorder.rb +96 -96
  13. data/lib/caricature/expectation.rb +1 -1
  14. data/lib/caricature/method_call_recorder.rb +3 -3
  15. data/lib/caricature/rspec/integration.rb +118 -118
  16. data/lib/caricature/version.rb +5 -5
  17. data/lib/caricature.rb +25 -25
  18. data/spec/bacon/integration/callback_spec.rb +156 -156
  19. data/spec/bacon/integration/clr_to_clr_spec.rb +325 -253
  20. data/spec/bacon/integration/event_spec.rb +97 -97
  21. data/spec/bacon/integration/indexer_spec.rb +27 -27
  22. data/spec/bacon/spec_helper.rb +4 -4
  23. data/spec/bacon/unit/descriptor_spec.rb +212 -212
  24. data/spec/bacon/unit/sword_spec.rb +39 -39
  25. data/spec/bacon/unit/verification_spec.rb +103 -103
  26. data/spec/bin/ClrModels.dll +0 -0
  27. data/spec/bin/ClrModels.dll.mdb +0 -0
  28. data/spec/fixtures/ExplodingCar.cs +56 -0
  29. data/spec/fixtures/ExposedChangedSubscriber.cs +26 -0
  30. data/spec/fixtures/ExposingWarrior.cs +58 -0
  31. data/spec/fixtures/IExplodingWarrior.cs +10 -0
  32. data/spec/fixtures/IExposing.cs +9 -0
  33. data/spec/fixtures/IExposingBridge.cs +9 -0
  34. data/spec/fixtures/IExposingWarrior.cs +8 -0
  35. data/spec/fixtures/IHaveAnIndexer.cs +8 -0
  36. data/spec/fixtures/IWarrior.cs +13 -0
  37. data/spec/fixtures/IWeapon.cs +9 -0
  38. data/spec/fixtures/IndexerCaller.cs +17 -0
  39. data/spec/fixtures/IndexerContained.cs +20 -0
  40. data/spec/fixtures/MyClassWithAStatic.cs +16 -0
  41. data/spec/fixtures/Ninja.cs +34 -0
  42. data/spec/fixtures/Samurai.cs +29 -0
  43. data/spec/fixtures/StaticCaller.cs +12 -0
  44. data/spec/fixtures/Sword.cs +16 -0
  45. data/spec/fixtures/SwordWithStatics.cs +19 -0
  46. data/spec/fixtures/clr_interaction.rb +61 -0
  47. data/spec/fixtures/dagger.rb +11 -0
  48. data/spec/fixtures/dagger_with_class_members.rb +11 -0
  49. data/spec/fixtures/sheath.rb +19 -0
  50. data/spec/fixtures/soldier.rb +29 -0
  51. data/spec/fixtures/soldier_with_class_members.rb +7 -0
  52. data/spec/fixtures/swift_cleanup_crew.rb +21 -0
  53. data/spec/fixtures/with_class_methods.rb +11 -0
  54. data/spec/{models → models.notused}/ClrModels.cs +241 -241
  55. data/spec/{models → models.notused}/ruby_models.rb +150 -150
  56. data/spec/rspec/integration/callback_spec.rb +156 -156
  57. data/spec/rspec/integration/clr_to_clr_spec.rb +254 -254
  58. data/spec/rspec/integration/clr_to_ruby_spec.rb +227 -227
  59. data/spec/rspec/integration/indexer_spec.rb +27 -27
  60. data/spec/rspec/integration/ruby_to_ruby_spec.rb +271 -271
  61. data/spec/rspec/spec_helper.rb +12 -12
  62. data/spec/rspec/unit/core_ext_spec.rb +87 -87
  63. data/spec/rspec/unit/descriptor_spec.rb +210 -210
  64. data/spec/rspec/unit/event_spec.rb +16 -16
  65. data/spec/rspec/unit/expectation_spec.rb +300 -300
  66. data/spec/rspec/unit/interop_spec.rb +29 -29
  67. data/spec/rspec/unit/isolation_spec.rb +86 -86
  68. data/spec/rspec/unit/isolator_spec.rb +219 -219
  69. data/spec/rspec/unit/messaging_spec.rb +310 -310
  70. data/spec/rspec/unit/method_call_spec.rb +342 -342
  71. data/spec/rspec/unit/sword_spec.rb +39 -39
  72. data/spec/rspec/unit/verification_spec.rb +103 -103
  73. data/spec/spec_helper.rb +16 -15
  74. metadata +42 -11
data/README.rdoc CHANGED
@@ -1,98 +1,98 @@
1
- = Caricature - Bringing simple mocking to the DLR
2
-
3
- * http://github.com/casualjim/caricature
4
-
5
- == DESCRIPTION:
6
-
7
- This project aims to make interop between IronRuby objects and .NET objects easier.
8
- The idea is that it integrates nicely with bacon and later rspec and that it transparently lets you mock ironruby ojbects
9
- as well as CLR objects/interfaces.
10
- Caricature handles interfaces, interface inheritance, CLR objects, CLR object instances, Ruby classes and instances of Ruby classes.
11
-
12
- From the start I wanted to do away with names like mock, stub, record, replay, verify etc.
13
- Instead I took the advice from Roy Osherhove and went with a name of Isolation for creating a mock.
14
-
15
- An Isolation will create what in Rhino.Mocks would be called a DynamicMock (but can be a partial too) :)
16
- In Moq it would be the Loose mocking strategy.
17
-
18
- The naming of the methods for creating mocks is the one that JP Boodhoo proposed WhenToldTo and WasToldTo.
19
- To specify a stub/expectation on an isolation you have one and only one way of doing that with the method called when_receiving.
20
- Then only if you're interested in asserting if a method has been called you can use the did_receive? method for this.
21
-
22
- It may be very important to note that when you're going to be isolating CLR classes to be used in other CLR classes
23
- you still need to obide by the CLR rules. That means if you want to redefine a method you'll need to make sure it's
24
- marked as virtual. Static types are still governed by static type rules. I'm working on a solution around those
25
- problems but for the time being this is how it has to be.
26
-
27
- == FEATURES/PROBLEMS:
28
-
29
- * [CLR-to-CLR mocking]: Caricature won't mock static methods because you can't override those according to CLR rules
30
- * [CLR-to-CLR mocking]: Caricature can only override methods that are marked virtual (CLR rules)
31
-
32
- == SYNOPSIS:
33
-
34
- isolation = Isolation.for(Ninja)
35
- isolation.when_receiving(:attack) do |exp|
36
- exp.with(:shuriken)
37
- exp.return(3)
38
- end
39
-
40
- Battle.new(mock)
41
- battle.combat
42
-
43
- isolation.should.have_received?(:attack)
44
-
45
-
46
- == REQUIREMENTS:
47
-
48
- * To use the caricature library you need to have uuidtools installed
49
- (sudo) gem install uuidtools
50
- (sudo) igem install uuidtools
51
-
52
- == INSTALL:
53
-
54
- (sudo) gem install caricature
55
-
56
- == LICENSE:
57
-
58
- Caricature -- A simple mocking framework for IronRuby
59
-
60
- Copyright (c) 2009, Caricature Team
61
- http://github.com/casualjim/caricature
62
- All rights reserved.
63
-
64
- Redistribution and use in source and binary forms,
65
- with or without modification, are permitted provided
66
- that the following conditions are met:
67
-
68
- * Redistributions of source code must retain the
69
- above copyright notice, this list of conditions and
70
- the following disclaimer.
71
-
72
- * Redistributions in binary form must reproduce
73
- the above copyright notice, this list of conditions
74
- and the following disclaimer in the documentation
75
- and/or other materials provided with the distribution.
76
-
77
- * Neither the name of the Caricature Team nor the
78
- names of its contributors may be used to endorse
79
- or promote products derived from this software
80
- without specific prior written permission.
81
-
82
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
83
- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
84
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
85
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
86
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
87
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
88
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
89
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
90
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
91
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
92
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
93
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
94
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
95
- SUCH DAMAGE.
96
-
97
- [This is the BSD license, see
1
+ = Caricature - Bringing simple mocking to the DLR
2
+
3
+ * http://github.com/casualjim/caricature
4
+
5
+ == DESCRIPTION:
6
+
7
+ This project aims to make interop between IronRuby objects and .NET objects easier.
8
+ The idea is that it integrates nicely with bacon and later rspec and that it transparently lets you mock ironruby ojbects
9
+ as well as CLR objects/interfaces.
10
+ Caricature handles interfaces, interface inheritance, CLR objects, CLR object instances, Ruby classes and instances of Ruby classes.
11
+
12
+ From the start I wanted to do away with names like mock, stub, record, replay, verify etc.
13
+ Instead I took the advice from Roy Osherhove and went with a name of Isolation for creating a mock.
14
+
15
+ An Isolation will create what in Rhino.Mocks would be called a DynamicMock (but can be a partial too) :)
16
+ In Moq it would be the Loose mocking strategy.
17
+
18
+ The naming of the methods for creating mocks is the one that JP Boodhoo proposed WhenToldTo and WasToldTo.
19
+ To specify a stub/expectation on an isolation you have one and only one way of doing that with the method called when_receiving.
20
+ Then only if you're interested in asserting if a method has been called you can use the did_receive? method for this.
21
+
22
+ It may be very important to note that when you're going to be isolating CLR classes to be used in other CLR classes
23
+ you still need to obide by the CLR rules. That means if you want to redefine a method you'll need to make sure it's
24
+ marked as virtual. Static types are still governed by static type rules. I'm working on a solution around those
25
+ problems but for the time being this is how it has to be.
26
+
27
+ == FEATURES/PROBLEMS:
28
+
29
+ * [CLR-to-CLR mocking]: Caricature won't mock static methods because you can't override those according to CLR rules
30
+ * [CLR-to-CLR mocking]: Caricature can only override methods that are marked virtual (CLR rules)
31
+
32
+ == SYNOPSIS:
33
+
34
+ isolation = Isolation.for(Ninja)
35
+ isolation.when_receiving(:attack) do |exp|
36
+ exp.with(:shuriken)
37
+ exp.return(3)
38
+ end
39
+
40
+ Battle.new(mock)
41
+ battle.combat
42
+
43
+ isolation.should.have_received?(:attack)
44
+
45
+
46
+ == REQUIREMENTS:
47
+
48
+ * To use the caricature library you need to have uuidtools installed
49
+ (sudo) gem install uuidtools
50
+ (sudo) igem install uuidtools
51
+
52
+ == INSTALL:
53
+
54
+ (sudo) gem install caricature
55
+
56
+ == LICENSE:
57
+
58
+ Caricature -- A simple mocking framework for IronRuby
59
+
60
+ Copyright (c) 2009, Caricature Team
61
+ http://github.com/casualjim/caricature
62
+ All rights reserved.
63
+
64
+ Redistribution and use in source and binary forms,
65
+ with or without modification, are permitted provided
66
+ that the following conditions are met:
67
+
68
+ * Redistributions of source code must retain the
69
+ above copyright notice, this list of conditions and
70
+ the following disclaimer.
71
+
72
+ * Redistributions in binary form must reproduce
73
+ the above copyright notice, this list of conditions
74
+ and the following disclaimer in the documentation
75
+ and/or other materials provided with the distribution.
76
+
77
+ * Neither the name of the Caricature Team nor the
78
+ names of its contributors may be used to endorse
79
+ or promote products derived from this software
80
+ without specific prior written permission.
81
+
82
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
83
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
84
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
85
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
86
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
87
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
88
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
89
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
90
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
91
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
92
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
93
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
94
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
95
+ SUCH DAMAGE.
96
+
97
+ [This is the BSD license, see
98
98
  http://www.opensource.org/licenses/bsd-license.php]