Skip to content
Extraits de code Groupes Projets
Valider 2e96f012 rédigé par Raphael Sofaer's avatar Raphael Sofaer
Parcourir les fichiers

simplify multi-server spec running with foreman. couldn't really get it...

simplify multi-server spec running with foreman.  couldn't really get it automated tonight, not sure why.
parent f8c05851
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -180,7 +180,6 @@ production: ...@@ -180,7 +180,6 @@ production:
<<: *defaults <<: *defaults
mount_resque_web: false mount_resque_web: false
# #
# Do not touch unless you know what you're doing # Do not touch unless you know what you're doing
# #
...@@ -192,7 +191,6 @@ test: ...@@ -192,7 +191,6 @@ test:
enable_splunk_logging: false enable_splunk_logging: false
open_invitations: true open_invitations: true
integration_1: integration_1:
<<: *defaults <<: *defaults
pod_url: "http://localhost:45789" pod_url: "http://localhost:45789"
......
integration_1: bundle exec thin start -e integration_1 -p 45789
integration_2: bundle exec thin start -e integration_2 -p 34658
...@@ -5,21 +5,14 @@ require 'spec_helper' ...@@ -5,21 +5,14 @@ require 'spec_helper'
unless Server.all.empty? unless Server.all.empty?
describe "commenting" do describe "commenting" do
before(:all) do before(:all) do
WebMock::Config.instance.allow_localhost = true Server.start
enable_typhoeus
#Server.all.each{|s| s.kill if s.running?}
#Server.all.each{|s| s.run}
end end
after(:all) do after(:all) do
disable_typhoeus Server.stop
#Server.all.each{|s| s.kill if s.running?}
#sleep(1)
#Server.all.each{|s| puts "Server at port #{s.port} still running." if s.running?}
WebMock::Config.instance.allow_localhost = false
end end
before do before do
Server.all.each{|s| s.truncate_database; } Server.truncate_databases
@post = nil @post = nil
Server[0].in_scope do Server[0].in_scope do
poster = Factory.create(:user_with_aspect, :username => "poster") poster = Factory.create(:user_with_aspect, :username => "poster")
......
...@@ -3,21 +3,14 @@ require 'spec_helper' ...@@ -3,21 +3,14 @@ require 'spec_helper'
unless Server.all.empty? unless Server.all.empty?
describe "commenting" do describe "commenting" do
before(:all) do before(:all) do
WebMock::Config.instance.allow_localhost = true Server.start
enable_typhoeus
#Server.all.each{|s| s.kill if s.running?}
#Server.all.each{|s| s.run}
end end
after(:all) do after(:all) do
disable_typhoeus Server.stop
#Server.all.each{|s| s.kill if s.running?}
#sleep(1)
#Server.all.each{|s| puts "Server at port #{s.port} still running." if s.running?}
WebMock::Config.instance.allow_localhost = false
end end
before do before do
Server.all.each{|s| s.truncate_database; } Server.truncate_databases
@post = nil @post = nil
Server[0].in_scope do Server[0].in_scope do
Factory.create(:user_with_aspect, :username => "poster") Factory.create(:user_with_aspect, :username => "poster")
......
...@@ -5,21 +5,14 @@ require 'spec_helper' ...@@ -5,21 +5,14 @@ require 'spec_helper'
unless Server.all.empty? unless Server.all.empty?
describe "reposting" do describe "reposting" do
before(:all) do before(:all) do
WebMock::Config.instance.allow_localhost = true Server.start
enable_typhoeus
#Server.all.each{|s| s.kill if s.running?}
#Server.all.each{|s| s.run}
end end
after(:all) do after(:all) do
disable_typhoeus Server.stop
#Server.all.each{|s| s.kill if s.running?}
#sleep(1)
#Server.all.each{|s| puts "Server at port #{s.port} still running." if s.running?}
WebMock::Config.instance.allow_localhost = false
end end
before do before do
Server.all.each{|s| s.truncate_database; } Server.truncate_databases
@original_post = nil @original_post = nil
Server[0].in_scope do Server[0].in_scope do
original_poster = Factory.create(:user_with_aspect, :username => "original_poster") original_poster = Factory.create(:user_with_aspect, :username => "original_poster")
......
...@@ -4,20 +4,15 @@ require 'spec_helper' ...@@ -4,20 +4,15 @@ require 'spec_helper'
unless Server.all.empty? unless Server.all.empty?
describe Server do describe Server do
before(:all) do before(:all) do
WebMock::Config.instance.allow_localhost = true Server.start
#Server.all.each{|s| s.kill if s.running?}
#Server.all.each{|s| s.run}
end end
after(:all) do after(:all) do
#Server.all.each{|s| s.kill if s.running?} Server.stop
#sleep(1)
#Server.all.each{|s| puts "Server at port #{s.port} still running." if s.running?}
WebMock::Config.instance.allow_localhost = false
end end
before do before do
Server.all.each{|s| s.truncate_database } Server.truncate_databases
end end
describe '.all' do describe '.all' do
it 'returns a server object for each server' do it 'returns a server object for each server' do
......
#This class is for running servers in the background during integration testing. This will not run on Windows. #This class is for running servers in the background during integration testing. This will not run on Windows.
class Server class Server
def self.start
WebMock::Config.instance.allow_localhost = true
enable_typhoeus
end
def self.stop
disable_typhoeus
WebMock::Config.instance.allow_localhost = false
end
def self.truncate_databases
all.each{|s| s.truncate_database }
end
def self.[] index def self.[] index
self.all[index] self.all[index]
...@@ -21,6 +34,7 @@ class Server ...@@ -21,6 +34,7 @@ class Server
end end
def ensure_database_setup def ensure_database_setup
@@databases_setup = lambda {
`cd #{Rails.root} && RAILS_ENV=#{@env} bundle exec rake db:create` `cd #{Rails.root} && RAILS_ENV=#{@env} bundle exec rake db:create`
tables_exist = self.db do tables_exist = self.db do
ActiveRecord::Base.connection.tables.include?("users") ActiveRecord::Base.connection.tables.include?("users")
...@@ -30,6 +44,7 @@ class Server ...@@ -30,6 +44,7 @@ class Server
else else
`cd #{Rails.root} && RAILS_ENV=#{@env} bundle exec rake db:schema:load` `cd #{Rails.root} && RAILS_ENV=#{@env} bundle exec rake db:schema:load`
end end
true}.call
end end
def run def run
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter