Sha256: b6cd981de19bf7b0bbc6b6dbf738e62f6a36b1195f17db80cbc52eae9e292c63

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

module WatirSpec
  module Runner

    module BrowserHelper
      def browser
        $browser
      end
    end

    module MessagesHelper
      def messages
        browser.div(id: 'messages').divs.map(&:text)
      end
    end

    module_function

    @execute = true

    def execute=(bool)
      @execute = bool
    end

    def execute
      start_server
      configure
      add_guard_hook

      @executed = true
    end

    def execute_if_necessary
      execute if !@executed && @execute
    end

    def configure
      Thread.abort_on_exception = true
      return unless defined?(RSpec)

      RSpec.configure do |config|
        config.include(BrowserHelper)
        config.include(MessagesHelper)

        config.before(:suite) { $browser = WatirSpec.new_browser }
        config.after(:suite) { $browser.close }
      end
    end

    def start_server
      WatirSpec::Server.run!
    end

    def add_guard_hook
      return if WatirSpec.unguarded?
      at_exit { WatirSpec::Guards.report }
    end

  end # Runner
end # WatirSpec

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watir-6.13.0 lib/watirspec/runner.rb
watir-6.12.0 lib/watirspec/runner.rb