Sha256: b8c91b3047ef8ac1b303616e2ad22fc36b0136e84f5e8f3b4def14173f4ed393

Contents?: true

Size: 1.96 KB

Versions: 20

Compression:

Stored size: 1.96 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Capybara::Session do
  context '#new' do
    it 'should raise an error if passed non-existent driver' do
      expect do
        Capybara::Session.new(:quox, TestApp).driver
      end.to raise_error(Capybara::DriverNotFoundError)
    end

    it 'verifies a passed app is a rack app' do
      expect do
        Capybara::Session.new(:unknown, random: 'hash')
      end.to raise_error TypeError, 'The second parameter to Session::new should be a rack app if passed.'
    end
  end

  context 'current_driver' do
    around do |example|
      orig_driver = Capybara.current_driver
      example.run
      Capybara.current_driver = orig_driver
    end

    it 'is global when threadsafe false' do
      Capybara.threadsafe = false
      Capybara.current_driver = :selenium
      thread = Thread.new do
        Capybara.current_driver = :random
      end
      thread.join
      expect(Capybara.current_driver).to eq :random
    end

    it 'is thread specific threadsafe true' do
      Capybara.threadsafe = true
      Capybara.current_driver = :selenium
      thread = Thread.new do
        Capybara.current_driver = :random
      end
      thread.join
      expect(Capybara.current_driver).to eq :selenium
    end
  end

  context 'session_name' do
    around do |example|
      orig_name = Capybara.session_name
      example.run
      Capybara.session_name = orig_name
    end

    it 'is global when threadsafe false' do
      Capybara.threadsafe = false
      Capybara.session_name = 'sess1'
      thread = Thread.new do
        Capybara.session_name = 'sess2'
      end
      thread.join
      expect(Capybara.session_name).to eq 'sess2'
    end

    it 'is thread specific when threadsafe true' do
      Capybara.threadsafe = true
      Capybara.session_name = 'sess1'
      thread = Thread.new do
        Capybara.session_name = 'sess2'
      end
      thread.join
      expect(Capybara.session_name).to eq 'sess1'
    end
  end
end

Version data entries

20 entries across 19 versions & 2 rubygems

Version Path
tdiary-5.0.11 vendor/bundle/gems/capybara-3.12.0/spec/session_spec.rb
tdiary-5.0.11 vendor/bundle/gems/capybara-3.6.0/spec/session_spec.rb
capybara-3.12.0 spec/session_spec.rb
capybara-3.11.1 spec/session_spec.rb
capybara-3.11.0 spec/session_spec.rb
capybara-3.10.1 spec/session_spec.rb
capybara-3.10.0 spec/session_spec.rb
capybara-3.9.0 spec/session_spec.rb
capybara-3.8.2 spec/session_spec.rb
capybara-3.8.1 spec/session_spec.rb
capybara-3.8.0 spec/session_spec.rb
capybara-3.7.2 spec/session_spec.rb
capybara-3.7.1 spec/session_spec.rb
capybara-3.7.0 spec/session_spec.rb
capybara-3.6.0 spec/session_spec.rb
capybara-3.5.1 spec/session_spec.rb
capybara-3.5.0 spec/session_spec.rb
capybara-3.4.2 spec/session_spec.rb
capybara-3.4.1 spec/session_spec.rb
capybara-3.4.0 spec/session_spec.rb