Sha256: bae749286edaf745d582706d5dbead633713a0d35884839a2e37315195dc9c33

Contents?: true

Size: 570 Bytes

Versions: 8

Compression:

Stored size: 570 Bytes

Contents

# frozen_string_literal: true

RSpec.shared_context 'when user is anonymous', shared_context: :metadata do
  before do
    visit '/'
    if link_exist?(I18n.translate!('devise.log_out'))
      click_link(I18n.translate!('devise.log_out'))
    elsif !link_exist?(I18n.translate!('devise.log_in'))
      raise 'login nor logout link found'
    end
  end

  it 'should be a link to log in' do
    expect(page).to have_link(nil, href: '/users/sign_in')
  end

  def link_exist?(locator)
    find_link(locator)
    true
  rescue Capybara::ElementNotFound
    false
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
eac_rails_base0-0.69.0 lib/eac_rails_base0/rspec/shared_contexts/when_user_is_anonymous.rb
eac_rails_base0-0.68.7 lib/eac_rails_base0/rspec/shared_contexts/when_user_is_anonymous.rb
eac_rails_base0-0.68.6 lib/eac_rails_base0/rspec/shared_contexts/when_user_is_anonymous.rb
eac_rails_base0-0.68.5 lib/eac_rails_base0/rspec/shared_contexts/when_user_is_anonymous.rb
eac_rails_base0-0.68.4 lib/eac_rails_base0/rspec/shared_contexts/when_user_is_anonymous.rb
eac_rails_base0-0.68.3 lib/eac_rails_base0/rspec/shared_contexts/when_user_is_anonymous.rb
eac_rails_base0-0.68.2 lib/eac_rails_base0/rspec/shared_contexts/when_user_is_anonymous.rb
eac_rails_base0-0.68.1 lib/eac_rails_base0/rspec/shared_contexts/when_user_is_anonymous.rb