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
@@ -1,40 +1,40 @@
1
- require File.dirname(__FILE__) + "/../spec_helper.rb"
2
-
3
- class ClrModels::Sword
4
-
5
- def to_s
6
- "<ClrModels::Sword object_id: #{object_id} >"
7
- end
8
- alias_method :inspect, :to_s
9
-
10
- end
11
-
12
- describe "ClrModels::Sword" do
13
-
14
- before do
15
- @warrior = Caricature::Isolation.for ClrModels::IWarrior
16
- end
17
-
18
- it "should call survive_attack on the mock" do
19
- @warrior.when_receiving(:survive_attack_with).return(5)
20
-
21
- sword = ClrModels::Sword.new
22
- sword.attack(@warrior).should == 5
23
-
24
- @warrior.did_receive?(:survive_attack_with).should be_successful
25
- end
26
-
27
- it "should return different results when expectation is defined with arguments" do
28
- sword1 = ClrModels::Sword.new
29
- sword2 = ClrModels::Sword.new
30
-
31
- @warrior.when_receiving(:survive_attack_with).with(:any).return(5)
32
- @warrior.when_receiving(:survive_attack_with).with(sword2).return(15)
33
-
34
- sword1.attack(@warrior).should == 5
35
- sword2.attack(@warrior).should == 15
36
-
37
- @warrior.did_receive?(:survive_attack_with).with(sword2).should be_successful
38
- end
39
-
1
+ require File.dirname(__FILE__) + "/../spec_helper.rb"
2
+
3
+ class ClrModels::Sword
4
+
5
+ def to_s
6
+ "<ClrModels::Sword object_id: #{object_id} >"
7
+ end
8
+ alias_method :inspect, :to_s
9
+
10
+ end
11
+
12
+ describe "ClrModels::Sword" do
13
+
14
+ before do
15
+ @warrior = Caricature::Isolation.for ClrModels::IWarrior
16
+ end
17
+
18
+ it "should call survive_attack on the mock" do
19
+ @warrior.when_receiving(:survive_attack_with).return(5)
20
+
21
+ sword = ClrModels::Sword.new
22
+ sword.attack(@warrior).should == 5
23
+
24
+ @warrior.did_receive?(:survive_attack_with).should be_successful
25
+ end
26
+
27
+ it "should return different results when expectation is defined with arguments" do
28
+ sword1 = ClrModels::Sword.new
29
+ sword2 = ClrModels::Sword.new
30
+
31
+ @warrior.when_receiving(:survive_attack_with).with(:any).return(5)
32
+ @warrior.when_receiving(:survive_attack_with).with(sword2).return(15)
33
+
34
+ sword1.attack(@warrior).should == 5
35
+ sword2.attack(@warrior).should == 15
36
+
37
+ @warrior.did_receive?(:survive_attack_with).with(sword2).should be_successful
38
+ end
39
+
40
40
  end
@@ -1,104 +1,104 @@
1
- require File.dirname(__FILE__) + "/../spec_helper"
2
-
3
- describe "Caricature::Verification" do
4
-
5
- describe "Matching" do
6
-
7
- before do
8
- @rec = Caricature::MethodCallRecorder.new
9
- @ver = Caricature::Verification.new(:my_method, @rec)
10
- end
11
-
12
- describe "Default initialisation" do
13
-
14
- it "should allow any arguments" do
15
- @ver.any_args?.should be_true
16
- end
17
-
18
- it "should match the provided method name when no arguments have been given" do
19
- @ver.matches?(:my_method).should be_true
20
- end
21
-
22
- it "should match the method name when arguments have been given" do
23
- @ver.matches?(:my_method, 1, 3, 4).should be_true
24
- end
25
-
26
- end
27
-
28
- describe "when initialized with and constrained by arguments" do
29
-
30
- before do
31
- @ver.with(1, 3, 6)
32
- end
33
-
34
- it "should match the provided method name when the correct arguments are given" do
35
- @ver.matches?(:my_method, 1, 3, 6).should be_true
36
- end
37
-
38
- it "should not match the method name when the arguments are not correct" do
39
- @ver.matches?(:my_method, 1, 3, 3).should be_false
40
- end
41
-
42
- it "should not match the method name when no arguments have been given" do
43
- @ver.matches?(:my_method).should be_false
44
- end
45
-
46
- end
47
-
48
- describe "when initialized with and not constrained by arguments" do
49
-
50
- before do
51
- @ver.with(1, 3, 6).allow_any_arguments
52
- end
53
-
54
- it "should match the provided method name when the correct arguments are given" do
55
- @ver.matches?(:my_method, 1, 3, 6).should be_true
56
- end
57
-
58
- it "should match the method name when the arguments are not correct" do
59
- @ver.matches?(:my_method, 1, 3, 3).should be_true
60
- end
61
-
62
- it "should match the method name when no arguments have been given" do
63
- @ver.matches?(:my_method).should be_true
64
- end
65
-
66
- end
67
-
68
- end
69
-
70
- describe "Verifying" do
71
-
72
- before do
73
- @rec = Caricature::MethodCallRecorder.new
74
- @rec.record_call :my_method
75
- @rec.record_call :my_method, :instance, nil, 1, 2, 3
76
- @rec.record_call :another_method
77
-
78
- end
79
-
80
- it "should be successful with any arguments allowed" do
81
- ver = Caricature::Verification.new(:my_method, @rec)
82
- ver.should be_successful
83
- end
84
-
85
- it "should be successful with a correct set of arguments provided for my_method" do
86
- ver = Caricature::Verification.new(:my_method, @rec)
87
- ver.with 1, 2, 3
88
- ver.should be_successful
89
- end
90
-
91
- it "should be unsuccessful when a wrong set of arguments is provided" do
92
- ver = Caricature::Verification.new(:my_method, @rec)
93
- ver.with 1, 5, 7
94
- ver.should_not be_successful
95
- end
96
-
97
- it "should be unsuccessful when the wrong method name is provided" do
98
- ver = Caricature::Verification.new(:some_method, @rec)
99
- ver.should_not be_successful
100
- end
101
-
102
- end
103
-
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ describe "Caricature::Verification" do
4
+
5
+ describe "Matching" do
6
+
7
+ before do
8
+ @rec = Caricature::MethodCallRecorder.new
9
+ @ver = Caricature::Verification.new(:my_method, @rec)
10
+ end
11
+
12
+ describe "Default initialisation" do
13
+
14
+ it "should allow any arguments" do
15
+ @ver.any_args?.should be_true
16
+ end
17
+
18
+ it "should match the provided method name when no arguments have been given" do
19
+ @ver.matches?(:my_method).should be_true
20
+ end
21
+
22
+ it "should match the method name when arguments have been given" do
23
+ @ver.matches?(:my_method, 1, 3, 4).should be_true
24
+ end
25
+
26
+ end
27
+
28
+ describe "when initialized with and constrained by arguments" do
29
+
30
+ before do
31
+ @ver.with(1, 3, 6)
32
+ end
33
+
34
+ it "should match the provided method name when the correct arguments are given" do
35
+ @ver.matches?(:my_method, 1, 3, 6).should be_true
36
+ end
37
+
38
+ it "should not match the method name when the arguments are not correct" do
39
+ @ver.matches?(:my_method, 1, 3, 3).should be_false
40
+ end
41
+
42
+ it "should not match the method name when no arguments have been given" do
43
+ @ver.matches?(:my_method).should be_false
44
+ end
45
+
46
+ end
47
+
48
+ describe "when initialized with and not constrained by arguments" do
49
+
50
+ before do
51
+ @ver.with(1, 3, 6).allow_any_arguments
52
+ end
53
+
54
+ it "should match the provided method name when the correct arguments are given" do
55
+ @ver.matches?(:my_method, 1, 3, 6).should be_true
56
+ end
57
+
58
+ it "should match the method name when the arguments are not correct" do
59
+ @ver.matches?(:my_method, 1, 3, 3).should be_true
60
+ end
61
+
62
+ it "should match the method name when no arguments have been given" do
63
+ @ver.matches?(:my_method).should be_true
64
+ end
65
+
66
+ end
67
+
68
+ end
69
+
70
+ describe "Verifying" do
71
+
72
+ before do
73
+ @rec = Caricature::MethodCallRecorder.new
74
+ @rec.record_call :my_method
75
+ @rec.record_call :my_method, :instance, nil, 1, 2, 3
76
+ @rec.record_call :another_method
77
+
78
+ end
79
+
80
+ it "should be successful with any arguments allowed" do
81
+ ver = Caricature::Verification.new(:my_method, @rec)
82
+ ver.should be_successful
83
+ end
84
+
85
+ it "should be successful with a correct set of arguments provided for my_method" do
86
+ ver = Caricature::Verification.new(:my_method, @rec)
87
+ ver.with 1, 2, 3
88
+ ver.should be_successful
89
+ end
90
+
91
+ it "should be unsuccessful when a wrong set of arguments is provided" do
92
+ ver = Caricature::Verification.new(:my_method, @rec)
93
+ ver.with 1, 5, 7
94
+ ver.should_not be_successful
95
+ end
96
+
97
+ it "should be unsuccessful when the wrong method name is provided" do
98
+ ver = Caricature::Verification.new(:some_method, @rec)
99
+ ver.should_not be_successful
100
+ end
101
+
102
+ end
103
+
104
104
  end
data/spec/spec_helper.rb CHANGED
@@ -1,15 +1,16 @@
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
- require File.dirname(__FILE__) + "/models/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
+ require File.dirname(__FILE__) + "/fixtures/soldier"
16
+ Dir[File.dirname(__FILE__) + "/fixtures/*.rb"].each { |l| require l }
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caricature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Porto Carrero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2010-01-03 00:00:00 +01:00
11
+
12
+ date: 2010-01-12 00:00:00 +01:00
12
13
  default_executable:
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
@@ -17,14 +18,16 @@ dependencies:
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
20
- - - '>='
21
+ - - ">="
21
22
  - !ruby/object:Gem::Version
22
23
  version: 2.0.0
23
24
  version:
24
25
  description: Caricature brings simple mocking to Ruby, DLR and CLR.
25
26
  email: ivan@flanders.co.nz
26
27
  executables: []
28
+
27
29
  extensions: []
30
+
28
31
  extra_rdoc_files:
29
32
  - README.rdoc
30
33
  files:
@@ -80,8 +83,35 @@ files:
80
83
  - spec/bacon/unit/sword_spec.rb
81
84
  - spec/bacon/unit/verification_spec.rb
82
85
  - spec/bin/ClrModels.dll
83
- - spec/models/ClrModels.cs
84
- - spec/models/ruby_models.rb
86
+ - spec/bin/ClrModels.dll.mdb
87
+ - spec/fixtures/ExplodingCar.cs
88
+ - spec/fixtures/ExposedChangedSubscriber.cs
89
+ - spec/fixtures/ExposingWarrior.cs
90
+ - spec/fixtures/IExplodingWarrior.cs
91
+ - spec/fixtures/IExposing.cs
92
+ - spec/fixtures/IExposingBridge.cs
93
+ - spec/fixtures/IExposingWarrior.cs
94
+ - spec/fixtures/IHaveAnIndexer.cs
95
+ - spec/fixtures/IWarrior.cs
96
+ - spec/fixtures/IWeapon.cs
97
+ - spec/fixtures/IndexerCaller.cs
98
+ - spec/fixtures/IndexerContained.cs
99
+ - spec/fixtures/MyClassWithAStatic.cs
100
+ - spec/fixtures/Ninja.cs
101
+ - spec/fixtures/Samurai.cs
102
+ - spec/fixtures/StaticCaller.cs
103
+ - spec/fixtures/Sword.cs
104
+ - spec/fixtures/SwordWithStatics.cs
105
+ - spec/fixtures/clr_interaction.rb
106
+ - spec/fixtures/dagger.rb
107
+ - spec/fixtures/dagger_with_class_members.rb
108
+ - spec/fixtures/sheath.rb
109
+ - spec/fixtures/soldier.rb
110
+ - spec/fixtures/soldier_with_class_members.rb
111
+ - spec/fixtures/swift_cleanup_crew.rb
112
+ - spec/fixtures/with_class_methods.rb
113
+ - spec/models.notused/ClrModels.cs
114
+ - spec/models.notused/ruby_models.rb
85
115
  - spec/rspec/integration/callback_spec.rb
86
116
  - spec/rspec/integration/clr_to_clr_spec.rb
87
117
  - spec/rspec/integration/clr_to_ruby_spec.rb
@@ -103,6 +133,7 @@ files:
103
133
  has_rdoc: true
104
134
  homepage: http://casualjim.github.com/caricature
105
135
  licenses: []
136
+
106
137
  post_install_message:
107
138
  rdoc_options:
108
139
  - --quiet
@@ -111,26 +142,26 @@ rdoc_options:
111
142
  - --main
112
143
  - README.rdoc
113
144
  - --line-numbers
114
- - --format
115
- - darkfish
116
145
  require_paths:
117
146
  - lib
118
147
  required_ruby_version: !ruby/object:Gem::Requirement
119
148
  requirements:
120
- - - '>='
149
+ - - ">="
121
150
  - !ruby/object:Gem::Version
122
- version: 1.8.4
151
+ version: 1.8.6
123
152
  version:
124
153
  required_rubygems_version: !ruby/object:Gem::Requirement
125
154
  requirements:
126
- - - '>='
155
+ - - ">="
127
156
  - !ruby/object:Gem::Version
128
- version: !str 0
157
+ version: "0"
129
158
  version:
130
159
  requirements: []
160
+
131
161
  rubyforge_project: caricature
132
162
  rubygems_version: 1.3.5
133
163
  signing_key:
134
164
  specification_version: 3
135
165
  summary: Caricature brings simple mocking to Ruby, DLR and CLR.
136
166
  test_files: []
167
+