Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. $ bundle exec rake test TEST=test/integration/users_login_test.rb
  2. > TESTOPTS="--name test_login_with_valid_information"
  3.  
  4. #michael:
  5. name: Michael Example
  6. email: michael@example.com
  7. password_digest: <%= User.digest('password') %>
  8.  
  9. require 'test_helper'
  10.  
  11. class UsersLoginTest < ActionDispatch::IntegrationTest
  12.  
  13. def setup
  14. @user = users(:michael)
  15. end
  16.  
  17. test "login with invalid information" do
  18. get login_path
  19. assert_template 'sessions/new'
  20. post login_path, session: { email: "", password: "" }
  21. assert_template 'sessions/new'
  22. assert_not flash.empty?
  23. get root_path
  24. assert flash.empty?
  25. end
  26.  
  27. test "login with valid information" do
  28. get login_path
  29. post login_path, session: { email: @user.email, password: 'password' }
  30. assert_redirected_to @user
  31. follow_redirect!
  32. assert_template 'users/show'
  33. assert_select "a[href=?]", login_path, count: 0
  34. assert_select "a[href=?]", logout_path
  35. assert_select "a[href=?]", user_path(@user)
  36. end
  37.  
  38. end
  39.  
  40. #michael:
  41. name: Michael Example
  42. email: michael@example.com
  43. password_digest: <%= User.digest('password') %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement