Class: Cucumber::WireSupport::Connection

Inherits:
Object
  • Object
show all
Includes:
WireProtocol
Defined in:
lib/cucumber/wire_support/connection.rb

Defined Under Namespace

Classes: ConnectionError

Instance Method Summary collapse

Methods included from WireProtocol

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

Constructor Details

#initialize(config) ⇒ Connection

Returns a new instance of Connection.



11
12
13
# File 'lib/cucumber/wire_support/connection.rb', line 11

def initialize(config)
  @config = config
end

Instance Method Details

#call_remote(request_handler, message, params) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cucumber/wire_support/connection.rb', line 15

def call_remote(request_handler, message, params)
  packet = WirePacket.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



28
29
30
# File 'lib/cucumber/wire_support/connection.rb', line 28

def exception(params)
  WireException.new(params, @config.host, @config.port)
end