jam-cloud/web/spec/features/password_reset_spec.rb

48 lines
1.7 KiB
Ruby

require 'spec_helper'
describe "Reset Password", :js => true, :type => :feature, :capybara_feature => true do
subject { page }
before do
UserMailer.deliveries.clear
visit request_reset_password_path
end
it "shows specific error for empty password" do
click_button 'RESET'
find('.login-error-msg', text: 'Please enter an email address')
UserMailer.deliveries.length.should == 0
end
it "shows specific error for invalid email address" do
fill_in "jam_ruby_user_email", with: 'snoozeday'
click_button 'RESET'
find('.login-error-msg', text: 'Please enter a valid email address')
UserMailer.deliveries.length.should == 0
end
it "acts as if success when email of no one in the service" do
fill_in "jam_ruby_user_email", with: 'noone_exists_with_this@blah.com'
click_button 'RESET'
find('span.please-check', text: 'Please check your email at noone_exists_with_this@blah.com and click the link in the email to set a new password.')
UserMailer.deliveries.length.should == 0
end
it "acts as if success when email is valid" do
user = FactoryGirl.create(:user)
fill_in "jam_ruby_user_email", with: user.email
click_button 'RESET'
find('span.please-check', text: "Please check your email at #{user.email} and click the link in the email to set a new password.")
UserMailer.deliveries.length.should == 1
end
it "acts as if success when email is valid (but with extra whitespace)" do
user = FactoryGirl.create(:user)
fill_in "jam_ruby_user_email", with: user.email + ' '
click_button 'RESET'
find('span.please-check', text: "Please check your email at #{user.email} and click the link in the email to set a new password.")
UserMailer.deliveries.length.should == 1
end
end