module RSpecRayo
  class Tropo1Driver
    require 'drb'
    require 'net/http'
    require 'uri'
    require 'countdownlatch'

    attr_accessor :script_content, :result, :drb, :config

    def initialize(uri = nil, latch_timeout = 5)
      @uri            = uri || "druby://0.0.0.0:8787"
      @latch_timeout  = latch_timeout
      @config         = {}
      start_drb
      reset!
    end

    def start_drb
      @drb = DRb.start_service @uri, self
    end

    def stop_drb
      @drb.stop_service
    end

    def reset!
      @script_content = nil
      @result = nil
      @latches = {}
    end

    def trigger(latch_name)
      @latches[latch_name].tap do |latch|
        latch.countdown! if latch
      end
    end

    def add_latch(latch_name, count = 1)
      @latches[latch_name] ||= CountDownLatch.new count
    end

    def wait(latch_name)
      @latches[latch_name].tap do |latch|
        latch.wait @latch_timeout if latch
      end
    end

    def place_call(session_url)
      Net::HTTP.get URI.parse(session_url)
    end
  end
end

module RSpecRayo
  class Tropo1Driver
    require 'net/http'
    require 'uri'
    require 'countdownlatch'

    attr_accessor :script_content, :result, :drb, :config

    def initialize(uri = nil, latch_timeout = 5)
      @uri            = uri || "druby://0.0.0.0:8787"
      @drb            = DRb.start_service @uri, self
      @latch_timeout  = latch_timeout
      @config         = {}
      reset!
    end

    def reset!
      @script_content = nil
      @result = nil
      @latches = {}
    end

    def trigger(latch_name)
      @latches[latch_name].tap do |latch|
        latch.countdown! if latch
      end
    end

    def add_latch(latch_name, count = 1)
      @latches[latch_name] ||= CountDownLatch.new count
    end

    def wait(latch_name)
      @latches[latch_name].tap do |latch|
        latch.wait @latch_timeout if latch
      end
    end

    def place_call(session_url)
      Net::HTTP.get URI.parse(session_url)
    end
  end
end

--- 
+++ 
@@ -1,5 +1,6 @@
 module RSpecRayo
   class Tropo1Driver
+    require 'drb'
     require 'net/http'
     require 'uri'
     require 'countdownlatch'
@@ -8,10 +9,18 @@
 
     def initialize(uri = nil, latch_timeout = 5)
       @uri            = uri || "druby://0.0.0.0:8787"
-      @drb            = DRb.start_service @uri, self
       @latch_timeout  = latch_timeout
       @config         = {}
+      start_drb
       reset!
+    end
+
+    def start_drb
+      @drb = DRb.start_service @uri, self
+    end
+
+    def stop_drb
+      @drb.stop_service
     end
 
     def reset!
Allow a third party to stop and start Tropo1's DRb service