Sha256: 0d69920fe28f203e3d96a2adf2945762ed32034844421179bf14d2d87c47c8ae

Contents?: true

Size: 856 Bytes

Versions: 4

Compression:

Stored size: 856 Bytes

Contents

module CiviCrm
  class Client
    class << self
      @mock_rest_client = nil
      def mock_rest_client(mock_client)
        @mock_rest_client = mock_client
      end

      alias_method :execute!, :execute
      def execute(opts)
        get_params = (opts[:headers] || {})[:params]
        post_params = opts[:payload]
        case opts[:method]
        when :get then @mock_rest_client.get opts[:url], get_params, post_params
        when :post then @mock_rest_client.post opts[:url], get_params, post_params
        when :put then @mock_rest_client.put opts[:url], get_params, post_params
        when :delete then @mock_rest_client.delete opts[:url], get_params, post_params
        end
      end
    end
  end
end
def authorized_civicrm_client
  CiviCrm.api_key = 'civicrm'
  CiviCrm.site_key = 'civicrm'
  CiviCrm::Client.mock_rest_client(mock)
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
civicrm-1.0.5 spec/support/civicrm.rb
civicrm-1.0.4 spec/support/civicrm.rb
civicrm-1.0.2 spec/support/civicrm.rb
civicrm-1.0.1 spec/support/civicrm.rb