Class: RSpecRayo::Tropo1Driver

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec-rayo/tropo1/driver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri = nil, latch_timeout = 5) ⇒ Tropo1Driver

Returns a new instance of Tropo1Driver.



10
11
12
13
14
15
# File 'lib/rspec-rayo/tropo1/driver.rb', line 10

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

Instance Attribute Details

#configObject

Returns the value of attribute config.



8
9
10
# File 'lib/rspec-rayo/tropo1/driver.rb', line 8

def config
  @config
end

#drbObject

Returns the value of attribute drb.



8
9
10
# File 'lib/rspec-rayo/tropo1/driver.rb', line 8

def drb
  @drb
end

#resultObject

Returns the value of attribute result.



8
9
10
# File 'lib/rspec-rayo/tropo1/driver.rb', line 8

def result
  @result
end

#script_contentObject

Returns the value of attribute script_content.



8
9
10
# File 'lib/rspec-rayo/tropo1/driver.rb', line 8

def script_content
  @script_content
end

Instance Method Details

#add_latch(latch_name, count = 1) ⇒ Object



37
38
39
# File 'lib/rspec-rayo/tropo1/driver.rb', line 37

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

#place_call(session_url) ⇒ Object



47
48
49
# File 'lib/rspec-rayo/tropo1/driver.rb', line 47

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

#reset!Object



25
26
27
28
29
# File 'lib/rspec-rayo/tropo1/driver.rb', line 25

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

#start_drbObject



17
18
19
# File 'lib/rspec-rayo/tropo1/driver.rb', line 17

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

#stop_drbObject



21
22
23
# File 'lib/rspec-rayo/tropo1/driver.rb', line 21

def stop_drb
  @drb.stop_service
end

#trigger(latch_name) ⇒ Object

Raises:

  • (RuntimeError)


31
32
33
34
35
# File 'lib/rspec-rayo/tropo1/driver.rb', line 31

def trigger(latch_name)
  latch = @latches[latch_name]
  raise RuntimeError, "No latch by that name" unless latch
  latch.countdown!
end

#wait(latch_name) ⇒ Object

Raises:

  • (RuntimeError)


41
42
43
44
45
# File 'lib/rspec-rayo/tropo1/driver.rb', line 41

def wait(latch_name)
  latch = @latches[latch_name]
  raise RuntimeError, "No latch by that name" unless latch
  latch.wait @latch_timeout
end