forked from zkan/bugday_2013_rspec_rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Registration Page Spec
roofimon edited this page Mar 24, 2013
·
3 revisions
- git checkout -b registration_page
describe 'try to register' do
before { visit '/registrants/new' }
describe 'with blank form' do
before { click_button 'Register'}
it{ should have_selector 'title', text: 'Agile Singapore 2013'}
it{ should have_content 'Registration Form' }
end
describe 'with invalid information' do
let(:invalid_email_registrant) {FactoryGirl.create(:registrant)}
before do
fill_in 'registrant_email', with: 'invalid.email.com'
fill_in 'registrant_first_name', with: invalid_email_registrant.first_name
fill_in 'registrant_last_name', with: invalid_email_registrant.last_name
fill_in 'registrant_company', with: invalid_email_registrant.company
fill_in 'registrant_phone', with: invalid_email_registrant.phone
click_button 'Register'
end
it{ should have_content 'The form contains 1 error' }
it{ should have_content 'Email is invalid' }
end
describe 'with valid information' do
before do
fill_in 'registrant_email', with: '[email protected]'
fill_in 'registrant_first_name', with: 'Arin'
fill_in 'registrant_last_name', with: 'Khemngoen'
fill_in 'registrant_company', with: 'Odd-e Global'
fill_in 'registrant_phone', with: '+66839093993'
end
it 'should create new registrant' do
expect {click_button 'Register'}.to change(Registrant, :count).by(1)
should have_content 'Successfully Registered'
end
it 'should' do
click_button 'Register'
ActionMailer::Base.deliveries.last.to.should == ['[email protected]']
end
end
<% if @registrant.errors.any? %>
<div id="error_explanation">
<div class="alert alert-error">
<button type="button" class="close" data-dismiss="alert">×</button>
<h4>The form contains <%= pluralize(@registrant.errors.count, "error") %>.</h4>
<ul>
<% @registrant.errors.full_messages.each do |msg| %>
<%= msg %><br>
<% end %>
</ul>
</div>
</div>
<% end %>