/
mark2_spec.rb
47 lines (36 loc) · 1.17 KB
/
mark2_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
require 'mark2'
require 'mark1'
describe Mark2 do
context 'encoding' do
it 'encodes abc to STU' do
Mark2.new(2,5).encode('abc').should == 'STU'
end
it 'is equivalent when going forwards 6 and backwards 3*2' do
Mark2.new(6,3).encode('abc').should == 'abc'
end
it 'successfully loops round both ways' do
Mark2.new(8,5).encode('.,?!').should == 'yz.,'
end
it 'includes spaces' do
Mark2.new(2,1).encode('test with spaces').should == 'test with spaces'
end
it 'can be functionally equivalent to a Mark1' do
message = "whatever you like, it doesn't actually matter"
Mark2.new(8,2).encode(message).should == Mark1.new(4).encode(message)
end
end
context 'decoding' do
it 'decodes STU to abc' do
Mark2.new(2,5).decode('STU').should == 'abc'
end
it 'is equivalent when going forwards 3*2 and backwards 6' do
Mark2.new(6,3).decode('abc').should == 'abc'
end
it 'successfully loops round both ways' do
Mark2.new(8,5).decode('yz.,').should == '.,?!'
end
it 'includes spaces' do
Mark2.new(2,1).encode('test with spaces').should == 'test with spaces'
end
end
end