Created
March 18, 2014 16:03
-
-
Save linko/9623110 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe 'Sponsorships' do | |
include Warden::Test::Helpers | |
describe 'Sponsorships Application form', :js do | |
let(:proposal) { Faker::Lorem.paragraphs(20).join('.') } | |
it 'fills out the form and submit' do | |
SiteOption.find_or_create_by_name_and_value('public', 'true') | |
visit sponsorships_path | |
select 'Athlete', from: 'menu_select' | |
click_on 'Start Now' | |
fill_in 'sponsorship_first_name', with: 'Bruce' | |
fill_in 'sponsorship_last_name', with: 'Wayne' | |
fill_in 'sponsorship_bdf_email', with: '[email protected]' | |
fill_in 'sponsorship_bdf_phone', with: '111-222-333' | |
fill_in 'sponsorship_bdf_streetaddress', with: 'secret address' | |
fill_in 'sponsorship_bdf_city', with: 'Gotham' | |
fill_in 'sponsorship_bdf_zip', with: '12345' | |
fill_in 'sponsorship_gpr_busd_dob', with: '05/05/90' | |
select 'United States', from: 'sponsorship_bdf_country' | |
select 'Alabama', from: 'sponsorship_bdf_state_display' | |
click_link 'basic-info-btn' | |
wait_for_animation_to_complete('#collapseTwo') | |
fill_in 'sponsorship_teamname', with: 'Batman and Robin' | |
fill_in 'sponsorship_schoolname', with: 'Gotham university' | |
fill_in 'sponsorship_yearsparticipating', with: '1990' | |
fill_in 'sponsorship_othersponsors', with: 'Some text' | |
select 'Skate', from: 'sponsorship_sportname' | |
select 'Locally', from: 'sponsorship_bdf_competelevel' | |
click_link 'sport-info-btn' | |
wait_for_animation_to_complete('#collapseThree') | |
fill_in 'sponsorship_bdf_fblink', with: 'http://facebook.com/batman' | |
fill_in 'sponsorship_bdf_fbfollowers', with: '233' | |
fill_in 'sponsorship_bdf_twitter', with: 'http://twitter.com/batman' | |
fill_in 'sponsorship_bdf_twitterfollowers' , with: '322' | |
fill_in 'sponsorship_bdf_instragram', with: 'http://instagram.com/batman' | |
fill_in 'sponsorship_bdf_instragramfollowers', with: '144' | |
fill_in 'sponsorship_bdf_youtube', with: 'http://youtube.com/batman' | |
fill_in 'sponsorship_bdf_youtubesubscriber', with: '566' | |
fill_in 'sponsorship_bdf_youtubeviews', with: '3000000' | |
fill_in 'sponsorship_bdf_vimeo', with: 'http://vimeo.com/32554444' | |
fill_in 'sponsorship_website', with: 'http://batman.com' | |
fill_in 'sponsorship_bdf_blog', with: 'http://blog.batman.com' | |
click_link 'social-media-btn' | |
wait_for_animation_to_complete('#collapseFour') | |
fill_in 'sponsorship_bdf_proposal', with: proposal | |
attach_file 'sponsorship_attachproposal', "#{Rails.root}/spec/factories/pdfs/sample_press_release.pdf" | |
click_on 'submit_btn' | |
find('#confirmation h3').should have_content 'Your Athlete/Team Sponsorship Application has successfully been submitted!' | |
click_on 'Print This Application' | |
find('#sponsorships h2').should have_content 'Athlete/Team Sponsorship Application' | |
within '#collapseOne' do | |
page.should have_content 'Bruce Wayne' | |
page.should have_content '[email protected]' | |
page.should have_content '111-222-333' | |
page.should have_content 'secret address' | |
page.should have_content 'Gotham' | |
page.should have_content '12345' | |
page.should have_content '1990-05-05' | |
page.should have_content 'United States' | |
page.should have_content 'Alabama' | |
end | |
within '#collapseTwo' do | |
page.should have_content 'Batman and Robin' | |
page.should have_content 'Gotham university' | |
page.should have_content '1990' | |
page.should have_content 'Some text' | |
page.should have_content 'Skate' | |
page.should have_content 'Locally' | |
end | |
within '#collapseThree' do | |
page.should have_content 'http://facebook.com/batman' | |
page.should have_content '233' | |
page.should have_content 'http://twitter.com/batman' | |
page.should have_content '322' | |
page.should have_content 'http://instagram.com/batman' | |
page.should have_content '144' | |
page.should have_content 'http://youtube.com/batman' | |
page.should have_content '566' | |
page.should have_content '3000000' | |
page.should have_content 'http://vimeo.com/32554444' | |
page.should have_content 'http://batman.com' | |
page.should have_content 'http://blog.batman.com' | |
end | |
end | |
end | |
describe 'Athlete birthdate format' do | |
specify do | |
visit athlete_sponsorships_path | |
fill_in 'Birthdate', with: '10/11/89' | |
click_button 'Submit Application' | |
find_field('Birthdate').value.should == '10/11/89' | |
end | |
end | |
describe 'Words counter & progressbar', :js do | |
def blur | |
click_link 'Basic Information' | |
click_link 'Sponsorship Proposal' | |
end | |
specify do | |
visit athlete_sponsorships_path | |
click_link 'Sponsorship Proposal' | |
page.should have_field 'sponsorship_bdf_proposal' | |
page.should have_content 'Current word count: 0' | |
page.should have_content '0% Complete' | |
fill_in 'sponsorship_bdf_proposal', with: '2 words' | |
page.should have_content 'Current word count: 2' | |
blur | |
page.should have_content '0% Complete' | |
fill_in 'sponsorship_bdf_proposal', with: (%w(word) * 200).join(' ') | |
page.should have_content 'Current word count: 200' | |
blur | |
page.should have_no_content '0% Complete' | |
end | |
end | |
end | |
def wait_for_animation_to_complete(selector, wait_time=5) | |
find(selector).synchronize(wait_time) do | |
result = page.evaluate_script("$('#{selector}').prop('style').height == 'auto'") | |
#save_screenshot("#{Rails.root}/screentshots/#{Time.now.to_i}.png") | |
raise Capybara::ElementNotFound.new("Too long to wait for '#{selector}' to be visible") unless result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment