# File lib/faraday/adapter/test.rb, line 64 def delete(path, headers = {}, &block) new_stub(:delete, path, headers, &block) end
# File lib/faraday/adapter/test.rb, line 27 def empty? @stack.empty? end
# File lib/faraday/adapter/test.rb, line 44 def get(path, headers = {}, &block) new_stub(:get, path, headers, &block) end
# File lib/faraday/adapter/test.rb, line 48 def head(path, headers = {}, &block) new_stub(:head, path, headers, &block) end
# File lib/faraday/adapter/test.rb, line 31 def match(request_method, path, headers, body) return false if !@stack.key?(request_method) stack = @stack[request_method] consumed = (@consumed[request_method] ||= []) if stub = matches?(stack, path, headers, body) consumed << stack.delete(stub) stub else matches?(consumed, path, headers, body) end end
# File lib/faraday/adapter/test.rb, line 68 def options(path, headers = {}, &block) new_stub(:options, path, headers, &block) end
# File lib/faraday/adapter/test.rb, line 60 def patch(path, body=nil, headers = {}, &block) new_stub(:patch, path, headers, body, &block) end
# File lib/faraday/adapter/test.rb, line 52 def post(path, body=nil, headers = {}, &block) new_stub(:post, path, headers, body, &block) end
# File lib/faraday/adapter/test.rb, line 56 def put(path, body=nil, headers = {}, &block) new_stub(:put, path, headers, body, &block) end
Raises an error if any of the stubbed calls have not been made.
# File lib/faraday/adapter/test.rb, line 73 def verify_stubbed_calls failed_stubs = [] @stack.each do |method, stubs| unless stubs.size == 0 failed_stubs.concat(stubs.map {|stub| "Expected #{method} #{stub}." }) end end raise failed_stubs.join(" ") unless failed_stubs.size == 0 end
# File lib/faraday/adapter/test.rb, line 92 def matches?(stack, path, headers, body) stack.detect { |stub| stub.matches?(path, headers, body) } end
# File lib/faraday/adapter/test.rb, line 87 def new_stub(request_method, path, headers = {}, body=nil, &block) normalized_path = Faraday::Utils.normalize_path(path) (@stack[request_method] ||= []) << Stub.new(normalized_path, headers, body, block) end
Generated with the Darkfish Rdoc Generator 2.