Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ bundle exec rake test TEST=test/integration/users_login_test.rb
- > TESTOPTS="--name test_login_with_valid_information"
- #michael:
- name: Michael Example
- email: michael@example.com
- password_digest: <%= User.digest('password') %>
- require 'test_helper'
- class UsersLoginTest < ActionDispatch::IntegrationTest
- def setup
- @user = users(:michael)
- end
- test "login with invalid information" do
- get login_path
- assert_template 'sessions/new'
- post login_path, session: { email: "", password: "" }
- assert_template 'sessions/new'
- assert_not flash.empty?
- get root_path
- assert flash.empty?
- end
- test "login with valid information" do
- get login_path
- post login_path, session: { email: @user.email, password: 'password' }
- assert_redirected_to @user
- follow_redirect!
- assert_template 'users/show'
- assert_select "a[href=?]", login_path, count: 0
- assert_select "a[href=?]", logout_path
- assert_select "a[href=?]", user_path(@user)
- end
- end
- #michael:
- name: Michael Example
- email: michael@example.com
- password_digest: <%= User.digest('password') %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement