caricature 0.6.0 → 0.6.1
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/VERSION +1 -1
- data/caricature.gemspec +5 -1
- data/doc/Array.html +2 -2
- data/doc/Caricature/ArgumentRecording.html +5 -5
- data/doc/Caricature/ClrClassDescriptor.html +2 -2
- data/doc/Caricature/ClrClassMessenger.html +2 -2
- data/doc/Caricature/ClrInterfaceDescriptor.html +4 -4
- data/doc/Caricature/ClrInterfaceIsolator.html +9 -9
- data/doc/Caricature/ClrInterfaceMessenger.html +2 -2
- data/doc/Caricature/ClrIsolator.html +13 -12
- data/doc/Caricature/Expectation.html +19 -19
- data/doc/Caricature/ExpectationBuilder.html +6 -6
- data/doc/Caricature/ExpectationSyntax.html +49 -21
- data/doc/Caricature/Expectations.html +7 -7
- data/doc/Caricature/Interception/ClassMethods.html +6 -6
- data/doc/Caricature/Interception.html +12 -12
- data/doc/Caricature/Isolation.html +22 -22
- data/doc/Caricature/Isolator.html +12 -12
- data/doc/Caricature/MemberDescriptor.html +4 -4
- data/doc/Caricature/Messenger.html +8 -8
- data/doc/Caricature/MethodCallRecorder.html +8 -8
- data/doc/Caricature/MethodCallRecording.html +11 -11
- data/doc/Caricature/RubyIsolator.html +8 -8
- data/doc/Caricature/RubyMessenger.html +2 -2
- data/doc/Caricature/RubyObjectDescriptor.html +4 -4
- data/doc/Caricature/TypeDescriptor.html +6 -6
- data/doc/Caricature/Verification.html +13 -13
- data/doc/Class.html +4 -4
- data/doc/Hash.html +2 -2
- data/doc/Module.html +4 -4
- data/doc/Object.html +93 -6
- data/doc/String.html +84 -4
- data/doc/System/String.html +4 -4
- data/doc/System/Type.html +4 -4
- data/doc/created.rid +1 -1
- data/doc/index.html +114 -104
- data/doc/lib/caricature/clr/aspnet_mvc_rb.html +52 -0
- data/doc/lib/caricature/clr/descriptor_rb.html +1 -1
- data/doc/lib/caricature/clr/isolation_rb.html +1 -1
- data/doc/lib/caricature/clr/isolator_rb.html +1 -1
- data/doc/lib/caricature/clr/messenger_rb.html +1 -1
- data/doc/lib/caricature/clr_rb.html +1 -1
- data/doc/lib/caricature/descriptor_rb.html +1 -1
- data/doc/lib/caricature/expectation_rb.html +1 -1
- data/doc/lib/caricature/isolation_rb.html +1 -1
- data/doc/lib/caricature/isolator_rb.html +1 -1
- data/doc/lib/caricature/messenger_rb.html +1 -1
- data/doc/lib/caricature/method_call_recorder_rb.html +1 -1
- data/doc/lib/caricature/verification_rb.html +1 -1
- data/doc/lib/caricature_rb.html +1 -1
- data/doc/lib/core_ext/array_rb.html +1 -1
- data/doc/lib/core_ext/class_rb.html +1 -1
- data/doc/lib/core_ext/core_ext_rb.html +1 -1
- data/doc/lib/core_ext/hash_rb.html +1 -1
- data/doc/lib/core_ext/module_rb.html +1 -1
- data/doc/lib/core_ext/object_rb.html +1 -1
- data/doc/lib/core_ext/string_rb.html +1 -1
- data/doc/lib/core_ext/system/string_rb.html +1 -1
- data/doc/lib/core_ext/system/type_rb.html +1 -1
- data/lib/caricature/expectation.rb +18 -3
- data/lib/caricature/messenger.rb +1 -0
- data/pkg/caricature-0.6.0.gem +0 -0
- data/spec/bacon_helper.rb +10 -0
- data/spec/models/ClrModels.cs +7 -7
- data/spec/sword_spec.rb +40 -0
- metadata +5 -1
data/doc/lib/caricature_rb.html
CHANGED
@@ -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 =
|
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
|
31
|
-
|
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.
|
data/lib/caricature/messenger.rb
CHANGED
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
|
data/spec/models/ClrModels.cs
CHANGED
@@ -85,16 +85,16 @@ namespace ClrModels{
|
|
85
85
|
|
86
86
|
}
|
87
87
|
|
88
|
-
|
88
|
+
public class Sword : IWeapon{
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
|
90
|
+
public int Attack(IWarrior warrior){
|
91
|
+
return warrior.SurviveAttackWith(this);
|
92
|
+
}
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
}
|
94
|
+
public int Damage(){
|
95
|
+
return 4;
|
97
96
|
}
|
97
|
+
}
|
98
98
|
|
99
99
|
public class SwordWithStatics : Sword{
|
100
100
|
|
data/spec/sword_spec.rb
ADDED
@@ -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.
|
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
|