From 9d3cee906330cbbe2dbd1bd4dcb88aa7c160baca Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 16 Aug 2016 21:54:30 +0200 Subject: Determine if registrations are open or not from config. --- spec/registration_spec.rb | 48 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) (limited to 'spec') diff --git a/spec/registration_spec.rb b/spec/registration_spec.rb index 8d04d89..387a445 100644 --- a/spec/registration_spec.rb +++ b/spec/registration_spec.rb @@ -9,22 +9,46 @@ describe RegistrationApp do end describe 'GET index' do - before :each do - get '/' - end + context 'when registration is open' do + before :each do + app.set :accept_registrations, { + start: Date.today.iso8601, + stop: (Date.today + 1).iso8601 + } + get '/' + end - it 'should succeed' do - expect(last_response).to be_ok - end + it 'should succeed' do + expect(last_response).to be_ok + end + + it 'displays the registration form' do + expect(last_response.body).to match(/form id="registration-form"/) + end - it 'displays the registration form' do - expect(last_response.body).to match(/form id="registration-form"/) + it 'allows three songs' do + expect(last_response.body).to match(/Låt nr. 1/) + expect(last_response.body).to match(/Låt nr. 2/) + expect(last_response.body).to match(/Låt nr. 3/) + end end - it 'allows three songs' do - expect(last_response.body).to match(/Låt nr. 1/) - expect(last_response.body).to match(/Låt nr. 2/) - expect(last_response.body).to match(/Låt nr. 3/) + context 'when registration is closed' do + before :each do + app.set :accept_registrations, { + start: (Date.today + 1).iso8601, + stop: (Date.today + 30).iso8601 + } + get '/' + end + + it 'should succeed' do + expect(last_response).to be_ok + end + + it 'displays message that registration is closed' do + expect(last_response.body).to match(/Registreringen er stengt/) + end end end -- cgit v1.2.3