I'm trying to write a test to make sure existing users can't register (Using Cucumber, Watir-Webdriver and Page Objects)
I have the following code:
text_field(:email, :id => "user_email")
text_field(:password, :id => "user_password")
text_field(:password_confirmation, :id => "user_password_confirmation")
checkbox(:terms_privacy, :id => "user_accepts_terms")
button(:sign_up_button, :text => "Sign Up")
def unique_username
@username = "qa_automation"+"#{rand(6 ** 6)}"+"@gmail.com"
end
def sign_up
unique_username
self.email = @username
self.password = USERS['PASSWORD']
self.password_confirmation = USERS['PASSWORD']
self.check_terms_privacy
self.sign_up_button
puts "username: #{@username}"
@existing = @username
end
def sign_up_with_existing_account
puts "exisiting username: #{@existing}"
self.email = @exisiting
self.password = USERS['PASSWORD']
self.password_confirmation = USERS['PASSWORD']
self.check_terms_privacy
self.sign_up_button
puts "username: #{@existing}"
end
But the @existing variable is returning nothing. These two lines are giving me back nothing:
puts "exisiting username: #{@existing}"
self.email = @exisiting
So I guess I'm trying to figure out how to pass the @existing variable from the 'sign_up' method to the 'sign_up_with_existing_account' method? Thoughts?