Sha256: f9238e20973028cc6f04a80e72d26e7523efb7454561e849c3dc7f624da3101d
Contents?: true
Size: 1.17 KB
Versions: 15
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true require 'devise' RSpec.configure do |config| config.include Warden::Test::Helpers config.after(:each) do Warden.test_reset! end end FactoryBot.define do factory :user, class: ::EacUsersSupport::User do email { 'admin@example.com' } password { 'mysecret' } end end RSpec.shared_context 'when user is admin', shared_context: :metadata do let(:user) { ::FactoryBot.create(:user) } before do visit '/users/sign_in' fill_in 'E-mail', with: user.email fill_in 'Password', with: user.password click_on 'Log in' end it 'user should be logged' do expect(page).to have_content user.email expect(::EacUsersSupport::User.current_user).not_to be_nil end end RSpec.shared_context 'when user is anonymous', shared_context: :metadata do before do visit '/' if link_exist?('Sair') click_link('Sair') elsif !link_exist?('Entrar') raise 'login nor logout link found' end end it 'user should be not logged' do expect(::EacUsersSupport::User.current_user).to be_nil end def link_exist?(locator) find_link(locator) true rescue Capybara::ElementNotFound false end end
Version data entries
15 entries across 15 versions & 1 rubygems