Created
March 12, 2014 10:06
-
-
Save phillipoertel/9504085 to your computer and use it in GitHub Desktop.
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_relative '../features_helper' | |
require_relative 'registration_spec_helper' | |
feature "Registering as new user", :js do | |
include RegistrationSpecHelper | |
background do | |
visit root_path | |
click_on("Registrieren") | |
end | |
scenario "should work when filling out the form correctly" do | |
fill_form(build(:user)) | |
click_button('Registrieren') | |
page.should have_content('ist im öffentlichen Profil sichtbar') | |
show_screen | |
page.should have_content('schau einfach in dein Postfach') | |
end | |
def with_toggle(name, value) | |
orig = AppConfig.send(name.to_sym) | |
AppConfig.set(name.to_sym, value) | |
yield | |
AppConfig.set(name.to_sym, orig) | |
end | |
scenario "tracks the user.signed_up event in Google Analytics" do | |
with_toggle(:google_analytics_enabled, true) do | |
fill_form(build(:user)) | |
click_button('Registrieren') | |
expect(page).to show_page(:user_edit) # AJAX action going on. Let's wait until the new page is loaded. | |
page.body.should have_content('["_trackEvent","user","signed_up"]') | |
end | |
end | |
scenario "should show all validation errors" do | |
fill_in('E-Mail', with: "keine@email-adresse") | |
click_button('Registrieren') | |
page.should have_error_on("input", "user_firstname", text: 'muss ausgefüllt werden') | |
page.should have_error_on("input", "user_firstname", text: 'muss ausgefüllt werden') | |
page.should have_error_on("input", "user_lastname", text: 'muss ausgefüllt werden') | |
page.should have_error_on("input", "user_email", text: 'das Format ist ungültig. Bitte überprüfe die Schreibweise') | |
page.should have_error_on("input", "user_password", text: 'muss ausgefüllt werden') | |
find(:xpath, ".//input[@id='user_agb_accepted']/following-sibling::span").text.strip.should == 'muss akzeptiert werden' | |
end | |
scenario "should show proper password validation error" do | |
fill_in('Passwort (mind. 6 Zeichen)', with: "xxxxxx") | |
click_button('Registrieren') | |
page.should have_error_on("input", "user_password", text: 'Eingaben stimmen nicht überein') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment