-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_spec.rb
93 lines (73 loc) · 1.6 KB
/
test_spec.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
84
85
86
87
88
89
90
91
92
93
describe 'Simple Tests that have nothing to do with the app' do
it 'can do basic math' do
expect(4 + 2).to eq 6
end
it 'can have negative expectations' do
expect(1 + 7).not_to eq 9
end
describe 'setup' do
before :each do
@sum = 1 + 2 + 3 + 4
end
it 'has the sum of 10' do
expect(@sum).to eq 10
end
it 'can be multiplied' do
expect(@sum * 10).to be <= 200
end
end
describe 'memoization' do
let(:sum) { 1 + 2 + 3 + 4}
it 'hast the sum of 10' do
expect(sum).to eq 10
end
it 'does not execute sum when not called' do
expect(nil).to be_nil
end
end
describe 'matchers' do
it 'can compare things' do
expect(100).to be >= 90
end
end
describe 'equality' do
it 'is equal if it has the same values' do
expect('hello').to eq 'hello'
end
it 'is not identical if it has the same values' do
expect('hello').not_to be 'hello'
end
end
describe 'fancy boolean matchers' do
class RubyCorn
def awesome?
true
end
def xzyubt?
true
end
end
it 'is an awesome rubycorn' do
expect(RubyCorn.new).to be_awesome
expect(RubyCorn.new).to be_xzyubt
end
it 'reflection' do
expect(2.even?).to be_truthy
expect(2.even?).to eq true
expect(2).to be_even
end
end
describe '===' do
it 'Tobi knows nothing' do
input = 'asdhasdash'
case input
when 3, 4, 5
puts 'nummbbbaaa'
when Integer
puts 'success'
else
puts 'moap moap moap'
end
end
end
end