Sha256: 80bf3fa7df64aa54a26a163da616cb57debce77ed91a075af9fdeaa317c91ca6

Contents?: true

Size: 637 Bytes

Versions: 4

Compression:

Stored size: 637 Bytes

Contents

require 'rubygems'
require 'rack'
require 'webrick'

# TODO: Use Selenium::WebDriver::SpecSupport::RackServer?
class SampleApp

  def self.start(host, port)
    Rack::Handler::WEBrick.run(new, :Host => host, :Port => port)
  end

  def initialize
    @public = Rack::File.new(File.expand_path("../public", __FILE__))
  end

  def call(env)
    req = Rack::Request.new(env)

    case req.path
    when "/"
      [200, {}, ["Selenium Ruby Client Sample Application"]]
    when "/compute"
      sleep 5
      resp = eval(req.params['calculator-expression']).to_s
      [200, {}, [resp]]
    else
      @public.call(env)
    end
  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
browserstack-webdriver-2.40.1 spec/integration/selenium/client/sample-app/sample_app.rb
browserstack-webdriver-0.0.22 spec/integration/selenium/client/sample-app/sample_app.rb
browserstack-webdriver-0.0.1 spec/integration/selenium/client/sample-app/sample_app.rb
bbc-selenium-webdriver-1.17.0 spec/integration/selenium/client/sample-app/sample_app.rb