diff --git a/config/environments/integration_1.rb b/config/environments/integration_1.rb
new file mode 100644
index 0000000000000000000000000000000000000000..1279e645a142226ac1fbaa68d428710a7fe2b39b
--- /dev/null
+++ b/config/environments/integration_1.rb
@@ -0,0 +1,39 @@
+#   Copyright (c) 2010, Diaspora Inc.  This file is
+#   licensed under the Affero General Public License version 3 or later.  See
+#   the COPYRIGHT file.
+
+Diaspora::Application.configure do
+  # Settings specified here will take precedence over those in config/environment.rb
+
+  # In the development environment your application's code is reloaded on
+  # every request.  This slows down response time but is perfect for development
+  # since you don't have to restart the webserver when you make code changes.
+  config.cache_classes = true
+
+  # Log error messages when you accidentally call methods on nil.
+  config.whiny_nils = true
+
+  # Show full error reports and disable caching
+  config.consider_all_requests_local       = true
+  config.action_view.debug_rjs             = true
+  config.action_controller.perform_caching = false
+
+  # Don't care if the mailer can't send
+  config.action_mailer.raise_delivery_errors = false
+  config.active_support.deprecation = :log
+  #config.threadsafe!
+
+  # Monkeypatch around the nasty "2.5MB exception page" issue, caused by very large environment vars
+  # This snippet via: http://stackoverflow.com/questions/3114993/exception-pages-in-development-mode-take-upwards-of-15-30-seconds-to-render-why
+  # Relevant Rails ticket: https://rails.lighthouseapp.com/projects/8994/tickets/5027-_request_and_responseerb-and-diagnosticserb-take-an-increasingly-long-time-to-render-in-development-with-multiple-show-tables-calls
+  config.after_initialize do
+    module SmallInspect
+      def inspect
+        "<#{self.class.name} - tooooo long>"
+      end
+    end
+    [ActionController::Base, ActionDispatch::RemoteIp::RemoteIpGetter, OmniAuth::Strategy, Warden::Proxy].each do |klazz|
+      klazz.send(:include, SmallInspect)
+    end
+  end
+end
diff --git a/config/environments/integration_2.rb b/config/environments/integration_2.rb
new file mode 100644
index 0000000000000000000000000000000000000000..1279e645a142226ac1fbaa68d428710a7fe2b39b
--- /dev/null
+++ b/config/environments/integration_2.rb
@@ -0,0 +1,39 @@
+#   Copyright (c) 2010, Diaspora Inc.  This file is
+#   licensed under the Affero General Public License version 3 or later.  See
+#   the COPYRIGHT file.
+
+Diaspora::Application.configure do
+  # Settings specified here will take precedence over those in config/environment.rb
+
+  # In the development environment your application's code is reloaded on
+  # every request.  This slows down response time but is perfect for development
+  # since you don't have to restart the webserver when you make code changes.
+  config.cache_classes = true
+
+  # Log error messages when you accidentally call methods on nil.
+  config.whiny_nils = true
+
+  # Show full error reports and disable caching
+  config.consider_all_requests_local       = true
+  config.action_view.debug_rjs             = true
+  config.action_controller.perform_caching = false
+
+  # Don't care if the mailer can't send
+  config.action_mailer.raise_delivery_errors = false
+  config.active_support.deprecation = :log
+  #config.threadsafe!
+
+  # Monkeypatch around the nasty "2.5MB exception page" issue, caused by very large environment vars
+  # This snippet via: http://stackoverflow.com/questions/3114993/exception-pages-in-development-mode-take-upwards-of-15-30-seconds-to-render-why
+  # Relevant Rails ticket: https://rails.lighthouseapp.com/projects/8994/tickets/5027-_request_and_responseerb-and-diagnosticserb-take-an-increasingly-long-time-to-render-in-development-with-multiple-show-tables-calls
+  config.after_initialize do
+    module SmallInspect
+      def inspect
+        "<#{self.class.name} - tooooo long>"
+      end
+    end
+    [ActionController::Base, ActionDispatch::RemoteIp::RemoteIpGetter, OmniAuth::Strategy, Warden::Proxy].each do |klazz|
+      klazz.send(:include, SmallInspect)
+    end
+  end
+end
diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake
index b259fc28d8e207bb0bf1ca68ae2d2f77c110c43f..68a9439ac15e66e090f104ca38cd7529f60d40a5 100644
--- a/lib/tasks/db.rake
+++ b/lib/tasks/db.rake
@@ -6,6 +6,21 @@ namespace :db do
   desc "rebuild and prepare test db"
   task :rebuild => [:drop, :create, :migrate, 'db:test:prepare']
 
+  namespace :integration do
+    # desc 'Check for pending migrations and load the integration schema'
+    task :prepare => :environment do
+      abcs = ActiveRecord::Base.configurations
+      envs = abcs.keys.select{ |k| k.include?("integration") }
+      envs.each do |env|
+        ActiveRecord::Base.establish_connection(env)
+        ActiveRecord::Base.connection.drop_database(abcs[env]["database"])
+        ActiveRecord::Base.connection.create_database(abcs[env]["database"])
+        ActiveRecord::Base.establish_connection(env)
+        ActiveRecord::Migrator.migrate("db/migrate", nil)
+      end
+    end
+  end
+
   desc 'Seed the current RAILS_ENV database from db/seeds.rb'
   namespace :seed do
     task :tom do
diff --git a/lib/tasks/integration.rake b/lib/tasks/integration.rake
new file mode 100644
index 0000000000000000000000000000000000000000..1b5c55ff1be696b65cb7193d000de219ada6176e
--- /dev/null
+++ b/lib/tasks/integration.rake
@@ -0,0 +1,48 @@
+#   Copyright (c) 2010, Diaspora Inc.  This file is
+#   licensed under the Affero General Public License version 3 or later.  See
+#   the COPYRIGHT file.
+
+namespace :integration do
+  desc "rebuild and prepare test db"
+  task :gogogo => ['db:integration:prepare', :start_servers, :run_specs]
+
+  task :start_servers => :environment do
+    abcs = ActiveRecord::Base.configurations
+    envs = abcs.keys.select{ |k| k.include?("integration") }
+    if servers_active?(envs.map{ |env| abcs[env]["app_server_port"] })
+      puts "Servers are already running, using running integration servers."
+      next
+    end
+    $integration_server_pids = []
+    envs.each do |env|
+      $integration_server_pids << fork do
+        Process.exec "thin start -e #{env} -p #{abcs[env]["app_server_port"]}"
+      end
+    end
+    while(!servers_active?(envs.map{ |env| abcs[env]["app_server_port"] })) do
+      sleep(1)
+    end
+  end
+
+  task :run_servers => :start_servers do
+    while(true) do
+      sleep 1000
+    end
+  end
+
+  require 'rspec/core'
+  require 'rspec/core/rake_task'
+  RSpec::Core::RakeTask.new(:run_specs => :start_servers) do |t|
+    t.pattern = "./spec/multi_server/**/*_spec.rb"
+  end
+
+  def servers_active? ports
+    begin
+      ports.each { |port| RestClient.get("localhost:#{port}/users/sign_in") }
+      true
+    rescue
+      false
+    end
+  end
+
+end
diff --git a/spec/multi_server/server_spec.rb b/spec/multi_server/server_spec.rb
new file mode 100644
index 0000000000000000000000000000000000000000..10a53fc130796d3ae27122a069fb196cceabd87a
--- /dev/null
+++ b/spec/multi_server/server_spec.rb
@@ -0,0 +1,45 @@
+#This is a spec for the class that runs the servers used in the other multi-server specs
+
+require 'spec_helper'
+if Server.all.first.running?
+  describe Server do
+    before do
+      Server.all.each{|s| s.truncate_database }
+    end
+    describe '.all' do
+      it 'returns a server object for each server' do
+        integration_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.include?("integration") }
+        integration_envs.count.should == Server.all.count
+      end
+    end
+    describe '#initialize' do
+      it 'takes an environment' do
+        server = Server.new("integration_1")
+        server.env.should == "integration_1"
+        server.port.should == ActiveRecord::Base.configurations["integration_1"]["app_server_port"]
+      end
+    end
+    describe "#running?" do
+      it "verifies that the server is running" do
+        Server.new("integration_1").running?.should be_true
+      end
+    end
+    describe '#db' do
+      it 'runs the given code in the context of that server' do
+        servers = Server.all
+
+        test_user_count = User.count
+        servers.first.db do
+          User.count.should == 0
+          Factory :user
+          User.count.should == 1
+        end
+        User.count.should == test_user_count
+
+        servers.last.db do
+          User.count.should == 0
+        end
+      end
+    end
+  end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 4abb41cb1acaca89b26ee07a7590cadd8f18f6a3..ee0c8ff4af9ef9d3bc22a6dcfce29527bd13334b 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -2,8 +2,6 @@
 #   licensed under the Affero General Public License version 3 or later.  See
 #   the COPYRIGHT file.
 
-# This file is copied to ~/spec when you run 'ruby script/generate rspec'
-# from the project root directory.
 ENV["RAILS_ENV"] ||= 'test'
 require File.join(File.dirname(__FILE__), '..', 'config', 'environment') unless defined?(Rails)
 require 'helper_methods'
@@ -12,6 +10,7 @@ require 'webmock/rspec'
 require 'factory_girl'
 
 include WebMock::API
+WebMock::Config.instance.allow_localhost = true
 include HelperMethods
 
 # Force fixture rebuild
diff --git a/spec/support/server.rb b/spec/support/server.rb
new file mode 100644
index 0000000000000000000000000000000000000000..0b6d4cd783e93f7399dafb3fd77f6543d2447ba5
--- /dev/null
+++ b/spec/support/server.rb
@@ -0,0 +1,37 @@
+#This class is for running servers in the background during integration testing.  This will not run on Windows.
+class Server
+  def self.all
+    @servers ||= ActiveRecord::Base.configurations.keys.select{
+      |k| k.include?("integration")
+    }.map{ |k| self.new(k) }
+  end
+
+  attr_reader :port, :env
+  def initialize(env)
+    @config = ActiveRecord::Base.configurations[env]
+    @port = @config["app_server_port"]
+    @env = env
+  end
+
+  def running?
+    begin
+      RestClient.get("localhost:#{@port}/users/sign_in")
+      true
+    rescue Errno::ECONNREFUSED
+      false
+    end
+  end
+
+  def db
+    former_env = Rails.env
+    ActiveRecord::Base.establish_connection(env)
+    yield
+    ActiveRecord::Base.establish_connection(former_env)
+  end
+
+  def truncate_database
+    db do
+      DatabaseCleaner.clean_with(:truncation)
+    end
+  end
+end