caricature 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/caricature.gemspec +5 -2
- data/doc/Array.html +2 -2
- data/doc/Caricature/ArgumentRecording.html +4 -4
- data/doc/Caricature/ClrClassMessenger.html +22 -22
- data/doc/Caricature/ClrInterfaceMessenger.html +19 -19
- data/doc/Caricature/ClrIsolator.html +1 -1
- data/doc/Caricature/Expectation.html +12 -12
- data/doc/Caricature/ExpectationBuilder.html +6 -6
- data/doc/Caricature/ExpectationSyntax.html +10 -10
- data/doc/Caricature/Expectations.html +19 -16
- data/doc/Caricature/Interception/ClassMethods.html +120 -2
- data/doc/Caricature/Interception.html +130 -12
- data/doc/Caricature/Isolation.html +207 -22
- data/doc/Caricature/Isolator.html +18 -18
- data/doc/Caricature/Messenger.html +87 -9
- data/doc/Caricature/MethodCallRecorder.html +20 -56
- data/doc/Caricature/MethodCallRecording.html +10 -10
- data/doc/Caricature/RubyIsolator.html +13 -13
- data/doc/Caricature/RubyMessenger.html +24 -23
- data/doc/Caricature/RubyObjectDescriptor.html +4 -4
- data/doc/Caricature/TypeDescriptor.html +4 -4
- data/doc/Caricature/Verification.html +16 -16
- data/doc/Caricature.html +2 -2
- data/doc/Class.html +4 -4
- data/doc/Hash.html +2 -2
- data/doc/Module.html +4 -4
- data/doc/Object.html +6 -6
- data/doc/String.html +4 -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 +102 -82
- 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/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 +52 -0
- 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/lib/caricature/clr/aspnet_mvc.rb +51 -0
- data/lib/caricature/clr/isolator.rb +2 -1
- data/lib/caricature/expectation.rb +4 -3
- data/lib/caricature/method_call_recorder.rb +2 -2
- data/lib/caricature/verification.rb +1 -1
- data/pkg/caricature-0.5.0.gem +0 -0
- data/spec/isolator_spec.rb +7 -1
- metadata +5 -2
data/doc/lib/caricature_rb.html
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
load_assembly 'System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
|
2
|
+
load_assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
|
3
|
+
load_assembly 'System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
|
4
|
+
|
5
|
+
class String
|
6
|
+
|
7
|
+
def to_url_filename
|
8
|
+
return self.gsub(/\?.*/, '') if self =~ /\?/
|
9
|
+
self
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_qs_parameters
|
13
|
+
if self =~ /\?/
|
14
|
+
parameters = NameValueCollection.new
|
15
|
+
self.split('?')[1].split("&").each do |pair|
|
16
|
+
parts = pair.split('=')
|
17
|
+
parameters.add pair.first, pair.last
|
18
|
+
end
|
19
|
+
return parameters
|
20
|
+
end
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def http_context_isolation(url="")
|
27
|
+
|
28
|
+
context = Caricature::Isolation.for(HttpContextBase)
|
29
|
+
request = Caricature::Isolation.for(HttpRequestBase)
|
30
|
+
response = Caricature::Isolation.for(HttpResponseBase)
|
31
|
+
session = Caricature::Isolation.for(HttpSessionStateBase)
|
32
|
+
server = Caricature::Isolation.for(HttpServerUtilityBase)
|
33
|
+
|
34
|
+
context.when_receiving(:request).return(request)
|
35
|
+
context.when_receiving(:response).return(response)
|
36
|
+
context.when_receiving(:session).return(session)
|
37
|
+
context.when_receiving(:server).return(server)
|
38
|
+
|
39
|
+
setup_request_url(context.request, url) unless url.nil? or url.empty?
|
40
|
+
|
41
|
+
context
|
42
|
+
end
|
43
|
+
|
44
|
+
def setup_request_url(request, url)
|
45
|
+
raise ArgumentError.new("url should not be nil") if url.nil? or url.empty?
|
46
|
+
raise ArgumentError.new("we expect a url to start with '~/'.") unless url =~ /^~\//
|
47
|
+
|
48
|
+
request.when_receiving(:query_string).return(url.to_s.to_qs_parameters)
|
49
|
+
request.when_receiving(:app_relative_current_execution_file_path).return(url.to_s.to_url_filename)
|
50
|
+
request.when_receiving(:path_info).return("")
|
51
|
+
end
|
@@ -18,7 +18,8 @@ module Caricature
|
|
18
18
|
instance = context.subject
|
19
19
|
end
|
20
20
|
@descriptor = ClrClassDescriptor.new sklass
|
21
|
-
|
21
|
+
instance ||= sklass.new unless sklass.to_clr_type.is_abstract
|
22
|
+
build_isolation sklass, instance
|
22
23
|
end
|
23
24
|
|
24
25
|
# initializes the messaging strategy for the isolator
|
@@ -24,7 +24,7 @@ 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 == :any || (candidates.size == 1 && candidates.first.any_args?)
|
27
|
+
is_single = args.empty? || (args.first.is_a?(Symbol) and args.first == :any) || (candidates.size == 1 && candidates.first.any_args?)
|
28
28
|
return candidates.first if is_single
|
29
29
|
|
30
30
|
second_pass = candidates.select {|exp| exp.args == args }
|
@@ -40,7 +40,7 @@ module Caricature
|
|
40
40
|
# there is a magic argument here +any+ which configures
|
41
41
|
# the expectation to respond to any arguments
|
42
42
|
def with(*args)
|
43
|
-
@any_args =
|
43
|
+
@any_args = args.first.is_a?(Symbol) and args.first == :any
|
44
44
|
@args = args
|
45
45
|
self
|
46
46
|
end
|
@@ -54,6 +54,7 @@ module Caricature
|
|
54
54
|
end
|
55
55
|
|
56
56
|
# tell the expectation it needs to raise an error with the specified arguments
|
57
|
+
alias_method :actual_raise, :raise
|
57
58
|
def raise(*args)
|
58
59
|
@error_args = args
|
59
60
|
self
|
@@ -127,7 +128,7 @@ module Caricature
|
|
127
128
|
# executes this expectation with its configuration
|
128
129
|
def execute(*margs)
|
129
130
|
ags = any_args? ? (margs.empty? ? :any : margs) : args
|
130
|
-
|
131
|
+
actual_raise *@error_args if has_error_args?
|
131
132
|
return return_value if has_return_value?
|
132
133
|
nil
|
133
134
|
end
|
@@ -28,7 +28,7 @@ module Caricature
|
|
28
28
|
# Also takes an array as an argument
|
29
29
|
def ==(other)
|
30
30
|
other = self.class.new(other) if other.respond_to?(:each)
|
31
|
-
return true if other.args.first == :any
|
31
|
+
return true if other.args.first.is_a?(Symbol) and other.args.first == :any
|
32
32
|
other.args == args
|
33
33
|
end
|
34
34
|
end
|
@@ -77,7 +77,7 @@ module Caricature
|
|
77
77
|
|
78
78
|
# finds an argument variation that matches the provided +args+
|
79
79
|
def find_argument_variations(args)
|
80
|
-
return @variations if args.first == :any
|
80
|
+
return @variations if args.first.is_a?(Symbol) and args.first == :any
|
81
81
|
@variations.select { |ar| ar.args == args }
|
82
82
|
end
|
83
83
|
end
|
Binary file
|
data/spec/isolator_spec.rb
CHANGED
@@ -6,7 +6,13 @@ class TestIsolation
|
|
6
6
|
@instance, @expectations = instance, expectations
|
7
7
|
end
|
8
8
|
def send_message(method_name, return_type, *args, &b)
|
9
|
-
|
9
|
+
internal_send method_name, :internal, return_type, *args, &b
|
10
|
+
end
|
11
|
+
def send_class_message(method_name, return_type, *args, &b)
|
12
|
+
internal_send method_name, :class, return_type, *args, &b
|
13
|
+
end
|
14
|
+
def internal_send(method_name, mode, return_type, *args, &b)
|
15
|
+
exp = expectations.find(method_name, mode, *args)
|
10
16
|
if exp
|
11
17
|
res = instance.__send__(method_name, *args, &b) if exp.super_before?
|
12
18
|
res = exp.execute(*args)
|
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.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Porto Carrero
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-21 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- doc/lib/caricature/isolation_rb.html
|
99
99
|
- doc/lib/caricature/isolator_rb.html
|
100
100
|
- doc/lib/caricature/messaging_rb.html
|
101
|
+
- doc/lib/caricature/messenger_rb.html
|
101
102
|
- doc/lib/caricature/method_call_recorder_rb.html
|
102
103
|
- doc/lib/caricature/verification_rb.html
|
103
104
|
- doc/lib/caricature_rb.html
|
@@ -116,6 +117,7 @@ files:
|
|
116
117
|
- lib/bin/Workarounds.pdb
|
117
118
|
- lib/caricature.rb
|
118
119
|
- lib/caricature/clr.rb
|
120
|
+
- lib/caricature/clr/aspnet_mvc.rb
|
119
121
|
- lib/caricature/clr/descriptor.rb
|
120
122
|
- lib/caricature/clr/isolation.rb
|
121
123
|
- lib/caricature/clr/isolator.rb
|
@@ -138,6 +140,7 @@ files:
|
|
138
140
|
- lib/core_ext/system/type.rb
|
139
141
|
- pkg/.gitignore
|
140
142
|
- pkg/caricature-0.1.0.gem
|
143
|
+
- pkg/caricature-0.5.0.gem
|
141
144
|
- spec/bacon_helper.rb
|
142
145
|
- spec/bin/.gitignore
|
143
146
|
- spec/core_ext_spec.rb
|