Skip to content

Instantly share code, notes, and snippets.

@vinibaggio
Created June 20, 2011 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinibaggio/1036471 to your computer and use it in GitHub Desktop.
Save vinibaggio/1036471 to your computer and use it in GitHub Desktop.
Guard + spork
group :test do
gem 'guard-spork'
gem 'guard-rspec'
gem 'growl'
gem 'rb-fsevent'
end
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' }, :cucumber => false do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch('spec/spec_helper.rb')
end
guard 'rspec', :cli => '--drb' do
watch(%r{^spec/.+_spec\.rb})
watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| "spec/requests/#{m[1]}_spec.rb" }
watch(%r{^app/views/(.+)/.*\.erb}) { |m| "spec/requests/#{m[1]}_spec.rb" }
end
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
# 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|
config.mock_with :rspec
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.include LoginHelper
config.use_transactional_fixtures = true
REDIS_PID = "#{Rails.root}/tmp/pids/redis-test.pid"
REDIS_CACHE_PATH = "#{Rails.root}/tmp/cache/"
# Melhorar essa parada
config.before(:suite) do
redis_options = {
"daemonize" => 'yes',
"pidfile" => REDIS_PID,
"port" => 9736,
"timeout" => 300,
"save 900" => 1,
"save 300" => 1,
"save 60" => 10000,
"dbfilename" => "dump.rdb",
"dir" => REDIS_CACHE_PATH,
"loglevel" => "debug",
"logfile" => "stdout",
"databases" => 16
}.map { |k, v| "#{k} #{v}" }.join('\n')
`echo '#{redis_options}' | redis-server -`
Resque.redis = 'localhost:9736'
end
config.after(:suite) do
%x{
cat #{REDIS_PID} | xargs kill -QUIT
rm -f #{REDIS_CACHE_PATH}dump.rdb
}
end
end
end
Spork.each_run do
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment