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

Instance Method Summary collapse

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



48
49
50
# File 'lib/saorin/test.rb', line 48

def client
  @client
end

#pidObject (readonly)

Returns the value of attribute pid.



46
47
48
# File 'lib/saorin/test.rb', line 46

def pid
  @pid
end

#serverObject (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(options = {})
  @client = Saorin::Client.new({
    :url => "http://127.0.0.1:#{PORT}"
  }.merge(options))
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(options = {})
  @pid = Process.fork do
    @server = Saorin::Server.new(Handler.new, {
      :host => HOST,
      :port => PORT,
      :Logger => Logger.new('/dev/null'),
      :AccessLog => [],
    }.merge(options))
    @server.start
  end
  sleep 1
end

#shutdown_test_serverObject



63
64
65
# File 'lib/saorin/test.rb', line 63

def shutdown_test_server
  Process.kill :TERM, @pid
end

#test_batchObject



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