Skip to content

Instantly share code, notes, and snippets.

@euqueme
Last active April 19, 2020 16:41
Show Gist options
  • Save euqueme/c76fcee993984d53e95c3586dce5ba22 to your computer and use it in GitHub Desktop.
Save euqueme/c76fcee993984d53e95c3586dce5ba22 to your computer and use it in GitHub Desktop.
RSpec.describe 'login followed by logout', type: :feature do
# The user must exist so we are creating it here
let(:user) { User.create(username: 'maruk', fullname: 'Maria Eugenia Queme') }
scenario 'login page' do
# First we need to be in the root path
visit root_path
# Secondly fill in the fields in this case only the username
fill_in 'session_username', with: user.username
# Third we have to click the Log in button
click_button 'Log in'
# We give it some time to load
sleep(3)
# And lastly we are expecting our page to have the success message
expect(page).to have_content('User Logged in')
# Logging out it's much simplier after this
click_on 'Log out'
sleep(3)
expect(page). to have_content('Please log in')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment