public
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
Search Repo:
Add spec for swiftiply connector.
macournoyer (author)
Wed Feb 13 18:55:54 -0800 2008
commit  f5012ae9b02f2eed32a018a769f11e9439cc0134
tree    f83039b80d6093758dbc282f7216f2dc542419c3
parent  f5279b19f75070900fa828dd299c8b20ab029973
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
0
@@ -1 +1,67 @@
0
+require File.dirname(__FILE__) + '/../spec_helper'
0
+
0
+describe Connectors::SwiftiplyClient do
0
+ before do
0
+ @connector = Connectors::SwiftiplyClient.new('0.0.0.0', 3333)
0
+ @connector.server = mock('server', :null_object => true)
0
+ end
0
+
0
+ it "should connect" do
0
+ EventMachine.run do
0
+ @connector.connect
0
+ EventMachine.stop
0
+ end
0
+ end
0
+
0
+ it "should disconnect" do
0
+ EventMachine.run do
0
+ @connector.connect
0
+ @connector.disconnect
0
+ EventMachine.stop
0
+ end
0
+ end
0
+end
0
+
0
+describe SwiftiplyConnection do
0
+ before do
0
+ @connection = SwiftiplyConnection.new(nil)
0
+ @connection.connector = Connectors::SwiftiplyClient.new('0.0.0.0', 3333)
0
+ @connection.connector.server = mock('server', :null_object => true)
0
+ end
0
+
0
+ it do
0
+ @connection.should be_persistent
0
+ end
0
+
0
+ it "should send handshake on connection_completed" do
0
+ @connection.should_receive(:send_data).with('swiftclient000000000d0500')
0
+ @connection.connection_completed
0
+ end
0
+
0
+ it "should reconnect on unbind" do
0
+ @connection.connector.stub!(:running?).and_return(true)
0
+ @connection.stub!(:rand).and_return(0) # Make sure we don't wait
0
+
0
+ @connection.should_receive(:reconnect).with('0.0.0.0', 3333)
0
+
0
+ EventMachine.run do
0
+ @connection.unbind
0
+ EventMachine.add_timer(0) { EventMachine.stop }
0
+ end
0
+ end
0
+
0
+ it "should not reconnect when not running" do
0
+ @connection.connector.stub!(:running?).and_return(false)
0
+ EventMachine.should_not_receive(:add_timer)
0
+ @connection.unbind
0
+ end
0
+
0
+ it "should have a host_ip" do
0
+ @connection.send(:host_ip).should == [0, 0, 0, 0]
0
+ end
0
+
0
+ it "should generate swiftiply_handshake based on key" do
0
+ @connection.send(:swiftiply_handshake, 'key').should == 'swiftclient000000000d0503key'
0
+ end
0
+end

Comments

    No one has commented yet.