Sha256: 71e6dc0f984c36383b5035c21ed2065041841d86e5754801ff709cf39e177147

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

module WatirSplash
  module Page
    class Base
      include SpecHelper

      class << self
        @@url = "about:blank"

        def url url
          @@url = url
        end
      end

      def initialize(browser=nil)
        if browser
          @browser = WatirSplash::Browser.current = browser 
        else
          @browser = WatirSplash::Browser.new
          @browser.goto @@url
        end
      end

      def modify element, methodz
        methodz.each_pair do |meth, return_value|
          element.instance_eval do 
            instance_variable_set("@_#{meth}_return_value_proc", return_value)
            instance_eval %Q[
              self.class.send(:alias_method, :__#{meth}, :#{meth}) if respond_to? :#{meth}

              def #{meth}(*args)
                self.send(:__#{meth}, *args) if respond_to? :__#{meth}
                instance_variable_get("@_#{meth}_return_value_proc").call(*args)
              end
            ]
          end
        end
        element
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
watirsplash-2.1.1 lib/watirsplash/page/base.rb
watirsplash-2.1.0 lib/watirsplash/page/base.rb
watirsplash-2.0.1.rc5 lib/watirsplash/page/base.rb
watirsplash-2.0.1.rc4 lib/watirsplash/page/base.rb
watirsplash-2.0.1.rc3 lib/watirsplash/page/base.rb
watirsplash-2.0.1.rc1 lib/watirsplash/page/base.rb
watirsplash-2.0.0 lib/watirsplash/page/base.rb