Skip to content

Commit

Permalink
Merge pull request #348 from rdammkoehler/fix_remote_wire_fail_error
Browse files Browse the repository at this point in the history
raises exception when remote socket end disconnects
  • Loading branch information
mattwynne committed Feb 25, 2013
2 parents 9a0c6dd + 8b49a83 commit 3f1c34b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/cucumber/wire_support/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 16 additions & 0 deletions spec/cucumber/wire_support/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 3f1c34b

Please sign in to comment.