caricature 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/VERSION +1 -1
  2. data/caricature.gemspec +5 -1
  3. data/doc/Array.html +2 -2
  4. data/doc/Caricature/ArgumentRecording.html +5 -5
  5. data/doc/Caricature/ClrClassDescriptor.html +2 -2
  6. data/doc/Caricature/ClrClassMessenger.html +2 -2
  7. data/doc/Caricature/ClrInterfaceDescriptor.html +4 -4
  8. data/doc/Caricature/ClrInterfaceIsolator.html +9 -9
  9. data/doc/Caricature/ClrInterfaceMessenger.html +2 -2
  10. data/doc/Caricature/ClrIsolator.html +13 -12
  11. data/doc/Caricature/Expectation.html +19 -19
  12. data/doc/Caricature/ExpectationBuilder.html +6 -6
  13. data/doc/Caricature/ExpectationSyntax.html +49 -21
  14. data/doc/Caricature/Expectations.html +7 -7
  15. data/doc/Caricature/Interception/ClassMethods.html +6 -6
  16. data/doc/Caricature/Interception.html +12 -12
  17. data/doc/Caricature/Isolation.html +22 -22
  18. data/doc/Caricature/Isolator.html +12 -12
  19. data/doc/Caricature/MemberDescriptor.html +4 -4
  20. data/doc/Caricature/Messenger.html +8 -8
  21. data/doc/Caricature/MethodCallRecorder.html +8 -8
  22. data/doc/Caricature/MethodCallRecording.html +11 -11
  23. data/doc/Caricature/RubyIsolator.html +8 -8
  24. data/doc/Caricature/RubyMessenger.html +2 -2
  25. data/doc/Caricature/RubyObjectDescriptor.html +4 -4
  26. data/doc/Caricature/TypeDescriptor.html +6 -6
  27. data/doc/Caricature/Verification.html +13 -13
  28. data/doc/Class.html +4 -4
  29. data/doc/Hash.html +2 -2
  30. data/doc/Module.html +4 -4
  31. data/doc/Object.html +93 -6
  32. data/doc/String.html +84 -4
  33. data/doc/System/String.html +4 -4
  34. data/doc/System/Type.html +4 -4
  35. data/doc/created.rid +1 -1
  36. data/doc/index.html +114 -104
  37. data/doc/lib/caricature/clr/aspnet_mvc_rb.html +52 -0
  38. data/doc/lib/caricature/clr/descriptor_rb.html +1 -1
  39. data/doc/lib/caricature/clr/isolation_rb.html +1 -1
  40. data/doc/lib/caricature/clr/isolator_rb.html +1 -1
  41. data/doc/lib/caricature/clr/messenger_rb.html +1 -1
  42. data/doc/lib/caricature/clr_rb.html +1 -1
  43. data/doc/lib/caricature/descriptor_rb.html +1 -1
  44. data/doc/lib/caricature/expectation_rb.html +1 -1
  45. data/doc/lib/caricature/isolation_rb.html +1 -1
  46. data/doc/lib/caricature/isolator_rb.html +1 -1
  47. data/doc/lib/caricature/messenger_rb.html +1 -1
  48. data/doc/lib/caricature/method_call_recorder_rb.html +1 -1
  49. data/doc/lib/caricature/verification_rb.html +1 -1
  50. data/doc/lib/caricature_rb.html +1 -1
  51. data/doc/lib/core_ext/array_rb.html +1 -1
  52. data/doc/lib/core_ext/class_rb.html +1 -1
  53. data/doc/lib/core_ext/core_ext_rb.html +1 -1
  54. data/doc/lib/core_ext/hash_rb.html +1 -1
  55. data/doc/lib/core_ext/module_rb.html +1 -1
  56. data/doc/lib/core_ext/object_rb.html +1 -1
  57. data/doc/lib/core_ext/string_rb.html +1 -1
  58. data/doc/lib/core_ext/system/string_rb.html +1 -1
  59. data/doc/lib/core_ext/system/type_rb.html +1 -1
  60. data/lib/caricature/expectation.rb +18 -3
  61. data/lib/caricature/messenger.rb +1 -0
  62. data/pkg/caricature-0.6.0.gem +0 -0
  63. data/spec/bacon_helper.rb +10 -0
  64. data/spec/models/ClrModels.cs +7 -7
  65. data/spec/sword_spec.rb +40 -0
  66. metadata +5 -1
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Tue May 19 14:14:36 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Tue May 19 13:09:23 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Tue May 19 08:48:15 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Tue May 19 13:41:41 +0200 2009</dd>
27
+ <dd class="modified-date">Thu May 21 13:47:23 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Tue May 19 14:46:27 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Tue May 19 14:51:41 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Tue May 19 14:13:59 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Tue May 19 14:03:21 +0200 2009</dd>
27
+ <dd class="modified-date">Wed May 20 15:20:03 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Tue May 19 14:10:02 +0200 2009</dd>
27
+ <dd class="modified-date">Thu May 21 13:38:47 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Tue May 19 13:59:00 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Sat May 16 13:30:39 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Mon May 18 14:56:54 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Sat May 16 13:31:04 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Sat May 16 13:30:14 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Sat May 16 00:22:26 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Tue May 19 10:37:13 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Sat May 16 00:22:26 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Sat May 16 00:22:26 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Sat May 16 00:22:26 +0200 2009</dd>
27
+ <dd class="modified-date">Tue May 19 15:03:01 +0200 2009</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,11 +24,18 @@ module Caricature
24
24
  def find(method_name, mode=:instance, *args)
25
25
  expectations = mode == :class ? @class_expectations : @instance_expectations
26
26
  candidates = expectations.select { |exp| exp.method_name.to_s.to_sym == method_name.to_s.to_sym }
27
- is_single = args.empty? || (args.first.is_a?(Symbol) and args.first == :any) || (candidates.size == 1 && candidates.first.any_args?)
27
+ is_single = (args.first.is_a?(Symbol) and args.first == :any)
28
28
  return candidates.first if is_single
29
29
 
30
- second_pass = candidates.select {|exp| exp.args == args }
31
- second_pass.first
30
+ second_pass = candidates.select do |exp|
31
+ result = false
32
+ exp.args.each_with_index do |item, idx|
33
+ result = true if args[idx] == item
34
+ end
35
+ result
36
+ end
37
+ return second_pass.first unless second_pass.empty?
38
+ candidates.select { |exp| exp.any_args? }.first
32
39
  end
33
40
 
34
41
  end
@@ -132,6 +139,14 @@ module Caricature
132
139
  return return_value if has_return_value?
133
140
  nil
134
141
  end
142
+
143
+ def to_s
144
+ "<Caricature::Expecation, method_name: #{method_name}, args: #{args}, error args: #{error_args}>"
145
+ end
146
+
147
+ def inspect
148
+ to_s
149
+ end
135
150
  end
136
151
 
137
152
  # Constructs the expecation object.
@@ -17,6 +17,7 @@ module Caricature
17
17
 
18
18
  # deliver the message to the receiving isolation
19
19
  def deliver(method_name, return_type, *args, &b)
20
+
20
21
  internal_deliver(:instance, method_name, return_type, *args, &b)
21
22
  end
22
23
 
Binary file
data/spec/bacon_helper.rb CHANGED
@@ -1,11 +1,21 @@
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.
1
4
  $: << File.dirname(__FILE__) + "/bin"
5
+ # adds the path to the caricature library.
2
6
  $: << File.dirname(__FILE__) + "/../lib"
3
7
 
8
+ # load the caricature library
4
9
  require "caricature"
5
10
  require 'caricature/clr'
11
+
12
+ # load the bacon library
6
13
  require 'bacon'
14
+
15
+ # Add the .NET framework
7
16
  require 'mscorlib'
8
17
 
18
+ # load the assembly with the C# code
9
19
  load_assembly 'ClrModels'
10
20
 
11
21
  class Soldier
@@ -85,16 +85,16 @@ namespace ClrModels{
85
85
 
86
86
  }
87
87
 
88
- public class Sword : IWeapon{
88
+ public class Sword : IWeapon{
89
89
 
90
- public int Attack(IWarrior warrior){
91
- return warrior.SurviveAttackWith(this);
92
- }
90
+ public int Attack(IWarrior warrior){
91
+ return warrior.SurviveAttackWith(this);
92
+ }
93
93
 
94
- public int Damage(){
95
- return 4;
96
- }
94
+ public int Damage(){
95
+ return 4;
97
96
  }
97
+ }
98
98
 
99
99
  public class SwordWithStatics : Sword{
100
100
 
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + "/bacon_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.equal 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.equal 5
35
+ sword2.attack(@warrior).should.equal 15
36
+
37
+ @warrior.did_receive?(:survive_attack_with).with(sword2).should.be.successful
38
+ end
39
+
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caricature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Porto Carrero
@@ -88,6 +88,7 @@ files:
88
88
  - doc/js/jquery.js
89
89
  - doc/js/quicksearch.js
90
90
  - doc/js/thickbox-compressed.js
91
+ - doc/lib/caricature/clr/aspnet_mvc_rb.html
91
92
  - doc/lib/caricature/clr/descriptor_rb.html
92
93
  - doc/lib/caricature/clr/isolation_rb.html
93
94
  - doc/lib/caricature/clr/isolator_rb.html
@@ -141,6 +142,7 @@ files:
141
142
  - pkg/.gitignore
142
143
  - pkg/caricature-0.1.0.gem
143
144
  - pkg/caricature-0.5.0.gem
145
+ - pkg/caricature-0.6.0.gem
144
146
  - spec/bacon_helper.rb
145
147
  - spec/bin/.gitignore
146
148
  - spec/core_ext_spec.rb
@@ -153,6 +155,7 @@ files:
153
155
  - spec/messaging_spec.rb
154
156
  - spec/method_call_spec.rb
155
157
  - spec/models/ClrModels.cs
158
+ - spec/sword_spec.rb
156
159
  - spec/verification_spec.rb
157
160
  - workarounds/ReflectionHelper.cs
158
161
  has_rdoc: true
@@ -194,4 +197,5 @@ test_files:
194
197
  - spec/isolator_spec.rb
195
198
  - spec/messaging_spec.rb
196
199
  - spec/method_call_spec.rb
200
+ - spec/sword_spec.rb
197
201
  - spec/verification_spec.rb