Skip to content

Instantly share code, notes, and snippets.

@svenyurgensson
Forked from fxposter/Gemfile
Created April 19, 2012 12:04
Show Gist options
  • Save svenyurgensson/2420542 to your computer and use it in GitHub Desktop.
Save svenyurgensson/2420542 to your computer and use it in GitHub Desktop.
Test environment for rails apps
group :development, :test do
gem 'rspec-rails', '~> 2.9' # rails generate rspec:install
gem 'factory_girl_rails'
end
group :test do
gem 'spork-rails' # spork rspec --bootstrap
gem 'capybara'
gem 'launchy'
gem 'timecop'
gem 'shoulda-matchers'
gem 'autotest-standalone', :require => false
gem 'autotest-rails-pure', :require => false
# gem 'autotest-fsevent', :require => false
# gem 'autotest-growl', :require => false
gem 'simplecov', :require => false
end
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
require 'simplecov'
SimpleCov.start 'rails'
# https://github.com/sporkrb/spork/wiki/Spork.trap_method-Jujitsu
require 'rails/application'
Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
config.treat_symbols_as_metadata_keys_with_true_values = true
#config.run_all_when_everything_filtered = true
#config.filter_run_including :focus => true
#config.include Devise::TestHelpers, :type => :controller
config.after :each do
ActionMailer::Base.deliveries.clear
end
config.include Rails.application.routes.url_helpers, :type => :requests
end
require 'capybara/rails'
require 'capybara/rspec'
Capybara.javascript_driver = :selenium
Capybara.default_selector = :css
Capybara.default_wait_time = 5
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :profile => 'configurator')
end
# If you use thinking-sphinx - uncomment lines below
# require 'thinking_sphinx/test'
# ThinkingSphinx::Test.init
#Devise.stretches = 1
Rails.logger.level = 4
#noinspection RubyClassVariableUsageInspection
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock :google_apps, :provider => 'google_apps', :uid => 'fxposter@gmail.com', :info => { :email => 'fxposter@gmail.com' }
end
Spork.each_run do
# This code will be run each time you run your specs.
FactoryGirl.reload
# Forces all threads to share the same connection. This works on
# Capybara because it starts the web server in a thread.
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment