Class: Faraday::Adapter::Test::Stub
- Defined in:
 - lib/puppet/feature/faraday/adapter/test.rb
 
Instance Attribute Summary collapse
- 
  
    
      #block  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute block.
 - 
  
    
      #body  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute body.
 - 
  
    
      #headers  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute headers.
 - 
  
    
      #params  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute params.
 - 
  
    
      #path  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute path.
 
Instance Method Summary collapse
- #headers_match?(request_headers) ⇒ Boolean
 - 
  
    
      #initialize(full, headers, body, block)  ⇒ Stub 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Stub.
 - #matches?(request_uri, request_headers, request_body) ⇒ Boolean
 - #params_match?(request_params) ⇒ Boolean
 - #to_s ⇒ Object
 
Constructor Details
#initialize(full, headers, body, block) ⇒ Stub
Returns a new instance of Stub.
      98 99 100 101 102 103 104  | 
    
      # File 'lib/puppet/feature/faraday/adapter/test.rb', line 98 def initialize(full, headers, body, block) path, query = full.split('?') params = query ? Faraday::Utils.parse_nested_query(query) : {} super(path, params, headers, body, block) end  | 
  
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block
      97 98 99  | 
    
      # File 'lib/puppet/feature/faraday/adapter/test.rb', line 97 def block @block end  | 
  
#body ⇒ Object
Returns the value of attribute body
      97 98 99  | 
    
      # File 'lib/puppet/feature/faraday/adapter/test.rb', line 97 def body @body end  | 
  
#headers ⇒ Object
Returns the value of attribute headers
      97 98 99  | 
    
      # File 'lib/puppet/feature/faraday/adapter/test.rb', line 97 def headers @headers end  | 
  
#params ⇒ Object
Returns the value of attribute params
      97 98 99  | 
    
      # File 'lib/puppet/feature/faraday/adapter/test.rb', line 97 def params @params end  | 
  
#path ⇒ Object
Returns the value of attribute path
      97 98 99  | 
    
      # File 'lib/puppet/feature/faraday/adapter/test.rb', line 97 def path @path end  | 
  
Instance Method Details
#headers_match?(request_headers) ⇒ Boolean
      123 124 125 126 127  | 
    
      # File 'lib/puppet/feature/faraday/adapter/test.rb', line 123 def headers_match?(request_headers) headers.keys.all? do |key| request_headers[key] == headers[key] end end  | 
  
#matches?(request_uri, request_headers, request_body) ⇒ Boolean
      106 107 108 109 110 111 112 113 114 115  | 
    
      # File 'lib/puppet/feature/faraday/adapter/test.rb', line 106 def matches?(request_uri, request_headers, request_body) request_path, request_query = request_uri.split('?') request_params = request_query ? Faraday::Utils.parse_nested_query(request_query) : {} request_path == path && params_match?(request_params) && (body.to_s.size.zero? || request_body == body) && headers_match?(request_headers) end  | 
  
#params_match?(request_params) ⇒ Boolean
      117 118 119 120 121  | 
    
      # File 'lib/puppet/feature/faraday/adapter/test.rb', line 117 def params_match?(request_params) params.keys.all? do |key| request_params[key] == params[key] end end  | 
  
#to_s ⇒ Object
      129 130 131  | 
    
      # File 'lib/puppet/feature/faraday/adapter/test.rb', line 129 def to_s "#{path} #{body}" end  |