Sha256: d84875e6986af9afc319478a91e5c59f68caa23be369882e9ca0c893f2898382

Contents?: true

Size: 1.73 KB

Versions: 12

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'

module BrowserMob
  module Proxy

    describe WebDriverListener do
      let(:client)   { double(Client) }
      let(:driver)   { double(Selenium::WebDriver::Driver, :current_url => 'http://foo') }
      let(:listener) { WebDriverListener.new(client) }
      let(:element)  { double(Selenium::WebDriver::Element, :ref => "some-id")}
      let(:har)      { double(HAR::Archive) }
      let(:url)      { "http://example.com" }

      it 'creates a new har on navigate.to' do
        client.should_receive(:new_har).with("navigate-to-http://example.com", {})
        client.should_receive(:har).and_return(:har)

        listener.before_navigate_to(url, driver)
        listener.before_quit(driver)
        listener.hars.size.should == 1
      end

      it 'creates a new page on navigate.back' do
        client.should_receive(:new_page).with(/^navigate-back/)

        listener.before_navigate_back(driver)
      end

      it 'creates a new page on navigate.forward' do
        client.should_receive(:new_page).with(/^navigate-forward/)

        listener.before_navigate_forward(driver)
      end

      it 'creates a new page on click' do
        client.should_receive(:new_page).with(/^click-element/)

        listener.before_click(element, driver)
      end

      it 'saves har before quit' do
        client.should_receive(:har).and_return(har)

        listener.before_quit(driver)
        listener.hars.size.should == 1
      end

      it 'passes the :capture_headers option' do
        listener = WebDriverListener.new(client, :capture_headers => true)
        client.should_receive(:new_har).with("navigate-to-http://example.com", :capture_headers => true)

        listener.before_navigate_to(url, driver)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
browsermob-proxy-0.3.1 spec/unit/webdriver_listener_spec.rb
browsermob-proxy-0.2.0 spec/unit/webdriver_listener_spec.rb
browsermob-proxy-0.1.9 spec/unit/webdriver_listener_spec.rb
browsermob-proxy-0.1.8 spec/unit/webdriver_listener_spec.rb
browsermob-proxy-0.1.8.rc1 spec/unit/webdriver_listener_spec.rb
browsermob-proxy-0.1.7 spec/unit/webdriver_listener_spec.rb
browsermob-proxy-0.1.6 spec/unit/webdriver_listener_spec.rb
browsermob-proxy-0.1.5 spec/unit/webdriver_listener_spec.rb
browsermob-proxy-0.1.4 spec/unit/webdriver_listener_spec.rb
browsermob-proxy-0.1.3 spec/unit/webdriver_listener_spec.rb
browsermob-proxy-0.1.2 spec/unit/webdriver_listener_spec.rb
browsermob-proxy-0.1.1 spec/unit/webdriver_listener_spec.rb