Class: BlitzSMTP::MockServer
- Inherits:
-
Object
- Object
- BlitzSMTP::MockServer
- Defined in:
- lib/blitz_smtp/mock_server.rb
Instance Attribute Summary collapse
-
#accepted_emails ⇒ Object
Returns the value of attribute accepted_emails.
-
#esmtp ⇒ Object
Returns the value of attribute esmtp.
-
#features ⇒ Object
Returns the value of attribute features.
Instance Method Summary collapse
- #address ⇒ Object
- #connected_to_client? ⇒ Boolean
-
#initialize ⇒ MockServer
constructor
A new instance of MockServer.
- #port ⇒ Object
- #shutdown! ⇒ Object
Constructor Details
#initialize ⇒ MockServer
Returns a new instance of MockServer.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/blitz_smtp/mock_server.rb', line 9 def initialize @esmtp = true @features = [] @accepted_emails = [] @server_socket = TCPServer.new(address, 0) @server_thread = Thread.start do loop do @client_socket = @server_socket.accept mock_smtp end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, command, *_) ⇒ Object (protected)
100 101 102 103 |
# File 'lib/blitz_smtp/mock_server.rb', line 100 def method_missing(method, command, *_) puts "could not identify #{command} [##{method}]" send_command_unknown(command) end |
Instance Attribute Details
#accepted_emails ⇒ Object
Returns the value of attribute accepted_emails.
7 8 9 |
# File 'lib/blitz_smtp/mock_server.rb', line 7 def accepted_emails @accepted_emails end |
#esmtp ⇒ Object
Returns the value of attribute esmtp.
7 8 9 |
# File 'lib/blitz_smtp/mock_server.rb', line 7 def esmtp @esmtp end |
#features ⇒ Object
Returns the value of attribute features.
7 8 9 |
# File 'lib/blitz_smtp/mock_server.rb', line 7 def features @features end |
Instance Method Details
#address ⇒ Object
22 23 24 |
# File 'lib/blitz_smtp/mock_server.rb', line 22 def address "localhost" end |
#connected_to_client? ⇒ Boolean
30 31 32 |
# File 'lib/blitz_smtp/mock_server.rb', line 30 def connected_to_client? not @client_socket.nil? end |
#port ⇒ Object
26 27 28 |
# File 'lib/blitz_smtp/mock_server.rb', line 26 def port @server_socket.connect_address.ip_port end |
#shutdown! ⇒ Object
34 35 36 37 38 |
# File 'lib/blitz_smtp/mock_server.rb', line 34 def shutdown! @server_thread.kill @client_socket.close if connected_to_client? @server_socket.close end |