mongrel2 0.38.0 → 0.39.0

Sign up to get free protection for your applications and to get access to all the features.
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
 
@@ -25,11 +14,12 @@ require 'mongrel2/config'
25
14
  describe Mongrel2::Config::Handler do
26
15
 
27
16
  before( :all ) do
28
- setup_logging( :fatal )
17
+ setup_logging()
29
18
  setup_config_db()
30
19
  end
31
20
 
32
21
  before( :each ) do
22
+ Mongrel2::Config::Handler.truncate
33
23
  @handler = Mongrel2::Config::Handler.new(
34
24
  :send_spec => TEST_SEND_SPEC,
35
25
  :send_ident => TEST_UUID,
@@ -43,75 +33,75 @@ describe Mongrel2::Config::Handler do
43
33
  end
44
34
 
45
35
  it "is valid if its specs and identities are all valid" do
46
- @handler.should be_valid()
36
+ expect( @handler ).to be_valid()
47
37
  end
48
38
 
49
39
 
50
40
  it "isn't valid if it doesn't have a send_spec" do
51
41
  @handler.send_spec = nil
52
- @handler.should_not be_valid()
53
- @handler.errors.full_messages.first.should =~ /must not be nil/i
42
+ expect( @handler ).to_not be_valid()
43
+ expect( @handler.errors.full_messages.first ).to match( /must not be nil/i )
54
44
  end
55
45
 
56
46
  it "isn't valid if it doesn't have a recv_spec" do
57
47
  @handler.recv_spec = nil
58
- @handler.should_not be_valid()
59
- @handler.errors.full_messages.first.should =~ /must not be nil/i
48
+ expect( @handler ).to_not be_valid()
49
+ expect( @handler.errors.full_messages.first ).to match( /must not be nil/i )
60
50
  end
61
51
 
62
52
 
63
53
  it "isn't valid if it doesn't have a valid URL in its send_spec" do
64
54
  @handler.send_spec = 'carrier pigeon'
65
- @handler.should_not be_valid()
66
- @handler.errors.full_messages.first.should =~ /not a uri/i
55
+ expect( @handler ).to_not be_valid()
56
+ expect( @handler.errors.full_messages.first ).to match( /not a uri/i )
67
57
  end
68
58
 
69
59
  it "isn't valid if it doesn't have a valid URL in its recv_spec" do
70
60
  @handler.recv_spec = 'smoke signals'
71
- @handler.should_not be_valid()
72
- @handler.errors.full_messages.first.should =~ /not a uri/i
61
+ expect( @handler ).to_not be_valid()
62
+ expect( @handler.errors.full_messages.first ).to match( /not a uri/i )
73
63
  end
74
64
 
75
65
 
76
66
  it "isn't valid if has an unsupported transport in its send_spec" do
77
67
  @handler.send_spec = 'inproc://application'
78
- @handler.should_not be_valid()
79
- @handler.errors.full_messages.first.should =~ /invalid 0mq transport/i
68
+ expect( @handler ).to_not be_valid()
69
+ expect( @handler.errors.full_messages.first ).to match( /invalid 0mq transport/i )
80
70
  end
81
71
 
82
72
  it "isn't valid if has an unsupported transport in its recv_spec" do
83
73
  @handler.recv_spec = 'inproc://application'
84
- @handler.should_not be_valid()
85
- @handler.errors.full_messages.first.should =~ /invalid 0mq transport/i
74
+ expect( @handler ).to_not be_valid()
75
+ expect( @handler.errors.full_messages.first ).to match( /invalid 0mq transport/i )
86
76
  end
87
77
 
88
78
 
89
79
  it "isn't valid if it doesn't have a send_ident" do
90
80
  @handler.send_ident = nil
91
- @handler.should_not be_valid()
92
- @handler.errors.full_messages.first.should =~ /invalid sender identity/i
81
+ expect( @handler ).to_not be_valid()
82
+ expect( @handler.errors.full_messages.first ).to match( /invalid sender identity/i )
93
83
  end
94
84
 
95
85
  it "*is* valid if it doesn't have a recv_ident" do
96
86
  @handler.recv_ident = nil
97
- @handler.should be_valid()
87
+ expect( @handler ).to be_valid()
98
88
  end
99
89
 
100
90
 
101
91
  it "is valid if it has 'json' set as the protocol" do
102
92
  @handler.protocol = 'json'
103
- @handler.should be_valid()
93
+ expect( @handler ).to be_valid()
104
94
  end
105
95
 
106
96
  it "is valid if it has 'tnetstring' set as the protocol" do
107
97
  @handler.protocol = 'tnetstring'
108
- @handler.should be_valid()
98
+ expect( @handler ).to be_valid()
109
99
  end
110
100
 
111
101
  it "isn't valid if it has an invalid protocol" do
112
102
  @handler.protocol = 'morsecode'
113
- @handler.should_not be_valid()
114
- @handler.errors.full_messages.first.should =~ /invalid/i
103
+ expect( @handler ).to_not be_valid()
104
+ expect( @handler.errors.full_messages.first ).to match( /invalid/i )
115
105
  end
116
106
 
117
107
  it "isn't valid if its send_spec isn't unique" do
@@ -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,21 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- BEGIN {
4
- require 'pathname'
5
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent
3
+ require_relative '../../helpers'
6
4
 
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 'socket'
14
5
  require 'rspec'
15
6
 
16
- require 'spec/lib/constants'
17
- require 'spec/lib/helpers'
18
-
7
+ require 'socket'
19
8
  require 'mongrel2'
20
9
  require 'mongrel2/config'
21
10
 
@@ -27,7 +16,7 @@ require 'mongrel2/config'
27
16
  describe Mongrel2::Config::Log do
28
17
 
29
18
  before( :all ) do
30
- setup_logging( :fatal )
19
+ setup_logging()
31
20
  setup_config_db()
32
21
  end
33
22
 
@@ -44,10 +33,10 @@ describe Mongrel2::Config::Log do
44
33
 
45
34
  log = Mongrel2::Config::Log.log_action( what, why, where, how )
46
35
 
47
- log.what.should == what
48
- log.why.should == why
49
- log.location.should == where
50
- log.how.should == how
36
+ expect( log.what ).to eq( what )
37
+ expect( log.why ).to eq( why )
38
+ expect( log.location ).to eq( where )
39
+ expect( log.how ).to eq( how )
51
40
  end
52
41
 
53
42
  it "has reasonable defaults for 'where' and 'how'" do
@@ -56,8 +45,8 @@ describe Mongrel2::Config::Log do
56
45
 
57
46
  log = Mongrel2::Config::Log.log_action( what, why )
58
47
 
59
- log.location.should == Socket.gethostname
60
- log.how.should == File.basename( $0 )
48
+ expect( log.location ).to eq( Socket.gethostname )
49
+ expect( log.how ).to eq( File.basename( $0 ) )
61
50
  end
62
51
 
63
52
  describe "an entry" do
@@ -76,7 +65,7 @@ describe Mongrel2::Config::Log do
76
65
  it "stringifies as a readable log file line" do
77
66
 
78
67
  # 2011-09-09 20:29:47 -0700 [mgranger] @localhost m2sh: load etc/mongrel2.conf (updating)
79
- @log.to_s.should =~ %r{
68
+ expect( @log.to_s ).to match(%r{
80
69
  ^
81
70
  (?-x:\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [\+\-]\d{4} )
82
71
  \[who\] \s
@@ -84,14 +73,14 @@ describe Mongrel2::Config::Log do
84
73
  how: \s
85
74
  what
86
75
  $
87
- }x
76
+ }x)
88
77
  end
89
78
 
90
79
  it "stringifies with a reason if it has one" do
91
80
  @log.why = 'Because'
92
81
 
93
82
  # 2011-09-09 20:29:47 -0700 [mgranger] @localhost m2sh: load etc/mongrel2.conf (updating)
94
- @log.to_s.should =~ %r{
83
+ expect( @log.to_s ).to match(%r{
95
84
  ^
96
85
  (?-x:\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [\+\-]\d{4} )
97
86
  \[who\] \s
@@ -100,7 +89,7 @@ describe Mongrel2::Config::Log do
100
89
  what \s
101
90
  \(Because\)
102
91
  $
103
- }x
92
+ }x)
104
93
  end
105
94
 
106
95
  end
@@ -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
 
@@ -37,6 +26,7 @@ describe Mongrel2::Config::Route do
37
26
  reset_logging()
38
27
  end
39
28
 
29
+
40
30
  it "returns a Mongrel2::Config::Directory if its target_type is 'dir'" do
41
31
  dir = Mongrel2::Config::Directory.create(
42
32
  :base => 'var/www/',
@@ -46,7 +36,7 @@ describe Mongrel2::Config::Route do
46
36
  @route.target_type = 'dir'
47
37
  @route.target_id = dir.id
48
38
 
49
- @route.target.should == dir
39
+ expect( @route.target ).to eq( dir )
50
40
  end
51
41
 
52
42
  it "returns a Mongrel2::Config::Proxy if its target_type is 'proxy'" do
@@ -55,7 +45,7 @@ describe Mongrel2::Config::Route do
55
45
  @route.target_type = 'proxy'
56
46
  @route.target_id = proxy.id
57
47
 
58
- @route.target.should == proxy
48
+ expect( @route.target ).to eq( proxy )
59
49
  end
60
50
 
61
51
  it "returns a Mongrel2::Config::Handler if its target_type is 'handler'" do
@@ -67,7 +57,7 @@ describe Mongrel2::Config::Route do
67
57
  @route.target_type = 'handler'
68
58
  @route.target_id = handler.id
69
59
 
70
- @route.target.should == handler
60
+ expect( @route.target ).to eq( handler )
71
61
  end
72
62
 
73
63
  it "raises an exception if its target_type is set to something invalid" do
@@ -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
 
@@ -25,7 +14,7 @@ require 'mongrel2/config'
25
14
  describe Mongrel2::Config::Server do
26
15
 
27
16
  before( :all ) do
28
- setup_logging( :fatal )
17
+ setup_logging()
29
18
  setup_config_db()
30
19
  end
31
20
 
@@ -47,53 +36,53 @@ describe Mongrel2::Config::Server do
47
36
 
48
37
 
49
38
  it "is valid if its access_log, error_log, pid_file, default_host, and port are all valid" do
50
- @server.should be_valid()
39
+ expect( @server ).to be_valid()
51
40
  end
52
41
 
53
42
  it "isn't valid if it doesn't have an access_log path" do
54
43
  @server.access_log = nil
55
- @server.should_not be_valid()
56
- @server.errors.full_messages.first.should =~ /missing or nil/i
44
+ expect( @server ).to_not be_valid()
45
+ expect( @server.errors.full_messages.first ).to match( /missing or nil/i )
57
46
  end
58
47
 
59
48
  it "isn't valid if it doesn't have an error_log path" do
60
49
  @server.error_log = nil
61
- @server.should_not be_valid()
62
- @server.errors.full_messages.first.should =~ /missing or nil/i
50
+ expect( @server ).to_not be_valid()
51
+ expect( @server.errors.full_messages.first ).to match( /missing or nil/i )
63
52
  end
64
53
 
65
54
  it "isn't valid if it doesn't have an pid_file path" do
66
55
  @server.pid_file = nil
67
- @server.should_not be_valid()
68
- @server.errors.full_messages.first.should =~ /missing or nil/i
56
+ expect( @server ).to_not be_valid()
57
+ expect( @server.errors.full_messages.first ).to match( /missing or nil/i )
69
58
  end
70
59
 
71
60
  it "isn't valid if it doesn't have a default_host" do
72
61
  @server.default_host = nil
73
- @server.should_not be_valid()
74
- @server.errors.full_messages.first.should =~ /missing or nil/i
62
+ expect( @server ).to_not be_valid()
63
+ expect( @server.errors.full_messages.first ).to match( /missing or nil/i )
75
64
  end
76
65
 
77
66
  it "isn't valid if it doesn't specify a port" do
78
67
  @server.port = nil
79
- @server.should_not be_valid()
80
- @server.errors.full_messages.first.should =~ /missing or nil/i
68
+ expect( @server ).to_not be_valid()
69
+ expect( @server.errors.full_messages.first ).to match( /missing or nil/i )
81
70
  end
82
71
 
83
72
 
84
73
  it "knows where its control socket is if there's no setting for control_port" do
85
74
  Mongrel2::Config::Setting.dataset.truncate
86
- FileTest.stub( :socket? ).with( '/usr/local/www/run/control' ).
75
+ allow( FileTest ).to receive( :socket? ).with( '/usr/local/www/run/control' ).
87
76
  and_return( true )
88
- @server.control_socket_uri.should == 'ipc:///usr/local/www/run/control'
77
+ expect( @server.control_socket_uri ).to eq( 'ipc:///usr/local/www/run/control' )
89
78
  end
90
79
 
91
80
  it "knows where its control socket is if there is a setting for control_port" do
92
81
  Mongrel2::Config::Setting.dataset.truncate
93
- FileTest.stub( :socket? ).with( '/usr/local/www/var/run/control.sock' ).
82
+ allow( FileTest ).to receive( :socket? ).with( '/usr/local/www/var/run/control.sock' ).
94
83
  and_return( true )
95
84
  Mongrel2::Config::Setting.create( key: 'control_port', value: 'ipc://var/run/control.sock' )
96
- @server.control_socket_uri.should == 'ipc:///usr/local/www/var/run/control.sock'
85
+ expect( @server.control_socket_uri ).to eq( 'ipc:///usr/local/www/var/run/control.sock' )
97
86
  end
98
87
 
99
88
  it "raises an error if the control socket path doesn't point to a UNIX socket" do
@@ -104,23 +93,23 @@ describe Mongrel2::Config::Server do
104
93
 
105
94
  it "can create a Mongrel2::Control for its control port" do
106
95
  Mongrel2::Config::Setting.dataset.truncate
107
- FileTest.stub( :socket? ).with( '/usr/local/www/run/control' ).
96
+ allow( FileTest ).to receive( :socket? ).with( '/usr/local/www/run/control' ).
108
97
  and_return( true )
109
98
  sock = @server.control_socket
110
- sock.should be_a( Mongrel2::Control )
99
+ expect( sock ).to be_a( Mongrel2::Control )
111
100
  sock.close
112
101
  end
113
102
 
114
103
  it "knows what the Pathname of its PID file is" do
115
104
  pidfile = @server.pid_file_path
116
- pidfile.should be_a( Pathname )
117
- pidfile.to_s.should == '/run/mongrel2.pid'
105
+ expect( pidfile ).to be_a( Pathname )
106
+ expect( pidfile.to_s ).to eq( '/run/mongrel2.pid' )
118
107
  end
119
108
 
120
109
  it "has a predicate that understands the use_ssl value" do
121
- @server.use_ssl.should be_false()
110
+ expect( @server.use_ssl ).to be_false()
122
111
  @server.use_ssl = true
123
- @server.use_ssl.should be_true()
112
+ expect( @server.use_ssl ).to be_true()
124
113
  end
125
114
 
126
115
  end