diff --git a/lib/cucumber/wire_support/connection.rb b/lib/cucumber/wire_support/connection.rb index 4b947b8422..6479b88d8c 100644 --- a/lib/cucumber/wire_support/connection.rb +++ b/lib/cucumber/wire_support/connection.rb @@ -42,6 +42,7 @@ def fetch_data_from_socket(timeout) else Timeout.timeout(timeout) { socket.gets } end + raise exception({'message' => "Remote Socket with #{@config.host}:#{@config.port} closed."}) if raw_response.nil? WirePacket.parse(raw_response) end diff --git a/spec/cucumber/wire_support/connection_spec.rb b/spec/cucumber/wire_support/connection_spec.rb index 673ddd6a3d..32f41ba9f6 100644 --- a/spec/cucumber/wire_support/connection_spec.rb +++ b/spec/cucumber/wire_support/connection_spec.rb @@ -19,6 +19,14 @@ def timeout(message = nil) return :default_timeout if message.nil? @custom_timeout[message] || Configuration::DEFAULT_TIMEOUTS.fetch(message) end + + def host + 'localhost' + end + + def port + '3902' + end end before(:each) do @@ -39,6 +47,14 @@ def timeout(message = nil) handler = mock(:handle_response => :response) @connection.call_remote(handler, :foo, []).should == :response end + + it "raises an exception on remote connection closed" do + @config.custom_timeout[:foo] = :never + @socket.stub(:gets => nil) + lambda { + @connection.call_remote(nil, :foo, []) + }.should raise_error(WireException, 'Remote Socket with localhost:3902 closed.') + end end end end