Skip to content

Instantly share code, notes, and snippets.

@tdouce
Last active August 29, 2015 14:08
Show Gist options
  • Save tdouce/b05632a9cf43755b94df to your computer and use it in GitHub Desktop.
Save tdouce/b05632a9cf43755b94df to your computer and use it in GitHub Desktop.
"client" spec/spec_helper.rb
...
RemoteFactoryGirl.configure do |config|
config.home = { host: 'localhost',
port: 3001,
end_point: '/remote_factory_girl/home' }
config.return_with_root = false
end
RemoteDatabaseCleaner.configure do |config|
config.home = { host: 'localhost',
port: RemoteFactoryGirl.config.home[:port],
end_point: '/remote_database_cleaner/home/clean' }
end
pids_dir = Rails.root.join('tmp', 'pids')
FileUtils.mkdir_p(pids_dir) unless File.directory?(pids_dir)
HOME_PID = File.join(pids_dir, 'home-test.pid')
HOME_SRC_DIR = '/Users/travisdouce/code/soa_integration_testing/home'
RSpec.configure do |config|
config.before(:suite) do
if auto_start_dependent_services?
Dir.chdir(HOME_SRC_DIR) do
Bundler.with_clean_env do
puts '[HOME] Starting test HOME server...'
`./bin/rails server --daemon --environment=test --pid=#{ HOME_PID } --port=#{ RemoteFactoryGirl.config.home[:port] }`
puts "[HOME] Preparing test HOME database..."
`bin/rake db:setup RAILS_ENV=test`
end
end
else
RemoteDatabaseCleaner.clean
end
end
config.after(:each) do
RemoteDatabaseCleaner.clean
end
config.after(:suite) do
if auto_start_dependent_services?
puts '\n[HOME] Stopping test HOME server...'
`cat #{ HOME_PID } | xargs kill -QUIT`
end
end
end
def auto_start_dependent_services?
ENV['DEP_SERVICES'] == 'auto_start'
end
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment