-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathterminal_sunday_spec.rb
More file actions
40 lines (31 loc) · 842 Bytes
/
Copy pathterminal_sunday_spec.rb
File metadata and controls
40 lines (31 loc) · 842 Bytes
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
require 'date'
def script_output
`ruby ./terminal_sunday.rb #{birthdate}`
end
RSpec.describe 'Terminal Sunday' do
before do
allow(Date).to receive(:today).and_return Date.new(2024, 1, 3)
end
let(:birthdate) { '1985-06-08' }
it 'calculates remaining Sundays correctly' do
expect(script_output).to include('2148')
end
it 'shows birth year' do
expect(script_output).to include('1985')
end
it 'shows the last year' do
expect(script_output).to include('2064')
end
describe 'handles incorrect number of args' do
it do
script_output = `ruby ./terminal_sunday.rb`
expect(script_output).to include('Usage: ')
end
end
describe 'handles invalid date format' do
let(:birthdate) { '1985' }
it do
expect(script_output).to include('Invalid date format')
end
end
end