-
Notifications
You must be signed in to change notification settings - Fork 0
/
interviewcake-spec.rb
54 lines (46 loc) · 1.24 KB
/
interviewcake-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
require './interviewcake'
describe 'Array' do
describe '#my_reverse' do
it 'should take an array of characters and reverse them' do
expect(["s", "a", "r", "a", "h"].my_reverse).to eq(["h", "a", "r", "a", "s"])
end
it 'should take an array of characters and reverse them' do
expect(["s", "a", "r", "a"].my_reverse).to eq(["a", "r", "a", "s"])
end
end
end
describe 'Stack' do
describe '#get_largest' do
stack = Stack.new(0)
stack.add(3)
stack.add(2)
stack.add(4)
stack.add(1)
it 'should return the largest element in the stack' do
expect(stack.get_largest).to eq 4
end
it 'should return the largest element in the stack even when something is removed' do
stack.remove
stack.remove
expect(stack.get_largest).to eq 3
end
end
end
describe 'Queue' do
queue = Queue.new(1)
describe '#enqueue' do
it 'should add something to the queue' do
expect(queue.enqueue(5)).to eq 5
end
end
queue.enqueue(4)
queue.enqueue(14)
describe '#dequeue' do
it 'should remove the oldest thing from the queue' do
expect(queue.dequeue).to eq 1
end
it 'should remove the oldest thing from the queue' do
expect(queue.dequeue).to eq 5
end
end
end