Class: Faraday::Adapter::MockRequest::Stubs
- Defined in:
- lib/faraday/adapter/mock_request.rb
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #get(path, request_headers = {}, &block) ⇒ Object
-
#initialize {|_self| ... } ⇒ Stubs
constructor
A new instance of Stubs.
- #match(request_method, path, request_headers) ⇒ Object
- #new_stub(path, request_headers, block) ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Stubs
Returns a new instance of Stubs.
10 11 12 13 14 |
# File 'lib/faraday/adapter/mock_request.rb', line 10 def initialize # {:get => [Stub, Stub]} @stack = {} yield self if block_given? end |
Instance Method Details
#empty? ⇒ Boolean
16 17 18 |
# File 'lib/faraday/adapter/mock_request.rb', line 16 def empty? @stack.empty? end |
#get(path, request_headers = {}, &block) ⇒ Object
25 26 27 |
# File 'lib/faraday/adapter/mock_request.rb', line 25 def get(path, request_headers = {}, &block) (@stack[:get] ||= []) << new_stub(path, request_headers, block) end |
#match(request_method, path, request_headers) ⇒ Object
20 21 22 23 |
# File 'lib/faraday/adapter/mock_request.rb', line 20 def match(request_method, path, request_headers) return false if !@stack.key?(request_method) @stack[request_method].detect { |stub| stub.matches?(path, request_headers) } end |