Class: Handsoap::Http::HttpMock

Inherits:
Object
  • Object
show all
Defined in:
lib/handsoap/http.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::HttpMock.new :status => 200, :headers => headers, :content => body
Handsoap.http_driver = :mock

Remember that headers should use rn, rather than n.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (HttpMock) initialize(mock)

Returns a new instance of HttpMock



283
284
285
286
# File 'lib/handsoap/http.rb', line 283

def initialize(mock)
  @mock = mock
  @is_loaded = false
end

Instance Attribute Details

- (Object) is_loaded

Returns the value of attribute is_loaded



282
283
284
# File 'lib/handsoap/http.rb', line 282

def is_loaded
  @is_loaded
end

- (Object) last_request

Returns the value of attribute last_request



282
283
284
# File 'lib/handsoap/http.rb', line 282

def last_request
  @last_request
end

- (Object) mock

Returns the value of attribute mock



282
283
284
# File 'lib/handsoap/http.rb', line 282

def mock
  @mock
end

Instance Method Details

- (Object) load!



287
288
289
# File 'lib/handsoap/http.rb', line 287

def load!
  is_loaded = true
end

- (Object) send_http_request(request)



290
291
292
293
# File 'lib/handsoap/http.rb', line 290

def send_http_request(request)
  @last_request = request
  Handsoap::Http.parse_http_part(mock[:headers], mock[:content], mock[:status], mock[:content_type])
end