forked from javan/whenever
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_case.rb
39 lines (36 loc) · 810 Bytes
/
test_case.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
module Whenever
begin
require 'minitest/autorun'
begin
# 2.0.0
class TestCase < MiniTest::Test; end
rescue NameError
# 1.9.3
class TestCase < MiniTest::Unit::TestCase; end
end
rescue LoadError
# 1.8.7
require 'test/unit'
class TestCase < Test::Unit::TestCase
def default_test; end
end
end
class TestCase
class << self
def setup(&block)
define_method(:setup) do
super()
instance_eval(&block)
end
end
def test(name, &block)
define_method("test_#{name}".to_sym, &block)
end
alias should test
end
def assert_no_match(regexp, string)
message = "<#{regexp}> expected to not match\n<#{string}>"
assert regexp !~ string, message
end
end
end