ensl.org/spec/features/users/user_signs_up_spec.rb

72 lines
1.9 KiB
Ruby
Raw Normal View History

2015-09-24 09:19:00 +00:00
require "spec_helper"
2015-09-24 09:19:00 +00:00
feature "Visitor signs up", js: :true do
let(:user) { attributes_for(:user) }
before do
visit new_user_path
end
2015-09-24 09:19:00 +00:00
scenario "with valid Username, Email, Password and Steam ID" do
within registration_form do
fill_form(:user, user.slice(*sign_up_attributes))
click_button submit(:user, :create)
end
2015-11-08 09:41:11 +00:00
2015-09-24 09:19:00 +00:00
expect(user_status).to have_content("ACCOUNT")
end
2015-09-24 09:19:00 +00:00
scenario "with invalid Email" do
within registration_form do
2015-09-24 09:19:00 +00:00
fill_form(:user, user.slice(*sign_up_attributes).merge(email: "invalid"))
click_button submit(:user, :create)
end
2015-09-24 09:19:00 +00:00
expect(page).to have_content(error_message("email.invalid"))
end
2015-09-24 09:19:00 +00:00
scenario "with blank Password" do
within registration_form do
2015-09-24 09:19:00 +00:00
fill_form(:user, user.slice(*sign_up_attributes).merge(raw_password: ""))
click_button submit(:user, :create)
end
2015-09-24 09:19:00 +00:00
expect(page).to have_content(error_message("raw_password.blank"))
end
2015-09-24 09:19:00 +00:00
scenario "with invalid Steam ID" do
within registration_form do
2015-09-24 09:19:00 +00:00
fill_form(:user, user.slice(*sign_up_attributes).merge(steamid: "invalid"))
click_button submit(:user, :create)
end
2015-09-24 09:19:00 +00:00
expect(page).to have_content(error_message("steamid.invalid"))
end
2015-09-24 09:19:00 +00:00
scenario "with out of range Steam ID" do
2015-09-24 05:58:21 +00:00
within registration_form do
2015-09-24 09:19:00 +00:00
fill_form(:user, user.slice(*sign_up_attributes).merge(steamid: "0:0:2147483648"))
2015-09-24 05:58:21 +00:00
click_button submit(:user, :create)
end
2015-09-24 09:19:00 +00:00
expect(page).to have_content(error_message("steamid.invalid"))
2015-09-24 05:58:21 +00:00
end
2015-09-24 09:19:00 +00:00
scenario "with nil Steam ID" do
2015-09-24 06:15:49 +00:00
within registration_form do
2015-09-24 09:19:00 +00:00
fill_form(:user, user.slice(*sign_up_attributes).merge(steamid: nil))
2015-09-24 06:15:49 +00:00
click_button submit(:user, :create)
end
2015-09-24 09:19:00 +00:00
expect(page).to have_content(error_message("steamid.invalid"))
2015-09-24 06:15:49 +00:00
end
def sign_up_attributes
[:username, :email, :raw_password, :steamid]
end
def error_message(translation)
I18n.t("activerecord.errors.models.user.attributes.#{translation}")
end
end