M
M
mlwrm2016-02-12 23:23:14
Ruby on Rails
mlwrm, 2016-02-12 23:23:14

How to create a test to log out a user?

Please tell me how to make the tester correctly so that after log in it tests the exit from the account? Swears at logout(:user)

describe "user log in and out" do
  it "allows an existing user to sign in" do
    User.create!(email: "[email protected]_test.org", password: "135798620")

    visit "/users/sign_in"

    fill_in "Email", with: "[email protected]_test.org"
    fill_in "Password", with: "135798620"

    click_button "Log in"

    expect(page).to have_content("Signed in successfully.")
  end

  it "testing logout function" do
    logout(:user)
    expect(page).to have_content("Signed out successfully.")
  end
end

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey P, 2016-02-13
@ruddy22

If this is rspec, then write a before_each block where to log in, then test what you need in it sections. Now, as it seems to me, there is a crash on testing log yelling?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question