Sha256: c1d50b35c9c781bf057ebbf1ee3338eacf1d1ee1ac356aa65ad6409cd302f115

Contents?: true

Size: 1.28 KB

Versions: 9

Compression:

Stored size: 1.28 KB

Contents

require 'page_magic'

describe PageMagic do
  describe '::drivers' do
    it 'returns loaded drivers' do
      expected_drivers = described_class::Drivers.new.tap(&:load)

      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

9 entries across 9 versions & 1 rubygems

Version Path
page_magic-1.0.0.alpha13 spec/page_magic_spec.rb
page_magic-1.0.0.alpha12 spec/page_magic_spec.rb
page_magic-1.0.0.alpha11 spec/page_magic_spec.rb
page_magic-1.0.0.alpha10 spec/page_magic_spec.rb
page_magic-1.0.0.alpha9 spec/page_magic_spec.rb
page_magic-1.0.0.alpha8 spec/page_magic_spec.rb
page_magic-1.0.0.alpha7 spec/page_magic_spec.rb
page_magic-1.0.0.alpha6 spec/page_magic_spec.rb
page_magic-1.0.0.alpha5 spec/page_magic_spec.rb