Sha256: 3fc9c67dbbda7e900bf7ace8945b02472c4ea3ba776f707e646d7286562ac6ca

Contents?: true

Size: 1.68 KB

Versions: 6

Compression:

Stored size: 1.68 KB

Contents

# encoding: utf-8
module WatirSpec
  class << self
    attr_accessor :browser_args, :persistent_browser, :unguarded, :implementation

    def html
      File.expand_path("#{File.dirname(__FILE__)}/../html")
    end

    def files
      "file://#{html}"
    end

    def host
      "http://#{Server.bind}:#{Server.port}"
    end

    def unguarded?
      @unguarded ||= false
    end

    def platform
      @platform ||= case RUBY_PLATFORM
                    when /java/
                      :java
                    when /mswin|msys|mingw32/
                      :windows
                    when /darwin/
                      :macosx
                    when /linux/
                      :linux
                    else
                      RUBY_PLATFORM
                    end
    end

    def implementation
      @implementation ||= (
        imp = WatirSpec::Implementation.new
        yield imp if block_given?

        imp
      )
    end

    def implementation=(imp)
      unless imp.kind_of? WatirSpec::Implementation
        raise TypeError, "expected WatirSpec::Implementation, got #{imp.class}"
      end

      @implementation = imp
    end

    def new_browser
      klass = WatirSpec.implementation.browser_class
      args = WatirSpec.implementation.browser_args
      args ? klass.new(*args) : klass.new
    end

    def ruby
      if @ruby.nil?
        if defined?(Gem)
          @ruby = Gem.ruby
        else
          require "rbconfig"
          rb = File.join(RbConfig::CONFIG.values_at('BINDIR', 'RUBY_INSTALL_NAME').compact)
          ext = RbConfig::CONFIG['EXEEXT']

          @ruby = "#{rb}#{ext}"
        end
      end

      @ruby
    end

  end # class << WatirSpec
end # WatirSpec

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
watir-webdriver-0.1.2 spec/watirspec/lib/watirspec.rb
watir-webdriver-0.1.1 spec/watirspec/lib/watirspec.rb
watir-webdriver-0.1.0 spec/watirspec/lib/watirspec.rb
watir-webdriver-0.0.9 spec/watirspec/lib/watirspec.rb
watir-webdriver-0.0.8 spec/watirspec/lib/watirspec.rb
watir-webdriver-0.0.7 spec/watirspec/lib/watirspec.rb