diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b0bf598aa..7a2a36196 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -57,12 +57,21 @@ def clock_time end end - config.before :each do - @client = new_client - end - - config.after :each do - @clients.each(&:close) + config.before(:suite) do + begin + new_client + rescue Mysql2::Error => e + username = DatabaseCredentials['root']['username'] + database = DatabaseCredentials['root']['database'] + message = %( +An error occurred while connecting to the testing database server. +Make sure that the database server is running. +Make sure that `mysql -u #{username} [options] #{database}` succeeds by the root user config in spec/configuration.yml. +Make sure that the testing database '#{database}' exists. If it does not exist, create it. +) + warn message + raise e + end end config.before(:all) do @@ -126,4 +135,12 @@ def clock_time ] end end + + config.before(:each) do + @client = new_client + end + + config.after(:each) do + @clients.each(&:close) + end end