Skip to content

Instantly share code, notes, and snippets.

@jwood
Created June 1, 2015 21:42
Show Gist options
  • Save jwood/e51ed37d4fb05e0a3376 to your computer and use it in GitHub Desktop.
Save jwood/e51ed37d4fb05e0a3376 to your computer and use it in GitHub Desktop.
require "rails_helper"
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 the Capybara DSL" do
scenario "user sees all offices in their city, and selects one" do
# Load the page
visit "/company"
# Make sure expected options are displayed
expect(find(".select-office")).to have_content("Please select an Office Location")
expect(find(".select-office")).to have_content(office_1.name)
expect(find(".select-office")).to have_content(office_2.name)
# Select an office
find("#office_#{office_1.id}").click
expect(page.find("#save-office-btn")).to have_content("Show me my office!")
# Save the selection
find("#save-office-btn").click
# Make sure details for the selected office are displayed
expect(find("#office-name")).to have_content(office_1.name)
expect(find(".company-tasks")).to have_content(office_task.name)
expect(find(".company-faqs")).to have_content(office_faq.question)
expect(page).to have_css(".map-block")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment