Sha256: 207147168dbd30156cdec6ec0c60b877d307c3ac668413b71089f602f98c2d06

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

require 'page_magic'

describe PageMagic do
  describe '::drivers' do
    it 'returns loaded drivers' do
      expected_drivers = described_class::Drivers.new.tap do |drivers|
        drivers.load
      end

      expect(described_class.drivers).to eq(expected_drivers)
    end
  end

  describe '::session' do
    context 'specifying the browser' do
      it 'loads the correct driver' do
        session = described_class.session(browser: :firefox)
        session.raw_session.driver.is_a?(Capybara::Selenium::Driver).should be_true
      end
    end

    context 'specifying a rack application' do
      it 'configures capybara to run against the app' do
        session = described_class.session(application: :rack_application)
        expect(session.raw_session.app).to be(:rack_application)
      end
    end

    context 'specifying options' do
      it 'passes the options to the browser driver' do
        options = {option: :config}
        session = described_class.session(options: options, browser: :chrome)

        expect(session.raw_session.driver.options).to include(options)
      end
    end

    context 'driver for browser not found' do
      it 'raises an error' do
        expect{described_class.session(browser: :invalid)}.to raise_exception described_class::UnspportedBrowserException
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
page_magic-1.0.0.alpha4 spec/page_magic_spec.rb
page_magic-1.0.0.alpha3 spec/page_magic_spec.rb
page_magic-0.11.0.alpha8 spec/page_magic_spec.rb
page_magic-0.11.0.alpha7 spec/page_magic_spec.rb