Sha256: 871d35e9170592b55762804aa56741b8c2ec2ce3ad387e8356a179ff646839d0

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

module WatirSplash
  # main helper module
  #
  # these methods can be used in specs directly
  module SpecHelper
    include Watir::WaitHelper

    # opens the browser at specified url
    def open_browser_at url
      @browser = Watir::Browser.new
      @browser.speed = :fast
      add_checker Watir::PageCheckers::JAVASCRIPT_ERRORS_CHECKER
      formatter.browser = @browser rescue nil 
      goto url
      maximize
    end

    # returns WatirSplash::HtmlFormatter object, nil if not in use
    def formatter
      @formatter ||= Spec::Runner.options.formatters.find {|f| f.kind_of?(WatirSplash::HtmlFormatter) rescue false}
    end

    module_function :formatter

    def method_missing name, *args #:nodoc:
      @browser.respond_to?(name) ? @browser.send(name, *args) : super
    end

    # make sure that using method 'p' will be invoked on @browser
    # and not Kernel
    # use Kernel.p if you need to dump some variable 
    def p *args #:nodoc:
      @browser.p *args
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
watirsplash-0.2.12 lib/watirsplash/spec_helper.rb
watirsplash-0.2.11 lib/watirsplash/spec_helper.rb
watirsplash-0.2.10 lib/watirsplash/spec_helper.rb
watirsplash-0.2.9 lib/watirsplash/spec_helper.rb
watirsplash-0.2.8 lib/watirsplash/spec_helper.rb
watirsplash-0.2.7 lib/watirsplash/spec_helper.rb
watirsplash-0.2.6 lib/watirsplash/spec_helper.rb