Skip to content

Instantly share code, notes, and snippets.

@keating
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keating/50ba6138d3d1ac4334c8 to your computer and use it in GitHub Desktop.
Save keating/50ba6138d3d1ac4334c8 to your computer and use it in GitHub Desktop.
describe "Admin see company list" do
subject {page}
describe "when there are no companies" do
before do
@admin = FactoryGirl.create(:developer_admin)
admin_login(@admin)
end
it "displays an empty company list" do
expect(page).to have_link("New Company")
expect(page).to have_link("View History")
within("table#companytable") do
expect(page).to have_selector('thead')
expect(page).to have_selector('tbody tr', maximum: 0)
end
within('table#companytable thead') do
expect(page).to have_text "LOGO"
expect(page).to have_text "NAME"
expect(page).to have_text "USERNAME"
expect(page).to have_text "ACTION"
end
end
end
describe "when there are companies" do
before do
@admin = FactoryGirl.create(:admin_with_companies_with_company_user)
admin_login(@admin)
end
it "displays the company list" do
expect(page).to have_link("View History")
within("table#companytable") do
expect(page).to have_selector('thead')
expect(page).to have_selector('tbody tr', count: 2)
end
within("table#companytable tbody") do
expect(page).to have_text('company_', count: 2)
expect(page).to have_selector('a.btn', text: "Manage", count: 2)
end
end
it "can see the company detail in a form", js: true do
visit_company_show_page
find("form#admin_form").should be_visible
end
it "can update the company information", js: true, driver: :poltergeist do
visit_company_show_page
find("form#admin_form").should be_visible
fill_in "company_name", with: "AnotherName"
fill_in "company_email", with: "email@example.com"
fill_in "company_password", with: "password"
find("input[value=Update]").click
expect(Company.where(name: "AnotherName").first).not_to be_nil
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment