~singpolyma/sgx-jmp

ref: 4be555de103e992ee7e03feb48b45c1eca917c45 sgx-jmp/test/test_helper.rb -rw-r--r-- 1.0 KiB
4be555deStephen Paul Weber Split logic out into testable objects 1 year, 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# frozen_string_literal: true

require "simplecov"
SimpleCov.start do
	add_filter "/test/"
	enable_coverage :branch
end

require "em_promise"
require "fiber"
require "minitest/autorun"
require "rantly/minitest_extensions"
require "webmock/minitest"
begin
	require "pry-rescue/minitest"
	require "pry-reload"
rescue LoadError
	# Just helpers for dev, no big deal if missing
	nil
end

CONFIG = {
	sgx: "sgx",
	component: {
		jid: "component"
	},
	plans: [
		{
			name: "test_usd",
			currency: :USD
		},
		{
			name: "test_bad_currency",
			currency: :BAD
		}
	],
	braintree: {
		merchant_accounts: {
			USD: "merchant_usd"
		}
	}
}.freeze

BLATHER = Class.new {
	def <<(*); end
}.new.freeze

module Minitest
	class Test
		def self.property(m, &block)
			define_method("test_#{m}") do
				property_of(&block).check { |args| send(m, *args) }
			end
		end

		def self.em(m)
			alias_method "raw_#{m}", m
			define_method(m) do
				EM.run do
					Fiber.new {
						begin
							send("raw_#{m}")
						ensure
							EM.stop
						end
					}.resume
				end
			end
		end
	end
end