Sha256: 044d867a1949670574613a8a35ef4c9b5c59543ba7af2a8a8e5fb5fbe487639d

Contents?: true

Size: 932 Bytes

Versions: 15

Compression:

Stored size: 932 Bytes

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

    def execute
      start_server
      configure
      add_guard_hook

      @executed = true
    end

    def execute_if_necessary
      execute unless @executed
    end

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

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

        $browser = WatirSpec.new_browser
        at_exit { $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 # SpecHelper
end # WatirSpec

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
watir-6.5.0 lib/watirspec/runner.rb
watir-6.4.3 lib/watirspec/runner.rb
watir-6.4.2 lib/watirspec/runner.rb
watir-6.4.1 lib/watirspec/runner.rb
watir-6.4.0 lib/watirspec/runner.rb
watir-6.4.0.rc2 lib/watirspec/runner.rb
watir-6.4.0.rc1 lib/watirspec/runner.rb
watir-6.3.0 lib/watirspec/runner.rb
watir-6.2.1 lib/watirspec/runner.rb
watir-6.2.0 lib/watirspec/runner.rb
watir-6.1.0 lib/watirspec/runner.rb
watir-6.0.3 lib/watirspec/runner.rb
watir-6.0.2 lib/watirspec/runner.rb
watir-6.0.1 lib/watirspec/runner.rb
watir-6.0.0 lib/watirspec/runner.rb