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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5bdea37b7c56e0c93406a5653f43c7f567c5037
4
- data.tar.gz: ed56dd644330b5f948426f9255e9210647299735
3
+ metadata.gz: 9a891b9b342ed29169b81e8d5db135f3cd4d9e1b
4
+ data.tar.gz: 9467b6614c8df8892d0a6c027dfec33be3824843
5
5
  SHA512:
6
- metadata.gz: e47dfa343b471dd317ca448de04be667702d9d54321128478368487ea9b6e08d20bc8e02c4066237bdb32e6d6732c804bae4a0ec5e252bba23b4ff668e445ae8
7
- data.tar.gz: 185e0c1e5d8d02a031365216baa1d5cdcfdfa5b48cea64f4f23aa56c460e0c724c8b9d4da6ab49399639f80666ac25200eb6cb3939efb2efb53f034fe0e9975c
6
+ metadata.gz: 52c633d2fba86266d991f5f7d6cabd735b303406b6f3c96ae734f47a2dfc77e3b45a435a35de6a7abecea03ece007e2ae64e9040c9eff34b58bb60bbb27340a7
7
+ data.tar.gz: 943c432e477cccb2cde8feac08dd7f8574ee39961830f7f9f465d9b20c83f473e1b2b310854cb3ad7133da5ac1e2e139f12acc111c3a33a9d6a1a112e0eb1f9a
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,9 @@
1
+ == v0.39.0 [2013-09-25] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ - Replace stagnant zmq library with rbczmq.
4
+ - Add config support for 1.8.1's "X-Requests"
5
+
6
+
1
7
  == v0.38.0 [2013-09-18] Michael Granger <ged@FaerieMUD.org>
2
8
 
3
9
  - Update dependencies, add Gemfile.
data/Manifest.txt CHANGED
@@ -38,6 +38,7 @@ lib/mongrel2/config/route.rb
38
38
  lib/mongrel2/config/server.rb
39
39
  lib/mongrel2/config/setting.rb
40
40
  lib/mongrel2/config/statistic.rb
41
+ lib/mongrel2/config/xrequest.rb
41
42
  lib/mongrel2/connection.rb
42
43
  lib/mongrel2/constants.rb
43
44
  lib/mongrel2/control.rb
@@ -52,9 +53,9 @@ lib/mongrel2/table.rb
52
53
  lib/mongrel2/testing.rb
53
54
  lib/mongrel2/websocket.rb
54
55
  lib/mongrel2/xmlrequest.rb
55
- spec/lib/constants.rb
56
- spec/lib/helpers.rb
57
- spec/lib/matchers.rb
56
+ spec/constants.rb
57
+ spec/helpers.rb
58
+ spec/matchers.rb
58
59
  spec/mongrel2/config/directory_spec.rb
59
60
  spec/mongrel2/config/dsl_spec.rb
60
61
  spec/mongrel2/config/filter_spec.rb
@@ -66,6 +67,7 @@ spec/mongrel2/config/route_spec.rb
66
67
  spec/mongrel2/config/server_spec.rb
67
68
  spec/mongrel2/config/setting_spec.rb
68
69
  spec/mongrel2/config/statistic_spec.rb
70
+ spec/mongrel2/config/xrequest_spec.rb
69
71
  spec/mongrel2/config_spec.rb
70
72
  spec/mongrel2/connection_spec.rb
71
73
  spec/mongrel2/constants_spec.rb
data/Rakefile CHANGED
@@ -28,12 +28,12 @@ hoespec = Hoe.spec 'mongrel2' do
28
28
  self.developer 'Michael Granger', 'ged@FaerieMUD.org'
29
29
 
30
30
  self.dependency 'nokogiri', '~> 1.5'
31
- self.dependency 'sequel', '~> 3.44'
31
+ self.dependency 'sequel', '~> 4.2'
32
32
  self.dependency 'tnetstring', '~> 0.3'
33
33
  self.dependency 'yajl-ruby', '~> 1.0'
34
34
  self.dependency 'trollop', '~> 2.0'
35
35
  self.dependency 'sysexits', '~> 1.1'
36
- self.dependency 'zmq', '~> 2.1'
36
+ self.dependency 'rbczmq', '~> 1.7'
37
37
  self.dependency 'loggability','~> 0.5'
38
38
  self.dependency 'sqlite3', '~> 1.3'
39
39
 
@@ -72,12 +72,17 @@ CREATE TABLE statistic (id SERIAL,
72
72
  sd REAL,
73
73
  primary key (other_type, other_id, name));
74
74
 
75
+ CREATE TABLE mimetype (id INTEGER PRIMARY KEY, mimetype TEXT, extension TEXT);
76
+
75
77
  CREATE TABLE filter (id INTEGER PRIMARY KEY,
76
78
  server_id INTEGER,
77
79
  name TEXT,
78
80
  settings TEXT);
79
81
 
80
- CREATE TABLE mimetype (id INTEGER PRIMARY KEY, mimetype TEXT, extension TEXT);
82
+ CREATE TABLE xrequest (id INTEGER PRIMARY KEY,
83
+ server_id INTEGER,
84
+ name TEXT,
85
+ settings TEXT);
81
86
 
82
87
  CREATE TABLE IF NOT EXISTS log(id INTEGER PRIMARY KEY,
83
88
  who TEXT,
data/lib/mongrel2.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  # -*- ruby -*-
2
2
  #encoding: utf-8
3
3
 
4
+ # Ensure this is used instead of 'zmq' if it's also installed
5
+ gem 'rbczmq'
6
+
4
7
  require 'loggability'
5
8
  require 'zmq'
6
9
 
@@ -22,10 +25,10 @@ module Mongrel2
22
25
  abort "\n\n>>> Mongrel2 requires Ruby 1.9.2 or later. <<<\n\n" if RUBY_VERSION < '1.9.2'
23
26
 
24
27
  # Library version constant
25
- VERSION = '0.38.0'
28
+ VERSION = '0.39.0'
26
29
 
27
30
  # Version-control revision constant
28
- REVISION = %q$Revision: 0ea16429b0cf $
31
+ REVISION = %q$Revision: 36202f7a03c9 $
29
32
 
30
33
 
31
34
  require 'mongrel2/constants'
@@ -267,6 +267,7 @@ module Mongrel2
267
267
  require 'mongrel2/config/mimetype'
268
268
  require 'mongrel2/config/log'
269
269
  require 'mongrel2/config/statistic'
270
+ require 'mongrel2/config/xrequest'
270
271
 
271
272
  require 'mongrel2/config/dsl'
272
273
 
@@ -46,6 +46,11 @@ class Mongrel2::Config::Server < Mongrel2::Config( :server )
46
46
  # The filters[rdoc-ref:Mongrel2::Config::Filter] that will be loaded by this server.
47
47
  one_to_many :filters
48
48
 
49
+ ##
50
+ # The xrequest handlers[rdoc-ref:Mongrel2::Config::XRequest] that will be loaded by this server.
51
+ one_to_many :xrequests,
52
+ :class => 'Mongrel2::Config::XRequest'
53
+
49
54
 
50
55
  ##
51
56
  # :method: uuid
@@ -207,6 +212,16 @@ class Mongrel2::Config::Server < Mongrel2::Config( :server )
207
212
  self.target.add_filter( name: path, settings: settings )
208
213
  end
209
214
 
215
+
216
+ ### Add a Mongrel2::Config::XRequest to the Server object with the specified
217
+ ### +path+ (name) and +settings+ hash.
218
+ def xrequest( path, settings={} )
219
+ self.target.save( :validate => false )
220
+
221
+ self.log.debug "XRequest [%s]: %p" % [ path, settings ]
222
+ self.target.add_xrequest( name: path, settings: settings )
223
+ end
224
+
210
225
  end # module DSLMethods
211
226
 
212
227
  end # class Mongrel2::Config::Server
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'tnetstring'
4
+
5
+ require 'mongrel2' unless defined?( Mongrel2 )
6
+ require 'mongrel2/config' unless defined?( Mongrel2::Config )
7
+
8
+ # Mongrel2 X-Request configuration class
9
+ #
10
+ # # Using the config DSL:
11
+ # xrequest '/usr/local/lib/mongrel2/filters/watermark.so',
12
+ # extensions: ['*.jpg', '*.png'],
13
+ # src: '/usr/local/var/image/acme.png'
14
+ #
15
+ # # Which is the same as:
16
+ # Mongrel2::Config::XRequest.create(
17
+ # name: '/usr/local/lib/mongrel2/filters/sendfile.so',
18
+ # settings: {
19
+ # min_size: 1000
20
+ # }
21
+ #
22
+ # # Or:
23
+ # server.add_xrequest(
24
+ # name: '/usr/local/lib/mongrel2/filters/sendfile.so',
25
+ # settings: {
26
+ # min_size: 1000
27
+ # })
28
+ #
29
+ class Mongrel2::Config::XRequest < Mongrel2::Config( :xrequest )
30
+
31
+ ### As of Mongrel2/1.8.1:
32
+ # CREATE TABLE xrequest (id INTEGER PRIMARY KEY,
33
+ # server_id INTEGER,
34
+ # name TEXT,
35
+ # settings TEXT);
36
+ #
37
+
38
+ many_to_one :server
39
+
40
+
41
+ # Serialize the settings column as TNetStrings
42
+ plugin :serialization, :tnetstring, :settings
43
+
44
+ end # class Mongrel2::Config::XRequest
45
+
@@ -70,14 +70,13 @@ class Mongrel2::Connection
70
70
  self.log.debug "0mq Context is: %p" % [ ctx ]
71
71
 
72
72
  self.log.info "Connecting PULL request socket (%s)" % [ self.sub_addr ]
73
- @request_sock = ctx.socket( ZMQ::PULL )
74
- @request_sock.setsockopt( ZMQ::LINGER, 0 )
73
+ @request_sock = ctx.socket( :PULL )
74
+ @request_sock.linger = 0
75
75
  @request_sock.connect( self.sub_addr )
76
76
 
77
77
  self.log.info "Connecting PUB response socket (%s)" % [ self.pub_addr ]
78
- @response_sock = ctx.socket( ZMQ::PUB )
79
- @response_sock.setsockopt( ZMQ::IDENTITY, self.identifier )
80
- @response_sock.setsockopt( ZMQ::LINGER, 0 )
78
+ @response_sock = ctx.socket( :PUB )
79
+ @response_sock.linger = 0
81
80
  @response_sock.connect( self.pub_addr )
82
81
  end
83
82
 
@@ -28,8 +28,8 @@ class Mongrel2::Control
28
28
  def initialize( port=DEFAULT_PORT )
29
29
  check_port( port )
30
30
  @ctx = Mongrel2.zmq_context
31
- @socket = @ctx.socket( ZMQ::REQ )
32
- @socket.setsockopt( ZMQ::LINGER, 0 )
31
+ @socket = @ctx.socket( :REQ )
32
+ @socket.linger = 0
33
33
  @socket.connect( port.to_s )
34
34
  end
35
35
 
@@ -156,7 +156,7 @@ class Mongrel2::Handler
156
156
  self.restore_signal_handlers
157
157
  self.log.info "Done: %p" % [ self ]
158
158
  @conn.close
159
- Mongrel2.zmq_context.close
159
+ Mongrel2.zmq_context.close if Mongrel2.zmq_context.respond_to?( :close )
160
160
  end
161
161
 
162
162
 
@@ -1,8 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'uri'
4
- require 'yajl'
5
- require 'tnetstring'
6
4
 
7
5
  require 'mongrel2' unless defined?( Mongrel2 )
8
6
 
@@ -1,15 +1,8 @@
1
1
  #!/usr/bin/ruby
2
2
  # coding: utf-8
3
3
 
4
- BEGIN {
5
- require 'pathname'
6
- basedir = Pathname.new( __FILE__ ).dirname.parent
7
-
8
- libdir = basedir + "lib"
9
-
10
- $LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
11
- $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
12
- }
4
+ require_relative 'constants'
5
+ require_relative 'matchers'
13
6
 
14
7
  # SimpleCov test coverage reporting; enable this using the :coverage rake task
15
8
  if ENV['COVERAGE']
@@ -44,8 +37,6 @@ require 'loggability/spechelpers'
44
37
  require 'sequel'
45
38
  require 'sequel/model'
46
39
 
47
- require 'spec/lib/constants'
48
- require 'spec/lib/matchers'
49
40
 
50
41
 
51
42
  ### RSpec helper functions that are used to test Mongrel2 itself.
@@ -226,7 +217,13 @@ end
226
217
  RSpec.configure do |c|
227
218
  include Mongrel2::TestConstants
228
219
 
229
- c.mock_with :rspec
220
+ c.treat_symbols_as_metadata_keys_with_true_values = true
221
+ c.run_all_when_everything_filtered = true
222
+ c.filter_run :focus
223
+ c.order = 'random'
224
+ c.mock_with( :rspec ) do |config|
225
+ config.syntax = :expect
226
+ end
230
227
 
231
228
  c.extend( Mongrel2::TestConstants )
232
229
  c.include( Mongrel2::TestConstants )
@@ -1,21 +1,11 @@
1
1
  #!/usr/bin/ruby
2
2
  # coding: utf-8
3
3
 
4
- BEGIN {
5
- require 'pathname'
6
- basedir = Pathname.new( __FILE__ ).dirname.parent
7
-
8
- libdir = basedir + "lib"
9
-
10
- $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
11
- }
12
-
13
- require 'rspec'
14
- require 'mongrel2'
4
+ require 'mongrel2' unless defined?( Mongrel2 )
15
5
 
16
6
 
17
7
  ### RSpec matchers for Mongrel2 specs
18
- module Mongrel2::Matchers
8
+ module Mongrel2::Matchers # :nodoc:
19
9
 
20
10
  ### A matcher for unordered array contents
21
11
  class EnumerableAllBeMatcher
@@ -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::Directory 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
 
@@ -43,48 +32,48 @@ describe Mongrel2::Config::Directory do
43
32
 
44
33
 
45
34
  it "is valid if its base, index_file, and default_ctype are all valid" do
46
- @dir.should be_valid()
35
+ expect( @dir ).to be_valid()
47
36
  end
48
37
 
49
38
  it "isn't valid if it doesn't have a base" do
50
39
  @dir.base = nil
51
- @dir.should_not be_valid()
52
- @dir.errors.full_messages.first.should =~ /missing or nil/i
40
+ expect( @dir ).to_not be_valid()
41
+ expect( @dir.errors.full_messages.first ).to match( /missing or nil/i )
53
42
  end
54
43
 
55
44
  it "isn't valid when its base starts with '/'" do
56
45
  @dir.base = '/var/www/public/'
57
- @dir.should_not be_valid()
58
- @dir.errors.full_messages.first.should =~ %r{shouldn't start with '/'}i
46
+ expect( @dir ).to_not be_valid()
47
+ expect( @dir.errors.full_messages.first ).to match( %r{shouldn't start with '/'}i )
59
48
  end
60
49
 
61
50
  it "isn't valid when its base doesn't end with '/'" do
62
51
  @dir.base = 'var/www/public'
63
- @dir.should_not be_valid()
64
- @dir.errors.full_messages.first.should =~ %r{must end with '/'}i
52
+ expect( @dir ).to_not be_valid()
53
+ expect( @dir.errors.full_messages.first ).to match( %r{must end with '/'}i )
65
54
  end
66
55
 
67
56
  it "isn't valid if it doesn't have an index file" do
68
57
  @dir.index_file = nil
69
- @dir.should_not be_valid()
70
- @dir.errors.full_messages.first.should =~ /must not be nil/i
58
+ expect( @dir ).to_not be_valid()
59
+ expect( @dir.errors.full_messages.first ).to match( /must not be nil/i )
71
60
  end
72
61
 
73
62
  it "isn't valid if it doesn't have a default content-type" do
74
63
  @dir.default_ctype = nil
75
- @dir.should_not be_valid()
76
- @dir.errors.full_messages.first.should =~ /must not be nil/i
64
+ expect( @dir ).to_not be_valid()
65
+ expect( @dir.errors.full_messages.first ).to match( /must not be nil/i )
77
66
  end
78
67
 
79
68
  it "isn't valid if its cache TTL is set to a negative value" do
80
69
  @dir.cache_ttl = -5
81
- @dir.should_not be_valid()
82
- @dir.errors.full_messages.first.should =~ /not a positive integer/i
70
+ expect( @dir ).to_not be_valid()
71
+ expect( @dir.errors.full_messages.first ).to match( /not a positive integer/i )
83
72
  end
84
73
 
85
74
  it "is valid if its cache TTL is set to zero" do
86
75
  @dir.cache_ttl = 0
87
- @dir.should be_valid()
76
+ expect( @dir ).to be_valid()
88
77
  end
89
78
 
90
79
  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
 
@@ -27,7 +16,7 @@ describe Mongrel2::Config::DSL do
27
16
  include described_class
28
17
 
29
18
  before( :all ) do
30
- setup_logging( :fatal )
19
+ setup_logging()
31
20
  setup_config_db()
32
21
  end
33
22
 
@@ -36,6 +25,7 @@ describe Mongrel2::Config::DSL do
36
25
  Mongrel2::Config::Host.truncate
37
26
  Mongrel2::Config::Route.truncate
38
27
  Mongrel2::Config::Filter.truncate
28
+ Mongrel2::Config::XRequest.truncate
39
29
  end
40
30
 
41
31
  after( :all ) do
@@ -47,8 +37,8 @@ describe Mongrel2::Config::DSL do
47
37
  it "can generate a default server config using the 'server' declarative" do
48
38
  result = server '965A7196-99BC-46FA-945B-3478AE92BFB5'
49
39
 
50
- result.should be_a( Mongrel2::Config::Server )
51
- result.uuid.should == '965A7196-99BC-46FA-945B-3478AE92BFB5'
40
+ expect( result ).to be_a( Mongrel2::Config::Server )
41
+ expect( result.uuid ).to eq( '965A7196-99BC-46FA-945B-3478AE92BFB5' )
52
42
  end
53
43
 
54
44
 
@@ -61,13 +51,13 @@ describe Mongrel2::Config::DSL do
61
51
  control_port '/var/run/intranet.sock'
62
52
  end
63
53
 
64
- result.should be_a( Mongrel2::Config::Server )
65
- result.uuid.should == '965A7196-99BC-46FA-945B-3478AE92BFB5'
66
- result.name.should == 'Intranet'
67
- result.chroot.should == '/service/mongrel2'
68
- result.access_log.should == '/var/log/access'
69
- result.error_log.should == '/var/log/errors'
70
- result.control_port.should == '/var/run/intranet.sock'
54
+ expect( result ).to be_a( Mongrel2::Config::Server )
55
+ expect( result.uuid ).to eq( '965A7196-99BC-46FA-945B-3478AE92BFB5' )
56
+ expect( result.name ).to eq( 'Intranet' )
57
+ expect( result.chroot ).to eq( '/service/mongrel2' )
58
+ expect( result.access_log ).to eq( '/var/log/access' )
59
+ expect( result.error_log ).to eq( '/var/log/errors' )
60
+ expect( result.control_port ).to eq( '/var/run/intranet.sock' )
71
61
  end
72
62
  end
73
63
 
@@ -80,12 +70,12 @@ describe Mongrel2::Config::DSL do
80
70
 
81
71
  end
82
72
 
83
- result.should be_a( Mongrel2::Config::Server )
84
- result.hosts.should have( 1 ).member
73
+ expect( result ).to be_a( Mongrel2::Config::Server )
74
+ expect( result.hosts ).to have( 1 ).member
85
75
  host = result.hosts.first
86
76
 
87
- host.should be_a( Mongrel2::Config::Host )
88
- host.name.should == 'localhost'
77
+ expect( host ).to be_a( Mongrel2::Config::Host )
78
+ expect( host.name ).to eq( 'localhost' )
89
79
  end
90
80
 
91
81
  it "can add several elaborately-configured hosts to a server via a block" do
@@ -118,51 +108,51 @@ describe Mongrel2::Config::DSL do
118
108
 
119
109
  end
120
110
 
121
- result.should be_a( Mongrel2::Config::Server )
122
- result.hosts.should have( 2 ).members
111
+ expect( result ).to be_a( Mongrel2::Config::Server )
112
+ expect( result.hosts ).to have( 2 ).members
123
113
  host1, host2 = result.hosts
124
114
 
125
- host1.should be_a( Mongrel2::Config::Host )
126
- host1.name.should == 'brillianttaste'
127
- host1.matching.should == '*.brillianttasteinthefoodmouth.com'
128
- host1.routes.should have( 6 ).members
129
- host1.routes.should all_be_a( Mongrel2::Config::Route )
130
-
131
- host1.routes[0].path.should == '/images'
132
- host1.routes[0].target.should be_a( Mongrel2::Config::Directory )
133
- host1.routes[0].target.base.should == 'var/www/images/'
134
-
135
- host1.routes[1].path.should == '/css'
136
- host1.routes[1].target.should be_a( Mongrel2::Config::Directory )
137
- host1.routes[1].target.base.should == 'var/www/css/'
138
-
139
- host1.routes[2].path.should == '/vote'
140
- host1.routes[2].target.should be_a( Mongrel2::Config::Proxy )
141
- host1.routes[2].target.addr.should == 'localhost'
142
- host1.routes[2].target.port.should == 6667
143
-
144
- host1.routes[3].path.should == '/admin'
145
- host1.routes[3].target.should be_a( Mongrel2::Config::Handler )
146
- host1.routes[3].target.send_ident.should == 'D613E7EE-E2EB-4699-A200-5C8ECAB45D5E'
147
- host1.routes[3].target.send_spec.should == 'tcp://127.0.0.1:9998'
148
- host1.routes[3].target.recv_ident.should == ''
149
- host1.routes[3].target.recv_spec.should == 'tcp://127.0.0.1:9997'
150
-
151
- host1.routes[4].path.should == '@directory'
152
- host1.routes[4].target.should be_a( Mongrel2::Config::Handler )
153
- host1.routes[4].target.send_ident.should == 'B7EFA46D-FEE4-432B-B80F-E8A9A2CC6FDB'
154
- host1.routes[4].target.send_spec.should == 'tcp://127.0.0.1:9996'
155
- host1.routes[4].target.recv_spec.should == 'tcp://127.0.0.1:9992'
156
- host1.routes[4].target.recv_ident.should == ''
157
- host1.routes[4].target.protocol.should == 'tnetstring'
158
-
159
- host1.routes[5].path.should == '/directory'
160
- host1.routes[5].target.should == host1.routes[4].target
161
-
162
- host2.should be_a( Mongrel2::Config::Host )
163
- host2.name.should == 'deveiate.org'
164
- host2.routes.should have( 1 ).member
165
- host2.routes.first.should be_a( Mongrel2::Config::Route )
115
+ expect( host1 ).to be_a( Mongrel2::Config::Host )
116
+ expect( host1.name ).to eq( 'brillianttaste' )
117
+ expect( host1.matching ).to eq( '*.brillianttasteinthefoodmouth.com' )
118
+ expect( host1.routes ).to have( 6 ).members
119
+ expect( host1.routes ).to all_be_a( Mongrel2::Config::Route )
120
+
121
+ expect( host1.routes[0].path ).to eq( '/images' )
122
+ expect( host1.routes[0].target ).to be_a( Mongrel2::Config::Directory )
123
+ expect( host1.routes[0].target.base ).to eq( 'var/www/images/' )
124
+
125
+ expect( host1.routes[1].path ).to eq( '/css' )
126
+ expect( host1.routes[1].target ).to be_a( Mongrel2::Config::Directory )
127
+ expect( host1.routes[1].target.base ).to eq( 'var/www/css/' )
128
+
129
+ expect( host1.routes[2].path ).to eq( '/vote' )
130
+ expect( host1.routes[2].target ).to be_a( Mongrel2::Config::Proxy )
131
+ expect( host1.routes[2].target.addr ).to eq( 'localhost' )
132
+ expect( host1.routes[2].target.port ).to eq( 6667 )
133
+
134
+ expect( host1.routes[3].path ).to eq( '/admin' )
135
+ expect( host1.routes[3].target ).to be_a( Mongrel2::Config::Handler )
136
+ expect( host1.routes[3].target.send_ident ).to eq( 'D613E7EE-E2EB-4699-A200-5C8ECAB45D5E' )
137
+ expect( host1.routes[3].target.send_spec ).to eq( 'tcp://127.0.0.1:9998' )
138
+ expect( host1.routes[3].target.recv_ident ).to eq( '' )
139
+ expect( host1.routes[3].target.recv_spec ).to eq( 'tcp://127.0.0.1:9997' )
140
+
141
+ expect( host1.routes[4].path ).to eq( '@directory' )
142
+ expect( host1.routes[4].target ).to be_a( Mongrel2::Config::Handler )
143
+ expect( host1.routes[4].target.send_ident ).to eq( 'B7EFA46D-FEE4-432B-B80F-E8A9A2CC6FDB' )
144
+ expect( host1.routes[4].target.send_spec ).to eq( 'tcp://127.0.0.1:9996' )
145
+ expect( host1.routes[4].target.recv_spec ).to eq( 'tcp://127.0.0.1:9992' )
146
+ expect( host1.routes[4].target.recv_ident ).to eq( '' )
147
+ expect( host1.routes[4].target.protocol ).to eq( 'tnetstring' )
148
+
149
+ expect( host1.routes[5].path ).to eq( '/directory' )
150
+ expect( host1.routes[5].target ).to eq( host1.routes[4].target )
151
+
152
+ expect( host2 ).to be_a( Mongrel2::Config::Host )
153
+ expect( host2.name ).to eq( 'deveiate.org' )
154
+ expect( host2.routes ).to have( 1 ).member
155
+ expect( host2.routes.first ).to be_a( Mongrel2::Config::Route )
166
156
  end
167
157
 
168
158
 
@@ -185,22 +175,22 @@ describe Mongrel2::Config::DSL do
185
175
  "upload.temp_store_mode" => "0666"
186
176
  )
187
177
 
188
- result.should be_an( Array )
189
- result.should have( 3 ).members
190
- result.should all_be_a( Mongrel2::Config::Setting )
191
- result[0].key.should == 'zeromq.threads'
192
- result[0].value.should == '8'
193
- result[1].key.should == 'upload.temp_store'
194
- result[1].value.should == '/home/zedshaw/projects/mongrel2/tmp/upload.XXXXXX'
195
- result[2].key.should == 'upload.temp_store_mode'
196
- result[2].value.should == '0666'
178
+ expect( result ).to be_an( Array )
179
+ expect( result ).to have( 3 ).members
180
+ expect( result ).to all_be_a( Mongrel2::Config::Setting )
181
+ expect( result[0].key ).to eq( 'zeromq.threads' )
182
+ expect( result[0].value ).to eq( '8' )
183
+ expect( result[1].key ).to eq( 'upload.temp_store' )
184
+ expect( result[1].value ).to eq( '/home/zedshaw/projects/mongrel2/tmp/upload.XXXXXX' )
185
+ expect( result[2].key ).to eq( 'upload.temp_store_mode' )
186
+ expect( result[2].value ).to eq( '0666' )
197
187
  end
198
188
 
199
189
  it "can set a single expert setting" do
200
190
  result = setting "zeromq.threads", 16
201
- result.should be_a( Mongrel2::Config::Setting )
202
- result.key.should == 'zeromq.threads'
203
- result.value.should == '16'
191
+ expect( result ).to be_a( Mongrel2::Config::Setting )
192
+ expect( result.key ).to eq( 'zeromq.threads' )
193
+ expect( result.value ).to eq( '16' )
204
194
  end
205
195
 
206
196
  end
@@ -213,20 +203,20 @@ describe Mongrel2::Config::DSL do
213
203
  '.textile' => 'text/x-textile'
214
204
  )
215
205
 
216
- result.should be_an( Array )
217
- result.should have( 2 ).members
218
- result.should all_be_a( Mongrel2::Config::Mimetype )
219
- result[0].extension.should == '.md'
220
- result[0].mimetype.should == 'text/x-markdown'
221
- result[1].extension.should == '.textile'
222
- result[1].mimetype.should == 'text/x-textile'
206
+ expect( result ).to be_an( Array )
207
+ expect( result ).to have( 2 ).members
208
+ expect( result ).to all_be_a( Mongrel2::Config::Mimetype )
209
+ expect( result[0].extension ).to eq( '.md' )
210
+ expect( result[0].mimetype ).to eq( 'text/x-markdown' )
211
+ expect( result[1].extension ).to eq( '.textile' )
212
+ expect( result[1].mimetype ).to eq( 'text/x-textile' )
223
213
  end
224
214
 
225
215
  it "can set a single mimetype mapping" do
226
216
  result = mimetype '.tmpl', 'text/x-inversion-template'
227
- result.should be_a( Mongrel2::Config::Mimetype )
228
- result.extension.should == '.tmpl'
229
- result.mimetype.should == 'text/x-inversion-template'
217
+ expect( result ).to be_a( Mongrel2::Config::Mimetype )
218
+ expect( result.extension ).to eq( '.tmpl' )
219
+ expect( result.mimetype ).to eq( 'text/x-inversion-template' )
230
220
  end
231
221
 
232
222
  end
@@ -238,9 +228,9 @@ describe Mongrel2::Config::DSL do
238
228
  filter '/usr/lib/mongrel2/null.so'
239
229
  end
240
230
 
241
- result.filters.should have( 1 ).member
242
- result.filters.first.should be_a( Mongrel2::Config::Filter )
243
- result.filters.first.settings.should == {}
231
+ expect( result.filters ).to have( 1 ).member
232
+ expect( result.filters.first ).to be_a( Mongrel2::Config::Filter )
233
+ expect( result.filters.first.settings ).to eq( {} )
244
234
  end
245
235
 
246
236
  it "can add a filter with settings to a server" do
@@ -250,10 +240,37 @@ describe Mongrel2::Config::DSL do
250
240
  min_size: 1000
251
241
  end
252
242
 
253
- result.filters.should have( 1 ).member
254
- result.filters.first.should be_a( Mongrel2::Config::Filter )
255
- result.filters.first.settings.should ==
256
- { 'extensions' => ["*.html", "*.txt"], 'min_size' => 1000 }
243
+ expect( result.filters ).to have( 1 ).member
244
+ expect( result.filters.first ).to be_a( Mongrel2::Config::Filter )
245
+ expect( result.filters.first.settings ).
246
+ to eq({ 'extensions' => ["*.html", "*.txt"], 'min_size' => 1000 })
247
+ end
248
+
249
+ end
250
+
251
+ describe 'xrequests' do
252
+
253
+ it "can add an xrequest to a server" do
254
+ result = server '965A7196-99BC-46FA-945B-3478AE92BFB5' do
255
+ xrequest '/usr/lib/mongrel2/null.so'
256
+ end
257
+
258
+ expect( result.xrequests ).to have( 1 ).member
259
+ expect( result.xrequests.first ).to be_a( Mongrel2::Config::XRequest )
260
+ expect( result.xrequests.first.settings ).to eq( {} )
261
+ end
262
+
263
+ it "can add a filter with settings to a server" do
264
+ result = server '965A7196-99BC-46FA-945B-3478AE92BFB5' do
265
+ xrequest '/usr/lib/mongrel2/null.so',
266
+ extensions: ["*.html", "*.txt"],
267
+ min_size: 1000
268
+ end
269
+
270
+ expect( result.xrequests ).to have( 1 ).member
271
+ expect( result.xrequests.first ).to be_a( Mongrel2::Config::XRequest )
272
+ expect( result.xrequests.first.settings ).
273
+ to eq({ 'extensions' => ["*.html", "*.txt"], 'min_size' => 1000 })
257
274
  end
258
275
 
259
276
  end