Permalink
Browse files

even more robustter tests

  • Loading branch information...
1 parent ffa77ac commit 5e8a3a17d7102a8e8c667c0544351e9b4df1a315 @josh committed Sep 8, 2009
Showing with 27 additions and 9 deletions.
  1. +27 −9 test/test_openid.rb
View
36 test/test_openid.rb
@@ -6,6 +6,10 @@
require 'rack/session/pool'
require 'rack/openid'
+log = Logger.new(STDOUT)
+log.level = Logger::WARN
+OpenID::Util.logger = log
+
class TestHeader < Test::Unit::TestCase
def test_build_header
assert_equal 'OpenID identity="http://example.com/"',
@@ -33,24 +37,38 @@ def test_parse_header
class TestOpenID < Test::Unit::TestCase
RotsServer = 'http://localhost:9292'
- def setup
- @pid = fork {
- exec "rackup -E none test/openid_server.ru"
+ @server_started = false
+
+ def self.start_server!
+ return if @server_started
+
+ pid = fork {
+ STDIN.reopen "/dev/null"
+ STDOUT.reopen "/dev/null", "a"
+ STDERR.reopen "/dev/null", "a"
+
+ exec "rackup test/openid_server.ru"
+ }
+
+ at_exit {
+ Process.kill 9, pid
+ Process.wait(pid)
}
- sleep 0.5
+ sleep 0.75
+
+ @server_started = true
+ end
+
+ def setup
+ self.class.start_server!
assert_nothing_raised(Errno::ECONNREFUSED) {
uri = URI.parse(RotsServer)
response = Net::HTTP.get_response(uri)
}
end
- def teardown
- Process.kill 9, @pid
- Process.wait(@pid)
- end
-
def test_with_get
@app = app
process('/', :method => 'GET')

0 comments on commit 5e8a3a1

Please sign in to comment.