diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/registration_spec.rb | 48 |
1 files changed, 36 insertions, 12 deletions
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 |