Class: EventMachine::MockHttpRequest
Defined Under Namespace
Classes: FakeHttpClient
Constant Summary
collapse
- @@registry =
nil
- @@registry_count =
nil
- @@pass_through_requests =
true
Instance Attribute Summary
Attributes inherited from HttpRequest
#method, #options
Class Method Summary
collapse
-
.count(uri, method, headers) ⇒ Object
-
.increment_access(query, method, headers) ⇒ Object
-
.pass_through_requests ⇒ Object
-
.pass_through_requests=(pass_through_requests) ⇒ Object
-
.register(uri, method, headers, data) ⇒ Object
-
.register_file(uri, method, headers, file) ⇒ Object
-
.registered?(query, method, headers) ⇒ Boolean
-
.registered_content(query, method, headers) ⇒ Object
-
.reset_counts! ⇒ Object
-
.reset_registry! ⇒ Object
Instance Method Summary
collapse
Methods inherited from HttpRequest
#delete, #get, #head, #initialize, #post, #put
Class Method Details
.count(uri, method, headers) ⇒ Object
57
58
59
60
61
|
# File 'lib/em-http/mock.rb', line 57
def self.count(uri, method, )
method = method.to_s.upcase
= .to_s
@@registry_count[uri][method][] rescue 0
end
|
.increment_access(query, method, headers) ⇒ Object
71
72
73
|
# File 'lib/em-http/mock.rb', line 71
def self.increment_access(query, method, )
@@registry_count[query][method][] += 1
end
|
.pass_through_requests ⇒ Object
43
44
45
|
# File 'lib/em-http/mock.rb', line 43
def self.pass_through_requests
@@pass_through_requests
end
|
.pass_through_requests=(pass_through_requests) ⇒ Object
39
40
41
|
# File 'lib/em-http/mock.rb', line 39
def self.pass_through_requests=(pass_through_requests)
@@pass_through_requests = pass_through_requests
end
|
.register(uri, method, headers, data) ⇒ Object
47
48
49
50
51
|
# File 'lib/em-http/mock.rb', line 47
def self.register(uri, method, , data)
method = method.to_s.upcase
= .to_s
@@registry[uri][method][] = data
end
|
.register_file(uri, method, headers, file) ⇒ Object
53
54
55
|
# File 'lib/em-http/mock.rb', line 53
def self.register_file(uri, method, , file)
register(uri, method, , File.read(file))
end
|
.registered?(query, method, headers) ⇒ Boolean
63
64
65
|
# File 'lib/em-http/mock.rb', line 63
def self.registered?(query, method, )
@@registry[query] and @@registry[query][method] and @@registry[query][method][]
end
|
.registered_content(query, method, headers) ⇒ Object
67
68
69
|
# File 'lib/em-http/mock.rb', line 67
def self.registered_content(query, method, )
@@registry[query][method][]
end
|
.reset_counts! ⇒ Object
22
23
24
25
26
|
# File 'lib/em-http/mock.rb', line 22
def self.reset_counts!
@@registry_count = Hash.new do |registry,query|
registry[query] = Hash.new{|h,k| h[k] = Hash.new(0)}
end
end
|
.reset_registry! ⇒ Object
28
29
30
31
32
|
# File 'lib/em-http/mock.rb', line 28
def self.reset_registry!
@@registry = Hash.new do |registry,query|
registry[query] = Hash.new{|h,k| h[k] = {}}
end
end
|
Instance Method Details
#real_send_request ⇒ Object
75
|
# File 'lib/em-http/mock.rb', line 75
alias_method :real_send_request, :send_request
|