Permalink
Browse files

Ensured webmock test server is started only once and killed after all…

… specs are finished.
  • Loading branch information...
1 parent 8118632 commit f5c5bf41dcc36b16b0f635ae88370e2eecd233e5 @bblimke committed Feb 4, 2012
Showing with 5 additions and 4 deletions.
  1. +3 −3 spec/spec_helper.rb
  2. +2 −1 spec/support/webmock_server.rb
View
6 spec/spec_helper.rb
@@ -30,11 +30,11 @@
config.filter_run_excluding :without_webmock => true
- config.before(:all) do
- WebMockServer.instance.start
+ config.before(:suite) do
+ WebMockServer.instance.start unless WebMockServer.instance.started
end
- config.after(:all) do
+ config.after(:suite) do
WebMockServer.instance.stop
end
View
3 spec/support/webmock_server.rb
@@ -5,7 +5,7 @@
class WebMockServer
include Singleton
- attr_reader :port
+ attr_reader :port, :started
def host_with_port
"localhost:#{port}"
@@ -22,6 +22,7 @@ def concurrent
end
def start
+ @started = true
server = WEBrick::GenericServer.new(:Port => 0, :Logger => Logger.new("/dev/null"))
server.logger.level = 0
@port = server.config[:Port]

0 comments on commit f5c5bf4

Please sign in to comment.