Sha256: 9d4575dc9f1c9dfbf35a673920928b0a9e918c4f96f9f75cf5bb7f89c43e4731

Contents?: true

Size: 1010 Bytes

Versions: 5

Compression:

Stored size: 1010 Bytes

Contents

require 'stripe'
require 'test/unit'
require 'mocha/setup'
require 'stringio'
require 'shoulda'
require File.expand_path('../test_data', __FILE__)

# monkeypatch request methods
module Stripe
  @mock_rest_client = nil

  def self.mock_rest_client=(mock_client)
    @mock_rest_client = mock_client
  end

  class << self
    remove_method :execute_request
  end

  def self.execute_request(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 :delete then @mock_rest_client.delete opts[:url], get_params, post_params
    end
  end
end

class Test::Unit::TestCase
  include Stripe::TestData
  include Mocha

  setup do
    @mock = mock
    Stripe.mock_rest_client = @mock
    Stripe.api_key = "foo"
  end

  teardown do
    Stripe.mock_rest_client = nil
    Stripe.api_key = nil
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stripe-1.44.0 test/test_helper.rb
stripe-1.43.1 test/test_helper.rb
stripe-1.43.0 test/test_helper.rb
stripe-1.42.0 test/test_helper.rb
stripe-1.41.0 test/test_helper.rb