Class: Picky::TestClient

Inherits:
Client show all
Defined in:
lib/picky-client/spec/test_client.rb

Instance Attribute Summary collapse

Attributes inherited from Client

#host, #path, #port

Instance Method Summary collapse

Methods inherited from Client

#default_configuration, default_configuration, #default_params, default_params, #defaultize, #initialize_from_hash, #initialize_from_uri, #remove, #replace, #search_unparsed, #send_off, #to_s

Constructor Details

#initialize(rack_app, options = {}) ⇒ TestClient

Example:

Picky::TestClient.new(BookSearch, :path => '/books')


12
13
14
15
16
# File 'lib/picky-client/spec/test_client.rb', line 12

def initialize rack_app, options = {}
  super options

  @request = ::Rack::MockRequest.new rack_app
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



5
6
7
# File 'lib/picky-client/spec/test_client.rb', line 5

def request
  @request
end

Instance Method Details

#search(query, params = {}) ⇒ Object

Wraps the search method to always extend the result with Convenience.



20
21
22
# File 'lib/picky-client/spec/test_client.rb', line 20

def search query, params = {}
  super.extend Convenience
end

#send_search(params = {}) ⇒ Object

Backend method that we override to not send a real search.



26
27
28
29
30
# File 'lib/picky-client/spec/test_client.rb', line 26

def send_search params = {}
  params = defaultize params

  request.get("#{self.path}?#{params.to_query}").body
end