require 'spec_helper' feature "Record Desktop" do let(:mac_user_agent_string) { 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36' } let(:windows_user_agent_string) { 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/4.0; InfoPath.2; SV1; .NET CLR 2.0.50727; WOW64)' } let(:linux_user_agent_string) { 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0' } let(:descriptor_file_url) { Applicants::ScreencastOMatic::UrlBuilder.new(@applicant, "www.example.com", Capybara.server_port).descriptor_file_url } scenario "downloading and launching the screen recorder - mac" do page.driver.header("User-Agent", mac_user_agent_string) @applicant = Applicants::Applicant.create(email: 'fake@example.com', terms_of_use: "1") visit download_applicant_path(@applicant) page_should_have_download_link_for_macintosh visit download_applicant_path(@applicant) click_on I18n.t('applicants.pages.download.buttons.continue') page.should have_content I18n.t('applicants.pages.tips.header') page.should have_xpath("//a[@href='#{descriptor_file_url}']") end scenario "downloading and launching the screen recorder - windows" do page.driver.header("User-Agent", windows_user_agent_string) @applicant = Applicants::Applicant.create(email: 'fake@example.com', terms_of_use: "1") visit download_applicant_path(@applicant) page_should_have_download_link_for_windows visit download_applicant_path(@applicant) click_on I18n.t('applicants.pages.download.buttons.continue') page.should have_content I18n.t('applicants.pages.tips.header') page.should have_xpath("//a[@href='#{descriptor_file_url}']") end scenario "downloading and launching the screen recorder - linux or other unknown OS" do page.driver.header("User-Agent", linux_user_agent_string) @applicant = Applicants::Applicant.create(email: 'fake@example.com', terms_of_use: "1") visit download_applicant_path(@applicant) page_should_have_download_links_for_unknown_os visit download_applicant_path(@applicant) click_on I18n.t('applicants.pages.download.buttons.continue') page.should have_content I18n.t('applicants.pages.tips.header') page.should have_xpath("//a[@href='#{descriptor_file_url}']") end end def page_should_have_download_links_for_unknown_os page.should have_content("Download for Windows") page.should have_xpath("//a[@href='http://www.example.com/install-windows-recorder']") page.should have_content("Download for Mac") page.should have_xpath("//a[@href='http://www.example.com/install-mac-recorder']") end def page_should_have_download_link_for_macintosh page.should have_content("Download Screen Recorder") page.should have_xpath("//a[@href='http://www.example.com/install-mac-recorder']") end def page_should_have_download_link_for_windows page.should have_content("Download Screen Recorder") page.should have_xpath("//a[@href='http://www.example.com/install-windows-recorder']") end