Class: EchSpec::Spec::WithSocket
- Inherits:
-
Object
- Object
- EchSpec::Spec::WithSocket
- Defined in:
- lib/echspec/spec.rb
Direct Known Subclasses
Spec5_1_10, Spec5_1_9, Spec7_1_11, Spec7_1_14_2_1, Spec7_1_1_2, Spec7_1_1_5, Spec7_5
Instance Method Summary collapse
-
#initialize ⇒ WithSocket
constructor
A new instance of WithSocket.
- #message_stack ⇒ Object
- #with_socket(hostname, port) ⇒ Object
Constructor Details
#initialize ⇒ WithSocket
Returns a new instance of WithSocket.
74 75 76 |
# File 'lib/echspec/spec.rb', line 74 def initialize @stack = Log::MessageStack.new end |
Instance Method Details
#message_stack ⇒ Object
78 79 80 |
# File 'lib/echspec/spec.rb', line 78 def @stack.marshal end |
#with_socket(hostname, port) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/echspec/spec.rb', line 61 def with_socket(hostname, port) socket = TCPSocket.new(hostname, port) yield(socket) rescue Timeout::Error Err.new("#{hostname}:#{port} connection timeout", ) rescue Errno::ECONNREFUSED Err.new("#{hostname}:#{port} connection refused", ) rescue Error::BeforeTargetSituationError => e Err.new(e., ) ensure socket&.close end |