Sha256: ff49bd4683f25ce6473558bb58e79f0e7b469f39c49954ff18d0635c8df1a214

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

::RSpec.configure do |config| # rubocop:disable Metrics/BlockLength
  config.before(:each, js: true) do
    config.rspeckled_logger.debug("Before Each  - Start - #{__FILE__}")

    page.driver.reset!

    config.rspeckled_logger.debug("Before Each  - End   - #{__FILE__}")
  end

  # Focus The Browser on Activation
  config.around(:each, js: true, autofocus: true) do |example|
    config.rspeckled_logger.debug("Around Each  - Start - #{__FILE__}")

    browser_name = example.metadata[:driver].to_s.capitalize

    ::Thread.new do
      sleep 1.5

      `
        osascript -e '
          tell the application named "#{browser_name}"
            activate

            set theWindow to the first item of windows

            if index of theWindow is not 1 then
              set index to 1
              set visible to false
              set visible to true
            end if
          end tell
        ' > /dev/null
      `
    end

    example.run

    sleep example.metadata[:delay]

    config.rspeckled_logger.debug("Around Each  - End   - #{__FILE__}")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspeckled-2.1.1 lib/rspeckled/plugins/hooks/capybara.rb