/
base_test_helper.rb
83 lines (71 loc) · 2.28 KB
/
base_test_helper.rb
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
72
73
74
75
76
77
78
79
80
81
82
83
require 'rubygems' if RUBY_PLATFORM == 'java'
begin
require 'simplecov'
SimpleCov.start do
add_filter '/test/'
end
rescue LoadError
end
begin
require 'coveralls'
Coveralls.wear!
rescue LoadError
end
require 'minitest/autorun'
require 'rr'
require 'gir_ffi-base'
require 'ffi-gobject_introspection'
GObjectIntrospection::IRepository.prepend_search_path File.join(File.dirname(__FILE__), 'lib')
module GObjectIntrospection
class IRepository
def shared_library_with_regress namespace
case namespace
when 'Regress'
return File.join(File.dirname(__FILE__), 'lib', 'libregress.so')
when 'GIMarshallingTests'
return File.join(File.dirname(__FILE__), 'lib', 'libgimarshallingtests.so')
else
return shared_library_without_regress namespace
end
end
alias_method :shared_library_without_regress, :shared_library
alias_method :shared_library, :shared_library_with_regress
end
end
Thread.abort_on_exception = true
class Minitest::Test
def assert_defines_singleton_method klass, method, msg = nil
method = method.to_sym
methods = klass.singleton_methods(false).map(&:to_sym)
msg = message(msg) {
"Expected #{mu_pp(klass)} to define singleton method #{mu_pp(method)}, " \
"but only found #{mu_pp(methods)}"
}
assert_includes methods, method, msg
end
def refute_defines_singleton_method klass, method, msg = nil
method = method.to_sym
methods = klass.singleton_methods(false).map(&:to_sym)
msg = message(msg) {
"Expected #{mu_pp(klass)} not to define singleton method #{mu_pp(method)}"
}
refute_includes methods, method, msg
end
def assert_defines_instance_method klass, method, msg = nil
method = method.to_sym
methods = klass.instance_methods(false).map(&:to_sym)
msg = message(msg) {
"Expected #{mu_pp(klass)} to define instance method #{mu_pp(method)}, " \
"but only found #{mu_pp(methods)}"
}
assert_includes methods, method, msg
end
def refute_defines_instance_method klass, method, msg = nil
method = method.to_sym
methods = klass.instance_methods(false).map(&:to_sym)
msg = message(msg) {
"Expected #{mu_pp(klass)} not to define instance method #{mu_pp(method)}"
}
refute_includes methods, method, msg
end
end