Sha256: 93a941b5acaf2d441e4eed47dfcba68e8c72bd6d4d351a45d495bf4e70525b15

Contents?: true

Size: 1.08 KB

Versions: 17

Compression:

Stored size: 1.08 KB

Contents

# -*- coding: utf-8 -*-
require 'handsoap/http/drivers/abstract_driver'

module Handsoap
  module Http
    module Drivers
      # 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 \r\n, rather than \n.
      class MockDriver < AbstractDriver
        attr_accessor :mock, :last_request, :is_loaded

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

        def load!
          is_loaded = true
        end

        def new
          self
        end

        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
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
handsoap-1.4.0 lib/handsoap/http/drivers/mock_driver.rb
handsoap-1.3.0 lib/handsoap/http/drivers/mock_driver.rb
handsoap-1.2.2 lib/handsoap/http/drivers/mock_driver.rb
handsoap-1.1.8 lib/handsoap/http/drivers/mock_driver.rb
handsoap-1.1.7 lib/handsoap/http/drivers/mock_driver.rb
pgericson-handsoap-1.1.10 lib/handsoap/http/drivers/mock_driver.rb
pgericson-handsoap-1.1.9 lib/handsoap/http/drivers/mock_driver.rb
pgericson-handsoap-1.1.8 lib/handsoap/http/drivers/mock_driver.rb
pgericson-handsoap-1.1.7 lib/handsoap/http/drivers/mock_driver.rb
handsoap-1.1.6 lib/handsoap/http/drivers/mock_driver.rb
handsoap-1.1.5 lib/handsoap/http/drivers/mock_driver.rb
whenyouneedme-handsoap-1.1.4 lib/handsoap/http/drivers/mock_driver.rb
handsoap-1.1.4 lib/handsoap/http/drivers/mock_driver.rb
handsoap-1.1.3 lib/handsoap/http/drivers/mock_driver.rb
handsoap-1.1.2 lib/handsoap/http/drivers/mock_driver.rb
handsoap-1.1.1 lib/handsoap/http/drivers/mock_driver.rb
handsoap-1.1.0 lib/handsoap/http/drivers/mock_driver.rb