Module: Saorin::Test
- Defined in:
- lib/saorin/test.rb
Defined Under Namespace
Classes: Handler
Constant Summary collapse
- HOST =
'127.0.0.1'
- PORT =
45339
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #create_test_client(options = {}) ⇒ Object
- #create_test_server(options = {}) ⇒ Object
- #shutdown_test_server ⇒ Object
- #test_batch ⇒ Object
- #test_call(*args) ⇒ Object
- #test_notify(*args) ⇒ Object
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
48 49 50 |
# File 'lib/saorin/test.rb', line 48 def client @client end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
46 47 48 |
# File 'lib/saorin/test.rb', line 46 def pid @pid end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
47 48 49 |
# File 'lib/saorin/test.rb', line 47 def server @server end |
Instance Method Details
#create_test_client(options = {}) ⇒ Object
67 68 69 70 71 |
# File 'lib/saorin/test.rb', line 67 def create_test_client( = {}) @client = Saorin::Client.new({ :url => "http://127.0.0.1:#{PORT}" }.merge()) end |
#create_test_server(options = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/saorin/test.rb', line 50 def create_test_server( = {}) @pid = Process.fork do @server = Saorin::Server.new(Handler.new, { :host => HOST, :port => PORT, :Logger => Logger.new('/dev/null'), :AccessLog => [], }.merge()) @server.start end sleep 1 end |
#shutdown_test_server ⇒ Object
63 64 65 |
# File 'lib/saorin/test.rb', line 63 def shutdown_test_server Process.kill :TERM, @pid end |
#test_batch ⇒ Object
81 82 83 |
# File 'lib/saorin/test.rb', line 81 def test_batch @client.batch end |
#test_call(*args) ⇒ Object
73 74 75 |
# File 'lib/saorin/test.rb', line 73 def test_call(*args) @client.call *args end |
#test_notify(*args) ⇒ Object
77 78 79 |
# File 'lib/saorin/test.rb', line 77 def test_notify(*args) @client.notify *args end |