mongrel2 0.38.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/History.rdoc +6 -0
  5. data/Manifest.txt +5 -3
  6. data/Rakefile +2 -2
  7. data/data/mongrel2/config.sql +6 -1
  8. data/lib/mongrel2.rb +5 -2
  9. data/lib/mongrel2/config.rb +1 -0
  10. data/lib/mongrel2/config/server.rb +15 -0
  11. data/lib/mongrel2/config/xrequest.rb +45 -0
  12. data/lib/mongrel2/connection.rb +4 -5
  13. data/lib/mongrel2/control.rb +2 -2
  14. data/lib/mongrel2/handler.rb +1 -1
  15. data/spec/{lib/constants.rb → constants.rb} +0 -2
  16. data/spec/{lib/helpers.rb → helpers.rb} +9 -12
  17. data/spec/{lib/matchers.rb → matchers.rb} +2 -12
  18. data/spec/mongrel2/config/directory_spec.rb +16 -27
  19. data/spec/mongrel2/config/dsl_spec.rb +115 -98
  20. data/spec/mongrel2/config/filter_spec.rb +1 -12
  21. data/spec/mongrel2/config/handler_spec.rb +23 -33
  22. data/spec/mongrel2/config/host_spec.rb +1 -12
  23. data/spec/mongrel2/config/log_spec.rb +13 -24
  24. data/spec/mongrel2/config/proxy_spec.rb +1 -12
  25. data/spec/mongrel2/config/route_spec.rb +5 -15
  26. data/spec/mongrel2/config/server_spec.rb +23 -34
  27. data/spec/mongrel2/config/setting_spec.rb +1 -12
  28. data/spec/mongrel2/config/statistic_spec.rb +1 -12
  29. data/spec/mongrel2/config/xrequest_spec.rb +19 -0
  30. data/spec/mongrel2/config_spec.rb +17 -29
  31. data/spec/mongrel2/connection_spec.rb +41 -53
  32. data/spec/mongrel2/constants_spec.rb +2 -14
  33. data/spec/mongrel2/control_spec.rb +44 -56
  34. data/spec/mongrel2/handler_spec.rb +64 -76
  35. data/spec/mongrel2/httprequest_spec.rb +21 -31
  36. data/spec/mongrel2/httpresponse_spec.rb +55 -67
  37. data/spec/mongrel2/request_spec.rb +53 -62
  38. data/spec/mongrel2/response_spec.rb +15 -24
  39. data/spec/mongrel2/table_spec.rb +41 -53
  40. data/spec/mongrel2/websocket_spec.rb +95 -104
  41. data/spec/mongrel2_spec.rb +3 -12
  42. metadata +13 -11
  43. metadata.gz.sig +0 -0
@@ -1,19 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- BEGIN {
4
- require 'pathname'
5
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent
6
-
7
- libdir = basedir + "lib"
8
-
9
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
10
- $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
11
- }
3
+ require_relative '../../helpers'
12
4
 
13
5
  require 'rspec'
14
-
15
- require 'spec/lib/helpers'
16
-
17
6
  require 'mongrel2'
18
7
  require 'mongrel2/config'
19
8
 
@@ -1,19 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- BEGIN {
4
- require 'pathname'
5
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent
6
-
7
- libdir = basedir + "lib"
8
-
9
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
10
- $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
11
- }
3
+ require_relative '../../helpers'
12
4
 
13
5
  require 'rspec'
14
-
15
- require 'spec/lib/helpers'
16
-
17
6
  require 'mongrel2'
18
7
  require 'mongrel2/config'
19
8
 
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../../helpers'
4
+
5
+ require 'rspec'
6
+ require 'mongrel2'
7
+ require 'mongrel2/config'
8
+
9
+
10
+ #####################################################################
11
+ ### C O N T E X T S
12
+ #####################################################################
13
+
14
+ describe Mongrel2::Config::XRequest do
15
+
16
+ # No functionality outside of Sequel::Model's purview yet
17
+
18
+ end
19
+
@@ -1,18 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- BEGIN {
4
- require 'pathname'
5
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent
6
-
7
- libdir = basedir + "lib"
8
-
9
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
10
- $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
11
- }
12
-
13
- require 'rspec'
14
-
15
- require 'spec/lib/helpers'
3
+ require_relative '../helpers'
16
4
 
17
5
  require 'mongrel2'
18
6
  require 'mongrel2/config'
@@ -25,7 +13,7 @@ require 'mongrel2/config'
25
13
  describe Mongrel2::Config do
26
14
 
27
15
  before( :all ) do
28
- setup_logging( :fatal )
16
+ setup_logging()
29
17
  setup_config_db()
30
18
  end
31
19
 
@@ -38,8 +26,8 @@ describe Mongrel2::Config do
38
26
  it "has a factory method for creating derivative classes" do
39
27
  begin
40
28
  model_class = Mongrel2::Config( :hookers )
41
- model_class.should < Mongrel2::Config
42
- model_class.dataset.first_source.should == :hookers
29
+ expect( model_class ).to satisfy {|klass| klass < Mongrel2::Config }
30
+ expect( model_class.dataset.first_source ).to eq( :hookers )
43
31
  ensure
44
32
  # Remove the example class from the list of subclasses so it
45
33
  # doesn't affect later tests
@@ -50,7 +38,7 @@ describe Mongrel2::Config do
50
38
  it "can reset the database handle for the config classes" do
51
39
  db = Mongrel2::Config.in_memory_db
52
40
  Mongrel2::Config.db = db
53
- Mongrel2::Config::Directory.db.should equal( db )
41
+ expect( Mongrel2::Config::Directory.db ).to equal( db )
54
42
  end
55
43
 
56
44
  it "has a convenience method for fetching an Array of all of its configured servers" do
@@ -65,47 +53,47 @@ describe Mongrel2::Config do
65
53
  default_host: 'localhost',
66
54
  port: 8275
67
55
  )
68
- Mongrel2::Config.servers.should have( 1 ).member
69
- Mongrel2::Config.servers.first.uuid.should == TEST_UUID
56
+ expect( Mongrel2::Config.servers ).to have( 1 ).member
57
+ expect( Mongrel2::Config.servers.first.uuid ).to eq( TEST_UUID )
70
58
  end
71
59
 
72
60
  it "has a convenience method for getting a setting's value" do
73
61
  Mongrel2::Config.init_database
74
62
  Mongrel2::Config::Setting.dataset.truncate
75
63
  Mongrel2::Config::Setting.create( key: 'control_port', value: 'ipc://var/run/control.sock' )
76
- Mongrel2::Config.settings.should respond_to( :[] )
77
- Mongrel2::Config.settings.should have( 1 ).member
78
- Mongrel2::Config.settings[ :control_port ].should == 'ipc://var/run/control.sock'
64
+ expect( Mongrel2::Config.settings ).to respond_to( :[] )
65
+ expect( Mongrel2::Config.settings ).to have( 1 ).member
66
+ expect( Mongrel2::Config.settings[ :control_port ] ).to eq( 'ipc://var/run/control.sock' )
79
67
  end
80
68
 
81
69
  it "can read the configuration schema from a data file" do
82
- Mongrel2::Config.load_config_schema.should =~ /create table server/i
70
+ expect( Mongrel2::Config.load_config_schema ).to match( /create table server/i )
83
71
  end
84
72
 
85
73
  it "knows whether or not its database has been initialized" do
86
74
  Mongrel2::Config.db = Mongrel2::Config.in_memory_db
87
- Mongrel2::Config.database_initialized?.should be_false()
75
+ expect( Mongrel2::Config.database_initialized? ).to be_false()
88
76
  Mongrel2::Config.init_database!
89
- Mongrel2::Config.database_initialized?.should be_true()
77
+ expect( Mongrel2::Config.database_initialized? ).to be_true()
90
78
  end
91
79
 
92
80
  it "doesn't re-initialize the database if the non-bang version of init_database is used" do
93
81
  Mongrel2::Config.db = Mongrel2::Config.in_memory_db
94
82
  Mongrel2::Config.init_database
95
83
 
96
- Mongrel2::Config.should_not_receive( :load_config_schema )
84
+ expect( Mongrel2::Config ).to_not receive( :load_config_schema )
97
85
  Mongrel2::Config.init_database
98
86
  end
99
87
 
100
88
  it "can return the path to the config DB as a Pathname if it's pointing at a file" do
101
89
  Mongrel2::Config.db = Sequel.
102
90
  connect( adapter: Mongrel2::Config.sqlite_adapter, database: 'config-spec.sqlite' )
103
- Mongrel2::Config.dbname.should == 'config-spec.sqlite'
91
+ expect( Mongrel2::Config.dbname ).to eq( 'config-spec.sqlite' )
104
92
  end
105
93
 
106
94
  it "returns nil if asked for the pathname to an in-memory database" do
107
95
  Mongrel2::Config.db = Mongrel2::Config.in_memory_db
108
- Mongrel2::Config.dbname.should be_nil()
96
+ expect( Mongrel2::Config.dbname ).to be_nil()
109
97
  end
110
98
 
111
99
  describe "Configurability support", :if => defined?( Configurability ) do
@@ -114,7 +102,7 @@ describe Mongrel2::Config do
114
102
  it_should_behave_like "an object with Configurability"
115
103
 
116
104
  it "uses the 'mongrel2' config section" do
117
- Mongrel2::Config.config_key.should == :mongrel2
105
+ expect( Mongrel2::Config.config_key ).to eq( :mongrel2 )
118
106
  end
119
107
 
120
108
  end
@@ -1,18 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- BEGIN {
4
- require 'pathname'
5
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent
6
-
7
- libdir = basedir + "lib"
8
-
9
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
10
- $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
11
- }
12
-
13
- require 'rspec'
14
-
15
- require 'spec/lib/helpers'
3
+ require_relative '../helpers'
16
4
 
17
5
  require 'mongrel2'
18
6
  require 'mongrel2/connection'
@@ -26,7 +14,7 @@ describe Mongrel2::Connection do
26
14
  include Mongrel2::Config::DSL
27
15
 
28
16
  before( :all ) do
29
- setup_logging( :fatal )
17
+ setup_logging()
30
18
  end
31
19
 
32
20
  # Ensure 0MQ never actually gets called
@@ -47,54 +35,54 @@ describe Mongrel2::Connection do
47
35
 
48
36
 
49
37
  it "doesn't connect to the endpoints when it's created" do
50
- @conn.instance_variable_get( :@request_sock ).should be_nil()
51
- @conn.instance_variable_get( :@response_sock ).should be_nil()
38
+ expect( @conn.instance_variable_get( :@request_sock ) ).to be_nil()
39
+ expect( @conn.instance_variable_get( :@response_sock ) ).to be_nil()
52
40
  end
53
41
 
54
42
  it "connects to the endpoints specified on demand" do
55
43
  request_sock = double( "request socket" )
56
44
  response_sock = double( "response socket" )
57
45
 
58
- @ctx.should_receive( :socket ).with( ZMQ::PULL ).and_return( request_sock )
59
- request_sock.should_receive( :setsockopt ).with( ZMQ::LINGER, 0 )
60
- request_sock.should_receive( :connect ).with( TEST_SEND_SPEC )
46
+ expect( @ctx ).to receive( :socket ).with( :PULL ).and_return( request_sock )
47
+ expect( request_sock ).to receive( :linger= ).with( 0 )
48
+ expect( request_sock ).to receive( :connect ).with( TEST_SEND_SPEC )
61
49
 
62
- @ctx.should_receive( :socket ).with( ZMQ::PUB ).and_return( response_sock )
63
- response_sock.should_receive( :setsockopt ).with( ZMQ::LINGER, 0 )
64
- response_sock.should_receive( :setsockopt ).with( ZMQ::IDENTITY, /^[[:xdigit:]]{40}$/ )
65
- response_sock.should_receive( :connect ).with( TEST_RECV_SPEC )
50
+ expect( @ctx ).to receive( :socket ).with( :PUB ).and_return( response_sock )
51
+ expect( response_sock ).to receive( :linger= ).with( 0 )
52
+ expect( response_sock ).to_not receive( :identity= )
53
+ expect( response_sock ).to receive( :connect ).with( TEST_RECV_SPEC )
66
54
 
67
- @conn.request_sock.should == request_sock
68
- @conn.response_sock.should == response_sock
55
+ expect( @conn.request_sock ).to eq( request_sock )
56
+ expect( @conn.response_sock ).to eq( response_sock )
69
57
  end
70
58
 
71
59
  it "stringifies as a description of the appid and both sockets" do
72
- @conn.to_s.should == "{#{TEST_UUID}} #{TEST_SEND_SPEC} <-> #{TEST_RECV_SPEC}"
60
+ expect( @conn.to_s ).to eq( "{#{TEST_UUID}} #{TEST_SEND_SPEC} <-> #{TEST_RECV_SPEC}" )
73
61
  end
74
62
 
75
63
  context "after a connection has been established" do
76
64
 
77
65
  before( :each ) do
78
- @request_sock = double( "request socket", :setsockopt => nil, :connect => nil )
79
- @response_sock = double( "response socket", :setsockopt => nil, :connect => nil )
66
+ @request_sock = double( "request socket", :linger= => nil, :connect => nil )
67
+ @response_sock = double( "response socket", :linger= => nil, :connect => nil )
80
68
 
81
- @ctx.stub( :socket ).with( ZMQ::PULL ).and_return( @request_sock )
82
- @ctx.stub( :socket ).with( ZMQ::PUB ).and_return( @response_sock )
69
+ allow( @ctx ).to receive( :socket ).with( :PULL ).and_return( @request_sock )
70
+ allow( @ctx ).to receive( :socket ).with( :PUB ).and_return( @response_sock )
83
71
 
84
72
  @conn.connect
85
73
  end
86
74
 
87
75
 
88
76
  it "closes both of its sockets when closed" do
89
- @request_sock.should_receive( :close )
90
- @response_sock.should_receive( :close )
77
+ expect( @request_sock ).to receive( :close )
78
+ expect( @response_sock ).to receive( :close )
91
79
 
92
80
  @conn.close
93
81
  end
94
82
 
95
83
  it "raises an exception if asked to fetch data after being closed" do
96
- @request_sock.stub( :close )
97
- @response_sock.stub( :close )
84
+ allow( @request_sock ).to receive( :close )
85
+ allow( @response_sock ).to receive( :close )
98
86
 
99
87
  @conn.close
100
88
 
@@ -104,69 +92,69 @@ describe Mongrel2::Connection do
104
92
  end
105
93
 
106
94
  it "doesn't keep its request and response sockets when duped" do
107
- request_sock2 = double( "request socket", :setsockopt => nil, :connect => nil )
108
- response_sock2 = double( "response socket", :setsockopt => nil, :connect => nil )
109
- @ctx.stub( :socket ).with( ZMQ::PULL ).and_return( request_sock2 )
110
- @ctx.stub( :socket ).with( ZMQ::PUB ).and_return( response_sock2 )
95
+ request_sock2 = double( "request socket", :linger= => nil, :connect => nil )
96
+ response_sock2 = double( "response socket", :linger= => nil, :connect => nil )
97
+ allow( @ctx ).to receive( :socket ).with( :PULL ).and_return( request_sock2 )
98
+ allow( @ctx ).to receive( :socket ).with( :PUB ).and_return( response_sock2 )
111
99
 
112
100
  duplicate = @conn.dup
113
101
 
114
- duplicate.request_sock.should == request_sock2
115
- duplicate.response_sock.should == response_sock2
102
+ expect( duplicate.request_sock ).to eq( request_sock2 )
103
+ expect( duplicate.response_sock ).to eq( response_sock2 )
116
104
  end
117
105
 
118
106
  it "doesn't keep its closed state when duped" do
119
- @request_sock.should_receive( :close )
120
- @response_sock.should_receive( :close )
107
+ expect( @request_sock ).to receive( :close )
108
+ expect( @response_sock ).to receive( :close )
121
109
 
122
110
  @conn.close
123
111
 
124
112
  duplicate = @conn.dup
125
- duplicate.should_not be_closed()
113
+ expect( duplicate ).to_not be_closed()
126
114
  end
127
115
 
128
116
  it "can read raw request messages off of the request_sock" do
129
- @request_sock.should_receive( :recv ).and_return( "the data" )
130
- @conn.recv.should == "the data"
117
+ expect( @request_sock ).to receive( :recv ).and_return( "the data" )
118
+ expect( @conn.recv ).to eq( "the data" )
131
119
  end
132
120
 
133
121
  it "can read request messages off of the request_sock as Mongrel2::Request objects" do
134
122
  msg = make_request()
135
- @request_sock.should_receive( :recv ).and_return( msg )
136
- @conn.receive.should be_a( Mongrel2::Request )
123
+ expect( @request_sock ).to receive( :recv ).and_return( msg )
124
+ expect( @conn.receive ).to be_a( Mongrel2::Request )
137
125
  end
138
126
 
139
127
  it "can write raw response messages with a TNetString header onto the response_sock" do
140
- @response_sock.should_receive( :send ).with( "#{TEST_UUID} 1:8, the data" )
128
+ expect( @response_sock ).to receive( :send ).with( "#{TEST_UUID} 1:8, the data" )
141
129
  @conn.send( TEST_UUID, 8, "the data" )
142
130
  end
143
131
 
144
132
  it "can write Mongrel2::Responses to the response_sock" do
145
- @response_sock.should_receive( :send ).with( "#{TEST_UUID} 1:8, the data" )
133
+ expect( @response_sock ).to receive( :send ).with( "#{TEST_UUID} 1:8, the data" )
146
134
 
147
135
  response = Mongrel2::Response.new( TEST_UUID, 8, 'the data' )
148
136
  @conn.reply( response )
149
137
  end
150
138
 
151
139
  it "can write raw response messages to more than one conn_id at the same time" do
152
- @response_sock.should_receive( :send ).with( "#{TEST_UUID} 15:8 16 44 45 1833, the data" )
140
+ expect( @response_sock ).to receive( :send ).with( "#{TEST_UUID} 15:8 16 44 45 1833, the data" )
153
141
  @conn.broadcast( TEST_UUID, [8, 16, 44, 45, 1833], 'the data' )
154
142
  end
155
143
 
156
144
  it "can write raw response messages to more than one conn_id at the same time" do
157
- @response_sock.should_receive( :send ).with( "#{TEST_UUID} 15:8 16 44 45 1833, the data" )
145
+ expect( @response_sock ).to receive( :send ).with( "#{TEST_UUID} 15:8 16 44 45 1833, the data" )
158
146
  @conn.broadcast( TEST_UUID, [8, 16, 44, 45, 1833], 'the data' )
159
147
  end
160
148
 
161
149
  it "can tell the connection a request or a response was from to close" do
162
- @response_sock.should_receive( :send ).with( "#{TEST_UUID} 1:8, " )
150
+ expect( @response_sock ).to receive( :send ).with( "#{TEST_UUID} 1:8, " )
163
151
 
164
152
  response = Mongrel2::Response.new( TEST_UUID, 8 )
165
153
  @conn.reply_close( response )
166
154
  end
167
155
 
168
156
  it "can broadcast a close to multiple connection IDs" do
169
- @response_sock.should_receive( :send ).with( "#{TEST_UUID} 15:8 16 44 45 1833, " )
157
+ expect( @response_sock ).to receive( :send ).with( "#{TEST_UUID} 15:8 16 44 45 1833, " )
170
158
  @conn.broadcast_close( TEST_UUID, [8, 16, 44, 45, 1833] )
171
159
  end
172
160
 
@@ -1,18 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- BEGIN {
4
- require 'pathname'
5
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent
6
-
7
- libdir = basedir + "lib"
8
-
9
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
10
- $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
11
- }
12
-
13
- require 'rspec'
14
-
15
- require 'spec/lib/helpers'
3
+ require_relative '../helpers'
16
4
 
17
5
  require 'mongrel2'
18
6
  require 'mongrel2/connection'
@@ -25,7 +13,7 @@ require 'mongrel2/connection'
25
13
  describe Mongrel2::Constants do
26
14
 
27
15
  it "defines a default configuration URI" do
28
- Mongrel2::Constants.constants.map( &:to_sym ).should include( :DEFAULT_CONFIG_URI )
16
+ expect( Mongrel2::Constants.constants.map( &:to_sym ) ).to include( :DEFAULT_CONFIG_URI )
29
17
  end
30
18
 
31
19
  end
@@ -1,18 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- BEGIN {
4
- require 'pathname'
5
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent
6
-
7
- libdir = basedir + "lib"
8
-
9
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
10
- $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
11
- }
12
-
13
- require 'rspec'
14
-
15
- require 'spec/lib/helpers'
3
+ require_relative '../helpers'
16
4
 
17
5
  require 'mongrel2'
18
6
  require 'mongrel2/control'
@@ -25,17 +13,17 @@ require 'mongrel2/control'
25
13
  describe Mongrel2::Control do
26
14
 
27
15
  before( :all ) do
28
- setup_logging( :fatal )
16
+ setup_logging()
29
17
  end
30
18
 
31
19
  before( :each ) do
32
20
  @ctx = double( "ZMQ::Context" )
33
- @socket = double( "ZMQ REQ socket", :connect => nil, :setsockopt => nil )
34
- @ctx.stub( :socket ).with( ZMQ::REQ ).and_return( @socket )
21
+ @socket = double( "ZMQ REQ socket", :connect => nil, :linger= => nil )
22
+ allow( @ctx ).to receive( :socket ).with( :REQ ).and_return( @socket )
35
23
 
36
24
  Mongrel2.instance_variable_set( :@zmq_ctx, @ctx )
37
25
 
38
- FileTest.stub( :socket? ).with( 'var/run/control' ). and_return( true )
26
+ allow( FileTest ).to receive( :socket? ).with( 'var/run/control' ). and_return( true )
39
27
 
40
28
  @control = Mongrel2::Control.new( 'ipc://var/run/control' )
41
29
  end
@@ -47,29 +35,29 @@ describe Mongrel2::Control do
47
35
 
48
36
 
49
37
  it "sends a 'stop' command to the control port when #stop is called" do
50
- @socket.should_receive( :send ).with( "10:4:stop,0:}]" )
51
- @socket.should_receive( :recv ).
38
+ expect( @socket ).to receive( :send ).with( "10:4:stop,0:}]" )
39
+ expect( @socket ).to receive( :recv ).
52
40
  and_return( "59:7:headers,6:3:msg,]4:rows,29:25:21:signal sent to server,]]}" )
53
- @control.stop.should == [{ :msg => "signal sent to server" }]
41
+ expect( @control.stop ).to eq( [{ :msg => "signal sent to server" }] )
54
42
  end
55
43
 
56
44
  it "sends a 'reload' command to the control port when #reload is called" do
57
- @socket.should_receive( :send ).with( "12:6:reload,0:}]" )
58
- @socket.should_receive( :recv ).
45
+ expect( @socket ).to receive( :send ).with( "12:6:reload,0:}]" )
46
+ expect( @socket ).to receive( :recv ).
59
47
  and_return( "59:7:headers,6:3:msg,]4:rows,29:25:21:signal sent to server,]]}" )
60
- @control.reload.should == [{ :msg => "signal sent to server" }]
48
+ expect( @control.reload ).to eq( [{ :msg => "signal sent to server" }] )
61
49
  end
62
50
 
63
51
  it "sends a 'terminate' command to the control port when #terminate is called" do
64
- @socket.should_receive( :send ).with( "15:9:terminate,0:}]" )
65
- @socket.should_receive( :recv ).
52
+ expect( @socket ).to receive( :send ).with( "15:9:terminate,0:}]" )
53
+ expect( @socket ).to receive( :recv ).
66
54
  and_return( "59:7:headers,6:3:msg,]4:rows,29:25:21:signal sent to server,]]}" )
67
- @control.terminate.should == [{ :msg => "signal sent to server" }]
55
+ expect( @control.terminate ).to eq( [{ :msg => "signal sent to server" }] )
68
56
  end
69
57
 
70
58
  it "sends a 'help' command to the control port when #help is called" do
71
- @socket.should_receive( :send ).with( "10:4:help,0:}]" )
72
- @socket.should_receive( :recv ).
59
+ expect( @socket ).to receive( :send ).with( "10:4:help,0:}]" )
60
+ expect( @socket ).to receive( :recv ).
73
61
  and_return( "416:7:headers,14:4:name,4:help,]4:rows,376:35:4:stop" +
74
62
  ",24:stop the server (SIGINT),]30:6:reload,17:reload " +
75
63
  "the server,]23:4:help,12:this command,]37:12:control" +
@@ -79,7 +67,7 @@ describe Mongrel2::Control do
79
67
  "8:4:time,17:the server's time,]28:4:uuid,17:the serv" +
80
68
  "er's uuid,]40:4:info,29:information about this serve" +
81
69
  "r,]]}" )
82
- @control.help.should == [
70
+ expect( @control.help ).to eq([
83
71
  {:name => "stop", :help => "stop the server (SIGINT)"},
84
72
  {:name => "reload", :help => "reload the server"},
85
73
  {:name => "help", :help => "this command"},
@@ -90,27 +78,27 @@ describe Mongrel2::Control do
90
78
  {:name => "time", :help => "the server's time"},
91
79
  {:name => "uuid", :help => "the server's uuid"},
92
80
  {:name => "info", :help => "information about this server"}
93
- ]
81
+ ])
94
82
  end
95
83
 
96
84
  it "sends a 'uuid' command to the control port when #uuid is called" do
97
- @socket.should_receive( :send ).with( "10:4:uuid,0:}]" )
98
- @socket.should_receive( :recv ).
85
+ expect( @socket ).to receive( :send ).with( "10:4:uuid,0:}]" )
86
+ expect( @socket ).to receive( :recv ).
99
87
  and_return( "75:7:headers,7:4:uuid,]4:rows,44:40:36:34D8E57C-3E91" +
100
88
  "-4F24-9BBE-0B53C1827CB4,]]}" )
101
- @control.uuid.should == [{ :uuid => '34D8E57C-3E91-4F24-9BBE-0B53C1827CB4' }]
89
+ expect( @control.uuid ).to eq( [{ :uuid => '34D8E57C-3E91-4F24-9BBE-0B53C1827CB4' }] )
102
90
  end
103
91
 
104
92
  it "sends an 'info' command to the control port when #info is called" do
105
- @socket.should_receive( :send ).with( "10:4:info,0:}]" )
106
- @socket.should_receive( :recv ).
93
+ expect( @socket ).to receive( :send ).with( "10:4:info,0:}]" )
94
+ expect( @socket ).to receive( :recv ).
107
95
  and_return( "260:7:headers,92:4:port,9:bind_addr,4:uuid,6:chroot," +
108
96
  "10:access_log,9:error_log,8:pid_file,16:default_host" +
109
97
  "name,]4:rows,142:137:4:8113#7:0.0.0.0,36:34D8E57C-3E" +
110
98
  "91-4F24-9BBE-0B53C1827CB4,2:./,18:.//logs/access.log" +
111
99
  ",15:/logs/error.log,18:./run/mongrel2.pid,9:localhos" +
112
100
  "t,]]}" )
113
- @control.info.should == [{
101
+ expect( @control.info ).to eq([{
114
102
  :port => 8113,
115
103
  :bind_addr => "0.0.0.0",
116
104
  :uuid => "34D8E57C-3E91-4F24-9BBE-0B53C1827CB4",
@@ -119,14 +107,14 @@ describe Mongrel2::Control do
119
107
  :error_log => "/logs/error.log",
120
108
  :pid_file => "./run/mongrel2.pid",
121
109
  :default_hostname => "localhost"
122
- }]
110
+ }])
123
111
  end
124
112
 
125
113
  it "sends a 'status' command with a 'what' option set to 'tasks' to the control port " +
126
114
  "when #tasklist is called" do
127
115
 
128
- @socket.should_receive( :send ).with( "28:6:status,15:4:what,5:tasks,}]" )
129
- @socket.should_receive( :recv ).
116
+ expect( @socket ).to receive( :send ).with( "28:6:status,15:4:what,5:tasks,}]" )
117
+ expect( @socket ).to receive( :recv ).
130
118
  and_return( "343:7:headers,38:2:id,6:system,4:name,5:state,6:status," +
131
119
  "]4:rows,279:38:1:1#5:false!6:SERVER,7:read fd,4:idle,]5" +
132
120
  "1:1:2#5:false!12:Handler_task,12:read handler,4:idle,]5" +
@@ -134,55 +122,55 @@ describe Mongrel2::Control do
134
122
  "8:1:4#5:false!7:control,12:read handler,7:running,]31:1" +
135
123
  ":5#5:false!6:ticker,0:,4:idle,]36:1:6#4:true!6:fdtask,5" +
136
124
  ":yield,5:ready,]]}" )
137
- @control.tasklist.should == [
125
+ expect( @control.tasklist ).to eq([
138
126
  {:id=>1, :system=>false, :name=>"SERVER", :state=>"read fd", :status=>"idle"},
139
127
  {:id=>2, :system=>false, :name=>"Handler_task", :state=>"read handler", :status=>"idle"},
140
128
  {:id=>3, :system=>false, :name=>"Handler_task", :state=>"read handler", :status=>"idle"},
141
129
  {:id=>4, :system=>false, :name=>"control", :state=>"read handler", :status=>"running"},
142
130
  {:id=>5, :system=>false, :name=>"ticker", :state=>"", :status=>"idle"},
143
131
  {:id=>6, :system=>true, :name=>"fdtask", :state=>"yield", :status=>"ready"}
144
- ]
132
+ ])
145
133
  end
146
134
 
147
135
  it "sends an 'status' command with a 'what' option set to 'net' to the control port " +
148
136
  "when #conn_status is called" do
149
137
 
150
- @socket.should_receive( :send ).with( "26:6:status,13:4:what,3:net,}]" )
151
- @socket.should_receive( :recv ).
138
+ expect( @socket ).to receive( :send ).with( "26:6:status,13:4:what,3:net,}]" )
139
+ expect( @socket ).to receive( :recv ).
152
140
  and_return( "150:7:headers,86:2:id,2:fd,4:type,9:last_ping,9:last_read," +
153
141
  "10:last_write,10:bytes_read,13:bytes_written,]4:rows,39:35" +
154
142
  ":1:2#2:38#1:1#1:0#1:0#1:0#3:405#1:0#]]}" )
155
- @control.conn_status.should == [
143
+ expect( @control.conn_status ).to eq([
156
144
  {:id=>2, :fd=>38, :type=>1, :last_ping=>0, :last_read=>0, :last_write=>0,
157
145
  :bytes_read=>405, :bytes_written=>0}
158
- ]
146
+ ])
159
147
  end
160
148
 
161
149
  it "sends a 'time' command to the control port when #time is called" do
162
- @socket.should_receive( :send ).with( "10:4:time,0:}]" )
163
- @socket.should_receive( :recv ).
150
+ expect( @socket ).to receive( :send ).with( "10:4:time,0:}]" )
151
+ expect( @socket ).to receive( :recv ).
164
152
  and_return( "49:7:headers,7:4:time,]4:rows,18:14:10:1315532674,]]}" )
165
- @control.time.should == Time.at( 1315532674 )
153
+ expect( @control.time ).to eq( Time.at( 1315532674 ) )
166
154
  end
167
155
 
168
156
  it "sends a 'kill' command with an ID equal to the argument to the control port when #kill " +
169
157
  "is called" do
170
- @socket.should_receive( :send ).with( "19:4:kill,9:2:id,1:0#}]" )
171
- @socket.should_receive( :recv ).and_return( "40:7:headers,9:6:status,]4:rows,8:5:2:OK,]]}" )
172
- @control.kill( 0 ).should == [{ :status => "OK" }]
158
+ expect( @socket ).to receive( :send ).with( "19:4:kill,9:2:id,1:0#}]" )
159
+ expect( @socket ).to receive( :recv ).and_return( "40:7:headers,9:6:status,]4:rows,8:5:2:OK,]]}" )
160
+ expect( @control.kill( 0 ) ).to eq( [{ :status => "OK" }] )
173
161
  end
174
162
 
175
163
  it "sends a 'control_stop' command to the control port when #info is called" do
176
- @socket.should_receive( :send ).with( "19:12:control_stop,0:}]" )
177
- @socket.should_receive( :recv ).
164
+ expect( @socket ).to receive( :send ).with( "19:12:control_stop,0:}]" )
165
+ expect( @socket ).to receive( :recv ).
178
166
  and_return( "63:7:headers,6:3:msg,]4:rows,33:29:25:stopping the control port,]]}" )
179
- @control.control_stop.should == [{:msg => "stopping the control port"}]
167
+ expect( @control.control_stop ).to eq( [{:msg => "stopping the control port"}] )
180
168
  end
181
169
 
182
170
 
183
171
  it "raises an exception if the server responds with an error" do
184
- @socket.should_receive( :send ).with( "19:4:kill,9:2:id,1:0#}]" )
185
- @socket.should_receive( :recv ).
172
+ expect( @socket ).to receive( :send ).with( "19:4:kill,9:2:id,1:0#}]" )
173
+ expect( @socket ).to receive( :recv ).
186
174
  and_return( "61:4:code,16:INVALID_ARGUMENT,5:error,22:Invalid argument type.,}" )
187
175
 
188
176
  expect {