Sha256: 4bd86af6d8564c94dd47ba6306dd5ed1b4f82d2b468a7a9ba7256a92ea97e51f

Contents?: true

Size: 1.48 KB

Versions: 29

Compression:

Stored size: 1.48 KB

Contents

require 'volt/spec/sauce_labs'

module Volt
  class << self
    def setup_capybara(app_path, volt_app = nil)
      browser = ENV['BROWSER']

      if browser
        setup_capybara_app(app_path, volt_app)

        case browser
        when 'phantom'
          Capybara.default_driver = :poltergeist
        when 'chrome', 'safari'
          # Use the browser name, note that safari requires an extension to run
          browser = browser.to_sym
          Capybara.register_driver(browser) do |app|
            Capybara::Selenium::Driver.new(app, browser: browser)
          end

          Capybara.default_driver = browser
        when 'firefox'
          Capybara.default_driver = :selenium
        when 'sauce'
          setup_sauce_labs
        end
      end
    end

    def setup_capybara_app(app_path, volt_app)
      require 'capybara'
      require 'capybara/dsl'
      require 'capybara/rspec'
      require 'capybara/poltergeist'
      require 'selenium-webdriver'
      require 'volt/server'

      case RUNNING_SERVER
      when 'thin'
        Capybara.server do |app, port|
          require 'rack/handler/thin'
          Rack::Handler::Thin.run(app, Port: port)
        end
      when 'puma'
        Capybara.server do |app, port|
          Puma::Server.new(app).tap do |s|
            s.add_tcp_listener Capybara.server_host, port
          end.run.join
        end
      end

      # Setup server, use existing booted app
      Capybara.app = Server.new(app_path, volt_app).app
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
volt-0.9.6 lib/volt/spec/capybara.rb
volt-0.9.6.pre3 lib/volt/spec/capybara.rb
volt-0.9.6.pre2 lib/volt/spec/capybara.rb
volt-0.9.6.pre1 lib/volt/spec/capybara.rb
volt-0.9.5 lib/volt/spec/capybara.rb
volt-0.9.5.pre12 lib/volt/spec/capybara.rb
volt-0.9.5.pre11 lib/volt/spec/capybara.rb
volt-0.9.5.pre9 lib/volt/spec/capybara.rb
volt-0.9.5.pre8 lib/volt/spec/capybara.rb
volt-0.9.5.pre7 lib/volt/spec/capybara.rb
volt-0.9.5.pre6 lib/volt/spec/capybara.rb
volt-0.9.5.pre5 lib/volt/spec/capybara.rb
volt-0.9.5.pre4 lib/volt/spec/capybara.rb
volt-0.9.5.pre3 lib/volt/spec/capybara.rb
volt-0.9.5.pre2 lib/volt/spec/capybara.rb
volt-0.9.5.pre1 lib/volt/spec/capybara.rb
volt-0.9.4 lib/volt/spec/capybara.rb
volt-0.9.4.pre5 lib/volt/spec/capybara.rb
volt-0.9.4.pre3 lib/volt/spec/capybara.rb
volt-0.9.4.pre2 lib/volt/spec/capybara.rb