spec/integration/user_spec.rb in volt-0.9.2 vs spec/integration/user_spec.rb in volt-0.9.3.pre1
- old
+ new
@@ -17,32 +17,11 @@
click_button 'Signup'
expect(page).to have_content('Test Account 9550')
end
- it 'should login and logout' do
- visit '/'
- # Add the user
- store._users! << { email: 'test@test.com', password: 'awes0mesEcRet', name: 'Test Account 9550' }
-
- click_link 'Login'
-
- fields = all(:css, 'form .form-control')
- fields[0].set('test@test.com')
- fields[1].set('awes0mesEcRet')
- click_button 'Login'
-
- expect(page).to have_content('Test Account 9550')
-
- # Click the logout link
- click_link 'Test Account 9550'
- click_link 'Logout'
-
- expect(page).to_not have_content('Test Account 9550')
- end
-
it 'should fail to create an account without a valid email and password' do
visit '/'
click_link 'Login'
click_link 'Signup here'
@@ -58,6 +37,57 @@
# some capybara drivers don't trigger blur correctly
page.execute_script("$('.form-control').blur()")
expect(page).to have_content('must be at least 8 characters')
end
+
+ describe "with a user" do
+ before do
+ # Add the user
+ store._users! << { email: 'test@test.com', password: 'awes0mesEcRet', name: 'Test Account 9550' }
+ end
+
+ it 'should login and logout' do
+ visit '/'
+
+ click_link 'Login'
+
+ fields = all(:css, 'form .form-control')
+ fields[0].set('test@test.com')
+ fields[1].set('awes0mesEcRet')
+ click_button 'Login'
+
+ expect(page).to have_content('Test Account 9550')
+
+ # Click the logout link
+ click_link 'Test Account 9550'
+ click_link 'Logout'
+
+ expect(page).to_not have_content('Test Account 9550')
+ end
+
+ it 'should show an error for invalid email' do
+ visit '/'
+ click_link 'Login'
+
+ fields = all(:css, 'form .form-control')
+ fields[0].set('notausersemail@gmail.com')
+ fields[1].set('awes0mesEcRet')
+ click_button 'Login'
+
+ expect(page).to have_content('User could not be found')
+ end
+
+ it 'should show an error for an invalid password' do
+ visit '/'
+ click_link 'Login'
+
+ fields = all(:css, 'form .form-control')
+ fields[0].set('test@test.com')
+ fields[1].set('wrongpassword')
+ click_button 'Login'
+
+ expect(page).to have_content('Password did not match')
+ end
+ end
+
end