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)
-
- (Object) is_loaded
Returns the value of attribute is_loaded.
-
- (Object) last_request
Returns the value of attribute last_request.
-
- (Object) mock
Returns the value of attribute mock.
Instance Method Summary (collapse)
-
- (MockDriver) initialize(mock)
constructor
A new instance of MockDriver.
- - (Object) load!
- - (Object) new
- - (Object) send_http_request(request)
Methods inherited from AbstractDriver
load!, #parse_headers, #parse_http_part, #parse_multipart, #parse_multipart_boundary
Constructor Details
- (MockDriver) initialize(mock)
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
- (Object) is_loaded
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 |
- (Object) last_request
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 |
- (Object) mock
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
- (Object) load!
23 24 25 |
# File 'lib/handsoap/http/drivers/mock_driver.rb', line 23 def load! is_loaded = true end |
- (Object) new
27 28 29 |
# File 'lib/handsoap/http/drivers/mock_driver.rb', line 27 def new self end |
- (Object) send_http_request(request)
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 |