Class: Cucumber::Wire::Connection

Inherits:
Object
  • Object
show all
Includes:
Protocol
Defined in:
lib/cucumber/wire/connection.rb

Defined Under Namespace

Classes: ConnectionError

Instance Method Summary collapse

Methods included from Protocol

#begin_scenario, #diff_failed, #diff_ok, #end_scenario, #invoke, #snippet_text, #step_matches

Constructor Details

#initialize(config) ⇒ Connection

Returns a new instance of Connection.



13
14
15
# File 'lib/cucumber/wire/connection.rb', line 13

def initialize(config)
  @config = config
end

Instance Method Details

#call_remote(request_handler, message, params) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cucumber/wire/connection.rb', line 17

def call_remote(request_handler, message, params)
  packet = DataPacket.new(message, params)

  begin
    send_data_to_socket(packet.to_json)
    response = fetch_data_from_socket(@config.timeout(message))
    response.handle_with(request_handler)
  rescue Timeout::Error => e
    backtrace = e.backtrace ; backtrace.shift # because Timeout puts some wierd stuff in there
    raise Timeout::Error, "Timed out calling wire server with message '#{message}'", backtrace
  end
end

#exception(params) ⇒ Object



30
31
32
# File 'lib/cucumber/wire/connection.rb', line 30

def exception(params)
  Wire::Exception.new(params, @config)
end