Sha256: 987295400d69fc07e76016493062e2906bb4aa1c150110a93de1de88a9346dfd

Contents?: true

Size: 972 Bytes

Versions: 2

Compression:

Stored size: 972 Bytes

Contents

# -*- coding: utf-8 -*-

# TODO
#   You need to set the OPERA_LAUNCHER and OPERA_PATH environment variables
#   for this Helper to work.

require 'operawatir'
require 'rspec'
require 'rbconfig'

module OperaWatir::Helper
  extend self
  
  def settings
    OperaWatir::Browser.settings
  end
  
  def browser
    @browser ||= OperaWatir::Browser.new
  end
  
  def configure_rspec!
    RSpec.configure do |config|
      
      # Set every RSpec option
      settings.each do |key, value|
        config.send("#{key}=", value) if config.respond_to?("#{key}=")
      end
            
      config.include SpecHelpers
      
      config.after(:suite) { browser.quit! if browser }
    end
  end

  def run!(settings={})
    OperaWatir::Browser.settings = settings
    configure_rspec!
    RSpec::Core::Runner.autorun
  end
  
private

  module SpecHelpers
    def browser
      OperaWatir::Helper.browser
    end

    def window
      browser.active_window
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
operawatir-0.3.2-jruby lib/operawatir/helper.rb
operawatir-0.3-jruby lib/operawatir/helper.rb