Sha256: dedd1304155c7307a0ac83e9e592acf3f44a9bb0fdf2329054a0b5e9e619dd14

Contents?: true

Size: 1.59 KB

Versions: 6

Compression:

Stored size: 1.59 KB

Contents

module Volt
  def self.spec_setup(app_path = '.')
    if RUBY_PLATFORM == 'opal'
      require 'volt'
    else
      ENV['SERVER'] = 'true'

      if ENV['BROWSER']
        require 'capybara'
        require 'capybara/dsl'
        require 'capybara/rspec'
        require 'capybara/poltergeist'
      end

      require 'volt'
      require 'volt/boot'

      # Require in app
      Volt.boot(Dir.pwd)

      if ENV['BROWSER']
        require 'volt/server'

        Capybara.server do |app, port|
          require 'rack/handler/thin'
          Rack::Handler::Thin.run(app, Port: port)
        end

        Capybara.app = Server.new(app_path).app

        if ENV['BROWSER'] == 'phantom'
          Capybara.default_driver = :poltergeist
        elsif ENV['BROWSER'] == 'chrome'
          Capybara.register_driver :chrome do |app|
            Capybara::Selenium::Driver.new(app, browser: :chrome)
          end

          Capybara.default_driver = :chrome
        elsif ENV['BROWSER'] == 'firefox'

          # require 'selenium/webdriver'
          # # require 'selenium/client'
          #
          Capybara.default_driver = :selenium

          # Capybara.register_driver :selenium_firefox do |app|
          #   Capybara::Selenium::Driver.new(app, :browser => :firefox)
          # end
          # Capybara.current_driver = :selenium_firefox
        elsif ENV['BROWSER'] == 'safari'
          # Needs extension
          Capybara.register_driver :safari do |app|
            Capybara::Selenium::Driver.new(app, browser: :safari)
          end
          Capybara.default_driver = :safari
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
volt-0.8.21 lib/volt/spec/setup.rb
volt-0.8.20 lib/volt/spec/setup.rb
volt-0.8.19 lib/volt/spec/setup.rb
volt-0.8.18 lib/volt/spec/setup.rb
volt-0.8.17 lib/volt/spec/setup.rb
volt-0.8.16 lib/volt/spec/setup.rb