-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01b773a
commit 059c98d
Showing
1 changed file
with
26 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,62 @@ | ||
require "rails_helper" | ||
|
||
RSpec.feature "Visitor signs up", type: :feature do | ||
scenario "by navigating to the page" do | ||
visit new_user_session_path | ||
|
||
click_link 'Join' | ||
|
||
expect(page).to have_current_path new_user_registration_path, ignore_query: true | ||
end | ||
|
||
scenario "with valid email and password" do | ||
sign_up_with "[email protected]", "password" | ||
|
||
expect(page).to have_content 'A message with a confirmation link has been sent to your email address.' | ||
expect(page).not_to have_link('Sign out') | ||
|
||
user = User.find_by email: "[email protected]" | ||
expect(user).to be_present | ||
expect(user).not_to be_confirmed | ||
expect(user.memberships.count).to be_zero | ||
verify_user_presence("[email protected]") | ||
verify_user_not_confirmed("[email protected]") | ||
end | ||
|
||
scenario "tries with invalid email" do | ||
sign_up_with "invalid_email", "password" | ||
|
||
expect_user_not_to_be_registered | ||
end | ||
|
||
scenario "tries with blank password" do | ||
sign_up_with "[email protected]", "" | ||
|
||
expect_user_not_to_be_registered | ||
end | ||
|
||
scenario "as a bot" do | ||
visit new_user_registration_path | ||
|
||
fill_in "Email", with: "[email protected]" | ||
fill_in "Password", with: "password" | ||
fill_in "Confirm Password", with: "password" | ||
fill_in "Full Name", with: 'Jane Doe' | ||
fill_in "Postal Address", with: '1 High Street' | ||
|
||
check "Rails Camp" | ||
|
||
fill_in "Ruby?", with: "Random bot generated string" | ||
|
||
click_button 'Register' | ||
|
||
scenario "as a user" do | ||
simulate_registration | ||
expect_user_not_to_be_registered | ||
expect(User.count).to be_zero | ||
end | ||
|
||
def sign_up_with(email, password) | ||
visit new_user_registration_path | ||
|
||
fill_in "Email", with: email | ||
fill_in "Password", with: password | ||
fill_in "Confirm Password", with: password | ||
fill_in "Full Name", with: 'Jane Doe' | ||
fill_in "Postal Address", with: '1 High Street' | ||
|
||
check "Rails Camp" | ||
|
||
fill_in "Ruby?", with: "Ruby" | ||
click_button 'Register' | ||
end | ||
|
||
def verify_user_presence(email) | ||
user = User.find_by(email: email) | ||
expect(user).to be_present | ||
end | ||
|
||
def verify_user_not_confirmed(email) | ||
user = User.find_by(email: email) | ||
expect(user).not_to be_confirmed | ||
expect(user.memberships.count).to be_zero | ||
end | ||
|
||
def simulate_registration | ||
visit new_user_registration_path | ||
fill_in "Email", with: "[email protected]" | ||
fill_in "Password", with: "password" | ||
fill_in "Confirm Password", with: "password" | ||
fill_in "Full Name", with: 'Jane Doe' | ||
fill_in "Postal Address", with: '1 High Street' | ||
check "Rails Camp" | ||
fill_in "Ruby?", with: "Random bot generated string" | ||
click_button 'Register' | ||
end | ||
|
||
|