Skip to content

Instantly share code, notes, and snippets.

@shageman
Forked from mainej/sign_up_page.rb
Created January 5, 2012 02:01
Show Gist options
  • Save shageman/1563299 to your computer and use it in GitHub Desktop.
Save shageman/1563299 to your computer and use it in GitHub Desktop.
class SignUpPage
def initialize
current_path.should == sign_up_path
end
def with_email(email)
fill_in "Login", :with => email
end
def with_password(password, confirmation = password)
fill_in "Password", :with => password
fill_in "Please re-type your password", :with => confirmation
end
def sign_up_as(email, password)
with_email(email)
with_password(password)
submit_successfully
end
def submit_successfully
click_link "Sign Up"
return TOSPage.new
end
def submit_unsuccessfully
click_link "Sign Up"
return SignUpPage.new
end
end
class TOSPage
def initialize
current_path.should == terms_path
end
def agree_to_terms
check "Agree"
end
def submit
click_link 'Continue'
return EditProfilePage.new
end
end
class UrlBar
def go_to_sign_up
visit sign_up_path
return SignUpPage.new
end
def at_edit_profile_page?
current_path == edit_profile_path
end
end
describe "sign-up workflow" do
context 'with valid credentials and TOS acceptance' do
it 'should take you to the edit profile page' do
url = UrlBar.new
sign_up = url_bar.go_to_sign_up
sign_up.with_email("[email protected]")
sign_up.with_password("password")
tos = sign_up.submit_successfully
tos.agree_to_terms
tos.submit
url.should be_at_edit_profile_page
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment