Sha256: cb527117097f69bd5ff1d0dc4e401e0d98e64ba53dc9dd08be6d7e419c48c176

Contents?: true

Size: 760 Bytes

Versions: 1

Compression:

Stored size: 760 Bytes

Contents

require 'webrick'
require 'json'

module Cypress
  class CallbackServer
    attr_reader :port
    def initialize(owner)
      @port    = 9293
      @webrick = WEBrick::HTTPServer.new(:Port => port)
      @webrick.mount_proc '/setup' do |req, res|
        owner.run_command :setup
        res.body = ''
      end
      @webrick.mount_proc '/eval' do |req, res|
        owner.run_command :eval, JSON.parse(req.body)
        res.body = ''
      end
      @webrick.mount_proc '/scenario' do |req, res|
        owner.run_command :scenario, JSON.parse(req.body)
        res.body = ''
      end
    end

    def start
      @webrick.start
    end

    def shutdown
      @webrick.shutdown
    end

    def callback_url
      "http://localhost:9293"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cypress-on-rails-0.1.5 lib/cypress/callback_server.rb