Sha256: 51f8e9ba7ca6df4261b19c7daa63eb062226f9f0b1833f0eeb5f4b464fb19d6a

Contents?: true

Size: 1.15 KB

Versions: 9

Compression:

Stored size: 1.15 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

      def event_log
        browser.div(id: 'log').wait_until(&:present?).ps.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 (!defined?(@executed) || !@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

9 entries across 9 versions & 1 rubygems

Version Path
watir-7.1.0 lib/watirspec/runner.rb
watir-7.0.0 lib/watirspec/runner.rb
watir-7.0.0.beta5 lib/watirspec/runner.rb
watir-7.0.0.beta4 lib/watirspec/runner.rb
watir-7.0.0.beta3 lib/watirspec/runner.rb
watir-7.0.0.beta2 lib/watirspec/runner.rb
watir-7.0.0.beta1 lib/watirspec/runner.rb
watir-6.19.1 lib/watirspec/runner.rb
watir-6.19.0 lib/watirspec/runner.rb