Permalink
Browse files

debugging

git-svn-id: https://svn.thoughtbot.com/ldap-activerecord-gateway@22 bbed3248-5b21-0410-9248-c913b1c69bca
  • Loading branch information...
1 parent d18dd97 commit e61e532c1d3fb9b841edcc94e5e7824f1f9bbbdf tsaleh committed May 16, 2007
Showing with 12 additions and 13 deletions.
  1. +5 −5 lib/server.rb
  2. +7 −8 test/server_test.rb
View
@@ -32,11 +32,7 @@ def initialize(config_file_name = nil)
self.logger.datetime_format = "%H:%M:%S"
self.logger.info ""
- require File.join(@config['rails_dir'], 'config', 'environment.rb')
- self.logger.info("Cannot load Rails. Exiting.") and exit 5 unless defined? RAILS_ROOT
- @config.symbolize_keys!
-
- @pidfile = PidFile.new(@config[:pid_file] || File.join(@config[:rails_dir], *%w(log ldap-server.pid)))
+ @pidfile = PidFile.new(@config["pid_file"] || File.join(@config["rails_dir"], *%w(log ldap-server.pid)))
end
def become_user(username = 'nobody', chroot = false)
@@ -51,6 +47,10 @@ def become_user(username = 'nobody', chroot = false)
end
def start
+ require File.join(@config['rails_dir'], 'config', 'environment.rb')
+ self.logger.info("Cannot load Rails. Exiting.") and exit 5 unless defined? RAILS_ROOT
+ @config.symbolize_keys!
+
pidfile.ensure_empty! "ERROR: It looks like I'm already running. Not starting."
logger.info "Starting LDAP server on port #{@config[:port]}."
View
@@ -25,14 +25,6 @@ class ServerTest < Test::Unit::TestCase
context "Server" do
setup { stub_everything }
- should "load environment.rb on new" do
- Server.any_instance.
- expects(:require).
- with("#{File.dirname(__FILE__)}/railsdir/config/environment.rb").
- returns(require("#{File.dirname(__FILE__)}/railsdir/config/environment.rb"))
- server = Server.new("/tmp/stuff.yml")
- end
-
should "read the config file on new" do
File.expects(:read).with("/tmp/stuff.yml").returns(CONFIG_FILE)
server = Server.new("/tmp/stuff.yml")
@@ -57,6 +49,13 @@ class ServerTest < Test::Unit::TestCase
@server = Server.new("/tmp/stuff.yml")
end
+ should "load environment.rb on start" do
+ @server.expects(:require).
+ with("#{File.dirname(__FILE__)}/railsdir/config/environment.rb").
+ returns(require("#{File.dirname(__FILE__)}/railsdir/config/environment.rb"))
+ @server.start
+ end
+
should "call pidfile.ensure_empty! on start" do
@server.pidfile.expects(:ensure_empty!)
@server.start

0 comments on commit e61e532

Please sign in to comment.