Last active
August 29, 2015 14:20
-
-
Save psahni/6228393df770e56bfd3b to your computer and use it in GitHub Desktop.
test to sign up and deleting the user
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
require 'capybara' | |
require 'capybara/angular' | |
require 'active_record' | |
require 'pg' | |
class ContactServiceTesting | |
include Capybara::DSL | |
include Capybara::Angular::DSL | |
def initialize | |
Capybara.default_driver = :selenium | |
Capybara.default_wait_time = 2 | |
Capybara::Angular.default_wait_time = 10 | |
end | |
def signup | |
link = 'http://localhost:3000/signup' | |
visit link | |
create_user | |
delete_user | |
end | |
def create_user | |
within('#signup_form') do | |
fill_in "email", :with => "[email protected]" | |
fill_in "password", :with => "sazabcqwer" | |
fill_in "password_confirmation", :with => 'sazabcqwer' | |
find_button("Register").click | |
end | |
end | |
def connection | |
@connection||=ActiveRecord::Base.establish_connection( | |
adapter: 'postgresql', | |
host: 'localhost', | |
database: 'contact_service_development', | |
username: 'postgres', | |
password: 'postgres' | |
) | |
end | |
def delete_user | |
connection.connection.execute("DELETE FROM users WHERE email='[email protected]'") | |
end | |
end | |
ContactServiceTesting.new.signup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment