-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathhelper.rb
55 lines (49 loc) · 1.08 KB
/
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
require 'rubygems'
require 'test-unit'
require 'uri'
require 'http/cookie'
module Test
module Unit
module Assertions
def assert_warn(pattern, message = nil, &block)
class << (output = "")
alias write <<
end
stderr, $stderr = $stderr, output
yield
assert_match(pattern, output, message)
ensure
$stderr = stderr
end
def assert_warning(pattern, message = nil, &block)
verbose, $VERBOSE = $VERBOSE, true
assert_warn(pattern, message, &block)
ensure
$VERBOSE = verbose
end
end
end
end
module Enumerable
def combine
masks = inject([[], 1]){|(ar, m), e| [ar << m, m << 1 ] }[0]
all = masks.inject(0){ |al, m| al|m }
result = []
for i in 1..all do
tmp = []
each_with_index do |e, idx|
tmp << e unless (masks[idx] & i) == 0
end
result << tmp
end
result
end
end
def test_file(filename)
File.expand_path(filename, File.dirname(__FILE__))
end
def sleep_until(time)
if (s = time - Time.now) > 0
sleep s
end
end