Instantly share code, notes, and snippets.
Save keating/50ba6138d3d1ac4334c8 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
describe"Admin see company list"do | |
subject{page} | |
describe"when there are no companies"do | |
beforedo | |
@admin=FactoryGirl.create(:developer_admin) | |
admin_login(@admin) | |
end | |
it"displays an empty company list"do | |
expect(page).tohave_link("New Company") | |
expect(page).tohave_link("View History") | |
within("table#companytable")do | |
expect(page).tohave_selector('thead') | |
expect(page).tohave_selector('tbody tr',maximum:0) | |
end | |
within('table#companytable thead')do | |
expect(page).tohave_text"LOGO" | |
expect(page).tohave_text"NAME" | |
expect(page).tohave_text"USERNAME" | |
expect(page).tohave_text"ACTION" | |
end | |
end | |
end | |
describe"when there are companies"do | |
beforedo | |
@admin=FactoryGirl.create(:admin_with_companies_with_company_user) | |
admin_login(@admin) | |
end | |
it"displays the company list"do | |
expect(page).tohave_link("View History") | |
within("table#companytable")do | |
expect(page).tohave_selector('thead') | |
expect(page).tohave_selector('tbody tr',count:2) | |
end | |
within("table#companytable tbody")do | |
expect(page).tohave_text('company_',count:2) | |
expect(page).tohave_selector('a.btn',text:"Manage",count:2) | |
end | |
end | |
it"can see the company detail in a form",js:truedo | |
visit_company_show_page | |
find("form#admin_form").shouldbe_visible | |
end | |
it"can update the company information",js:true,driver::poltergeistdo | |
visit_company_show_page | |
find("form#admin_form").shouldbe_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_tobe_nil | |
end | |
end | |
end |
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment