Class: Handsoap::Http::Drivers::MockDriver
- Inherits:
-
AbstractDriver
- Object
- AbstractDriver
- Handsoap::Http::Drivers::MockDriver
- Defined in:
- lib/handsoap/http/drivers/mock_driver.rb
Overview
A mock driver for your testing needs.
To use it, create a new instance and assign to Handsoap::Http.drivers
. Then configure Handsoap::Service
to use it:
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :status => 200, :headers => headers, :content => body
Handsoap.http_driver = :mock
Remember that headers should use rn, rather than n.
Instance Attribute Summary collapse
-
#is_loaded ⇒ Object
Returns the value of attribute is_loaded.
-
#last_request ⇒ Object
Returns the value of attribute last_request.
-
#mock ⇒ Object
Returns the value of attribute mock.
Instance Method Summary collapse
-
#initialize(mock) ⇒ MockDriver
constructor
A new instance of MockDriver.
- #load! ⇒ Object
- #new ⇒ Object
- #send_http_request(request) ⇒ Object
Methods inherited from AbstractDriver
load!, #parse_headers, #parse_http_part, #parse_multipart, #parse_multipart_boundary
Constructor Details
#initialize(mock) ⇒ MockDriver
Returns a new instance of MockDriver.
18 19 20 21 |
# File 'lib/handsoap/http/drivers/mock_driver.rb', line 18 def initialize(mock) @mock = mock @is_loaded = false end |
Instance Attribute Details
#is_loaded ⇒ Object
Returns the value of attribute is_loaded.
16 17 18 |
# File 'lib/handsoap/http/drivers/mock_driver.rb', line 16 def is_loaded @is_loaded end |
#last_request ⇒ Object
Returns the value of attribute last_request.
16 17 18 |
# File 'lib/handsoap/http/drivers/mock_driver.rb', line 16 def last_request @last_request end |
#mock ⇒ Object
Returns the value of attribute mock.
16 17 18 |
# File 'lib/handsoap/http/drivers/mock_driver.rb', line 16 def mock @mock end |
Instance Method Details
#load! ⇒ Object
23 24 25 |
# File 'lib/handsoap/http/drivers/mock_driver.rb', line 23 def load! is_loaded = true end |
#new ⇒ Object
27 28 29 |
# File 'lib/handsoap/http/drivers/mock_driver.rb', line 27 def new self end |
#send_http_request(request) ⇒ Object
31 32 33 34 35 |
# File 'lib/handsoap/http/drivers/mock_driver.rb', line 31 def send_http_request(request) @last_request = request (mock.kind_of? Hash) ? parse_http_part(mock[:headers], mock[:content], mock[:status], mock[:content_type]) : mock end |