Sha256: 77b897b87f6e34f8183e9286c7a69d66755e3260aee2df66b8ae24a3b5d00933

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

module WatirSpec
  class Implementation

    attr_writer :name, :guard_proc, :browser_class
    attr_accessor :browser_args

    def initialize
      @guard_proc = nil
    end

    def initialize_copy(orig)
      super
      @browser_args = Marshal.load( Marshal.dump(@browser_args))
    end

    def browser_class
      @browser_class || raise("browser_class not set")
    end

    def name
      @name || raise("implementation name not set")
    end

    def matches_guard?(args)
      return @guard_proc.call(args) if @guard_proc

      args.include? name
    end

    def matching_guards_in(guards)
      result = []
      guards.each { |args, data| data.each { |d| result << d } if args.empty? || matches_guard?(args) }

      result
    end

    def inspect_args
      hash = browser_args.last
      desired_capabilities = hash.delete(:desired_capabilities)
      caps = desired_capabilities.send(:capabilities)
      string = "\tdriver: #{browser_args.first}\n"
      hash.each { |arg| string << "#{arg.inspect}\n" }
      string << "\tcapabilities:\n"
      caps.each { |k, v| string << "\t\t#{k}: #{v}\n"}
      hash[:desired_capabilities] = desired_capabilities
      string
    end
  end # Implementation
end # WatirSpec

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watir-6.6.1 lib/watirspec/implementation.rb
watir-6.6.0 lib/watirspec/implementation.rb