Sha256: 9afb5143720acd82f3ca29c5199efaf1b2c4809fe7c92711f593a91d24734bd8

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.alpha8 spec/page_magic/driver_spec.rb
page_magic-1.0.0.alpha7 spec/page_magic/driver_spec.rb
page_magic-1.0.0.alpha6 spec/page_magic/driver_spec.rb
page_magic-1.0.0.alpha5 spec/page_magic/driver_spec.rb