Sha256: 169200ad4b8a2d0523495b92337a0f915d4f6a15a76044b81353b4d86607513c

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

require 'page_magic/driver'

module PageMagic
  describe Driver do

    let(:driver_class) do
      Class.new do
        attr_reader :rack_app, :options
        def initialize rack_app, options
          @rack_app = rack_app
          @options = options
        end
        def == driver
          driver.rack_app == rack_app && driver.options == options
        end
      end
    end
    subject do
      described_class.new :custom_browser do
        driver_class
      end
    end

    describe '#supports?' do
      context 'browser is in supported browsers' do
        it 'returns true' do
          expect(subject.support?(:custom_browser)).to eq(true)
        end
      end

      context 'browser is not in supported browsers' do
        it 'returns false' do
          expect(subject.support?(:unsupported_browser)).to eq(false)
        end
      end
    end
    describe '#build' do
      it 'adds the browser to the options supplied to the driver' do
        expect(subject.build(:rack_app, browser: :custom_browser, options: {}).options).to eq(browser: :custom_browser)
      end

      it 'creates an instance of the supplied driver' do
        expect(subject.build(:rack_app,browser: :custom_browser, options: {})).to eq(driver_class.new(:rack_app, {browser: :custom_browser}))
      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/driver_spec.rb
page_magic-1.0.0.alpha3 spec/page_magic/driver_spec.rb
page_magic-0.11.0.alpha8 spec/page_magic/driver_spec.rb
page_magic-0.11.0.alpha7 spec/page_magic/driver_spec.rb