Sha256: 8ea6bec887979cb651c7bce1ef5e8537979ea7221a7e7730df297cf376bf77ed

Contents?: true

Size: 1.09 KB

Versions: 13

Compression:

Stored size: 1.09 KB

Contents

require 'rubygems'
require File.expand_path('../../lib/faye/websocket', __FILE__)
require 'cgi'

EM.run {
  host   = 'ws://localhost:9001'
  agent  = "Faye (Ruby #{RUBY_VERSION})"
  cases  = 0
  skip   = []
  
  socket = Faye::WebSocket::Client.new("#{host}/getCaseCount")
  
  socket.onmessage = lambda do |event|
    puts "Total cases to run: #{event.data}"
    cases = event.data.to_i
  end
  
  socket.onclose = lambda do |event|
    run_case = lambda do |n|
      if n > cases
        socket = Faye::WebSocket::Client.new("#{host}/updateReports?agent=#{CGI.escape agent}")
        socket.onclose = lambda { |e| EM.stop }
        
      elsif skip.include?(n)
        EM.next_tick { run_case.call(n+1) }
        
      else
        puts "Running test case ##{n} ..."
        socket = Faye::WebSocket::Client.new("#{host}/runCase?case=#{n}&agent=#{CGI.escape agent}")
        
        socket.onmessage = lambda do |event|
          socket.send(event.data)
        end
        
        socket.onclose = lambda do |event|
          run_case.call(n + 1)
        end
      end
    end
    
    run_case.call(1)
  end
}

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
faye-websocket-0.4.6-java examples/autobahn_client.rb
faye-websocket-0.4.6 examples/autobahn_client.rb
faye-websocket-0.4.5-java examples/autobahn_client.rb
faye-websocket-0.4.5 examples/autobahn_client.rb
_bushido-faye-websocket-0.4.4 examples/autobahn_client.rb
faye-websocket-0.4.4-java examples/autobahn_client.rb
faye-websocket-0.4.4 examples/autobahn_client.rb
faye-websocket-0.4.3 examples/autobahn_client.rb
faye-websocket-0.4.2 examples/autobahn_client.rb
faye-websocket-0.4.1 examples/autobahn_client.rb
faye-websocket-0.4.0 examples/autobahn_client.rb
faye-websocket-0.3.0 examples/autobahn_client.rb
faye-websocket-0.2.0 examples/autobahn_client.rb