Sha256: 00165a0915cbd2bd59292aac8d534cad8da4c516face6f9d889a652e31b68268

Contents?: true

Size: 1017 Bytes

Versions: 3

Compression:

Stored size: 1017 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) do
        browser.quit if @browser
        abort
      end
    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

#OperaWatir::Helper.run!

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
operawatir-0.4.1.pre3-jruby lib/operawatir/helper.rb
operawatir-0.4.1.pre2-jruby lib/operawatir/helper.rb
operawatir-0.4.1.pre1-jruby lib/operawatir/helper.rb