Skip to content

Instantly share code, notes, and snippets.

@jwood
Created June 1, 2015 21:43
Show Gist options
  • Save jwood/a0071fd55de9052d8986 to your computer and use it in GitHub Desktop.
Save jwood/a0071fd55de9052d8986 to your computer and use it in GitHub Desktop.
require "rails_helper"
class CompanyOfficePage < SitePrism::Page
set_url "/company"
element :select_office, ".select-office"
element :office_name, "#office-name"
element :save_office_button, "#save-office-btn"
element :company_tasks, ".company-tasks"
element :company_faqs, ".company-faqs"
element :map_block, ".map-block"
end
feature "Company/Office page spec", js: true do
let(:company) { FactoryGirl.create(:company) }
let(:employee) { FactoryGirl.create(:employee, full_city: "Chicago, IL", company: company) }
let!(:office_1) { FactoryGirl.create(:office, company: company, address: FactoryGirl.attributes_for(:chicago_address)) }
let!(:office_2) { FactoryGirl.create(:office, company: company, address: FactoryGirl.attributes_for(:chicago_address)) }
let!(:office_task) { FactoryGirl.create(:task, company: company, office: office_1) }
let!(:office_faq) { FactoryGirl.create(:faq, company: company, office: office_1) }
before do
login_employee(employee)
end
describe "with a SitePrism page object" do
let(:company_page) { CompanyOfficePage.new }
scenario "user sees all offices in their city, and selects one" do
# Load the page
company_page.load
# Make sure expected options are displayed
expect(company_page.select_office).to have_content("Please select an Office Location")
expect(company_page.select_office).to have_content(office_1.name)
expect(company_page.select_office).to have_content(office_2.name)
# Select an office
find("#office_#{office_1.id}").click
expect(company_page.save_office_button).to have_content("Show me my office!")
# Save the selection
company_page.save_office_button.click
# Make sure details for the selected office are displayed
expect(company_page.office_name).to have_text(office_1.name)
expect(company_page.company_tasks).to have_content(office_task.name)
expect(company_page.company_faqs).to have_content(office_faq.question)
expect(company_page).to have_map_block
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment