-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtest_testrocket.rb
More file actions
66 lines (55 loc) · 1.68 KB
/
test_testrocket.rb
File metadata and controls
66 lines (55 loc) · 1.68 KB
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
require_relative 'helper'
class RefinementTest
using TestRocket
def self.test!
describe TestRocket do
it 'finds emptiness non-truthful by default' do
(+->{}).must_match(/FAIL/)
(+->{}).must_match("#{__FILE__}:#{__LINE__}")
end
it 'passes a simple positive assertion' do
(+->{ 2 + 2 == 4 }).must_match(/OK/)
end
it 'passes a simple negative assertion' do
(-->{ 2 + 2 == 5 }).must_match(/OK/)
end
it 'fails a simple erroneous assertion' do
(+->{ 2 + 2 == 5 }).must_match(/FAIL/)
(+->{ 2 + 2 == 5 }).must_match("#{__FILE__}:#{__LINE__}")
end
it 'fails a simple correct assertion assumed to fail' do
(-->{ 2 + 2 == 4 }).must_match(/FAIL/)
(-->{ 2 + 2 == 4 }).must_match("#{__FILE__}:#{__LINE__}")
end
it 'gives a pending notice' do
(~->{ 'a pending test' }).must_match(/PENDING/)
(~->{ 'a pending test' }).must_match(/a pending test/)
(~->{ 'a pending test' }).must_match("#{__FILE__}:#{__LINE__}")
end
it 'fires a description rocket' do
(!->{ 'a description' }).must_match(/FIRE/)
(!->{ 'a description' }).must_match(/a description/)
end
it 'influences Ruby Proc if TestRocket used explicitly' do
(
ok = ->() { nil }
!ok
).must_match(/FIRE/)
end
end
end
end
class NoRefinementTest
def self.test!
describe 'Without `using TestRocket`' do
it 'does not influence global Ruby scope and other libs' do
(
ok = ->() { nil }
!ok
).must_equal(false)
end
end
end
end
RefinementTest.test!
NoRefinementTest.test!