Skip to content

Commit

Permalink
Merge pull request webmachine#38 from samwgoldman/mongrel_configure_s…
Browse files Browse the repository at this point in the history
…cope

Mongrel configure scope
  • Loading branch information
samwgoldman committed Mar 8, 2012
2 parents a942971 + 1f3858b commit b543db2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/webmachine/adapters/mongrel.rb
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/webmachine/adapters/mongrel_spec.rb
Expand Up @@ -46,6 +46,15 @@
chunks.join.should eq("Hello, World!")
end
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
end
end
rescue LoadError
warn "Platform is #{RUBY_PLATFORM}: skipping mongrel adapter spec."
Expand Down

0 comments on commit b543db2

Please sign in to comment.