Permalink
Browse files

Fix variable scope bug in mongrel adapter. Fixes #33

  • Loading branch information...
1 parent e7fa92a commit 1f3858b0b00caa76c447e9401d4ffc9f65f77b65 @samwgoldman samwgoldman committed Mar 8, 2012
Showing with 8 additions and 4 deletions.
  1. +5 −4 lib/webmachine/adapters/mongrel.rb
  2. +3 −0 spec/webmachine/adapters/mongrel_spec.rb
@@ -13,13 +13,14 @@ class Mongrel < Adapter
# Starts the Mongrel adapter
def run
- options = {
+ defaults = {
:port => configuration.port,
- :host => configuration.ip
+ :host => configuration.ip,
+ :dispatcher => dispatcher
}.merge(configuration.adapter_options)
- config = ::Mongrel::Configurator.new(options) do
+ config = ::Mongrel::Configurator.new(defaults) do
listener do
- uri '/', :handler => Webmachine::Adapters::Mongrel::Handler.new(dispatcher)
+ uri '/', :handler => Webmachine::Adapters::Mongrel::Handler.new(defaults[:dispatcher])
end
trap("INT") { stop }
run
@@ -48,6 +48,9 @@
end
it "can run" do
+ # Prevent webserver thread from taking over
+ Thread.stub!(:new).and_return(stub(:join => nil))
+
expect {
adapter.run
}.not_to raise_error

0 comments on commit 1f3858b

Please sign in to comment.