Commit a580171e authored by Jonne Haß's avatar Jonne Haß

Replace spork with spring, update & use binstubs

Spring is the recommended application preloader for rails
parent 4cadc2d5
......@@ -3,4 +3,3 @@
--color
--tag ~performance
--order random
--drb
......@@ -202,14 +202,15 @@ group :development do
# Automatic test runs
gem 'guard-cucumber', '1.5.1'
gem 'guard-rspec', '4.3.1'
gem 'guard', '2.8.2', :require => false
gem 'guard', '2.10.0', :require => false
gem 'rb-fsevent', '0.9.4', :require => false
gem 'rb-inotify', '0.9.5', :require => false
# Preloading environment
gem 'guard-spork', '2.0.1'
gem 'spork', '1.0.0rc4'
gem 'spring', '1.2.0'
gem 'spring-commands-rspec', '1.0.2'
gem 'spring-commands-cucumber', '1.0.1'
# Debugging
gem 'pry'
......
......@@ -245,7 +245,7 @@ GEM
json
multi_json
request_store (>= 1.0.5)
guard (2.8.2)
guard (2.10.0)
formatador (>= 0.2.4)
listen (~> 2.7)
lumberjack (~> 1.0)
......@@ -257,10 +257,6 @@ GEM
guard-rspec (4.3.1)
guard (~> 2.1)
rspec (>= 2.14, < 4.0)
guard-spork (2.0.1)
childprocess (>= 0.2.3)
guard (~> 2.8.2)
spork (>= 0.8.4)
haml (4.0.5)
tilt
handlebars_assets (0.18)
......@@ -307,7 +303,7 @@ GEM
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.9.2)
listen (2.8.1)
listen (2.8.3)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
......@@ -538,7 +534,11 @@ GEM
sinon-rails (1.10.3)
railties (>= 3.1)
slop (3.6.0)
spork (1.0.0rc4)
spring (1.2.0)
spring-commands-cucumber (1.0.1)
spring (>= 0.9.1)
spring-commands-rspec (1.0.2)
spring (>= 0.9.1)
sprockets (2.11.3)
hike (~> 1.2)
multi_json (~> 1.0)
......@@ -625,10 +625,9 @@ DEPENDENCIES
foreman (= 0.62)
fuubar (= 2.0.0)
gon (= 5.2.3)
guard (= 2.8.2)
guard (= 2.10.0)
guard-cucumber (= 1.5.1)
guard-rspec (= 4.3.1)
guard-spork (= 2.0.1)
haml (= 4.0.5)
handlebars_assets (= 0.18.0)
http_accept_language (= 2.0.2)
......@@ -688,7 +687,9 @@ DEPENDENCIES
simple_captcha2 (= 0.3.2)
sinatra (= 1.4.5)
sinon-rails (= 1.10.3)
spork (= 1.0.0rc4)
spring (= 1.2.0)
spring-commands-cucumber (= 1.0.1)
spring-commands-rspec (= 1.0.2)
test_after_commit (= 0.4.0)
timecop (= 0.7.1)
twitter (= 4.8.1)
......
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
# also, http://asciicasts.com/episodes/264-guard
guard 'rspec', :all_on_start => false, :all_after_pass => false do
guard :rspec, cmd: 'bin/spring rspec', all_on_start: false, all_after_pass: false do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
......@@ -15,23 +12,12 @@ guard 'rspec', :all_on_start => false, :all_after_pass => false do
watch('spec/spec_helper.rb') { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara request specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
end
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' }, :all_on_start => false, :all_after_pass => false, :wait => 70 do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch('Gemfile')
watch('Gemfile.lock')
watch('spec/spec_helper.rb') { :rspec }
watch('test/test_helper.rb') { :test_unit }
watch(%r{features/support/}) { :cucumber }
end
guard 'cucumber', :all_on_start => false, :all_after_pass => false do
guard :cucumber, command_prefix: 'bin/spring', bundler: false, all_on_start: false, all_after_pass: false do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { 'features' }
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
......
web: bundle exec unicorn_rails -c config/unicorn.rb -p $PORT
sidekiq: bundle exec sidekiq
xmpp: bundle exec vines start
web: bin/bundle exec unicorn_rails -c config/unicorn.rb -p $PORT
sidekiq: bin/bundle exec sidekiq
xmpp: bin/bundle exec vines start
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'autospec' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'autospec')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'compass' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('compass', 'compass')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'cucumber' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require 'bundler/setup'
load Gem.bin_path('cucumber', 'cucumber')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'foreman' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('foreman', 'foreman')
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require_relative '../config/boot'
require 'rake'
Rake.application.run
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'rspec' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'sass' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('sass', 'sass')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'sass-convert' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('sass', 'sass-convert')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'scss' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('sass', 'scss')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'spork' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('spork', 'spork')
#!/usr/bin/env ruby
# This file loads spring without using Bundler, in order to be fast
# It gets overwritten when you run the `spring binstub` command
unless defined?(Spring)
require "rubygems"
require "bundler"
if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)
ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
ENV["GEM_HOME"] = ""
Gem.paths = ENV
gem "spring", match[1]
require "spring/binstub"
end
end
......@@ -29,9 +29,9 @@ before_fork do |server, worker|
unless AppConfig.single_process_mode?
Sidekiq.redis {|redis| redis.client.disconnect }
end
if AppConfig.server.embed_sidekiq_worker?
@sidekiq_pid ||= spawn('bundle exec sidekiq')
@sidekiq_pid ||= spawn('bin/bundle exec sidekiq')
end
old_pid = '/var/run/diaspora/diaspora.pid.oldbin'
......
require 'rubygems'
prefork = proc do
ENV["RAILS_ENV"] ||= "test"
ENV["RAILS_ENV"] ||= "test"
# Have all rests run with english browser locale
ENV['LANG'] = 'C'
# Have all rests run with english browser locale
ENV['LANG'] = 'C'
require 'cucumber/rails'
require 'cucumber/rails'
require 'capybara/rails'
require 'capybara/cucumber'
require 'capybara/session'
#require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
require 'capybara/rails'
require 'capybara/cucumber'
require 'capybara/session'
#require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
# Ensure we know the appservers port
Capybara.server_port = 9887
# Ensure we know the appservers port
Capybara.server_port = 9887
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
# order to ease the transition to Capybara we set the default here. If you'd
# prefer to use XPath just remove this line and adjust any selectors in your
# steps to use the XPath syntax.
Capybara.default_selector = :css
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
# order to ease the transition to Capybara we set the default here. If you'd
# prefer to use XPath just remove this line and adjust any selectors in your
# steps to use the XPath syntax.
Capybara.default_selector = :css
# We have a ridiculously high wait time to account for build machines of various beefiness.
# Capybara.default_wait_time = 30
# We have a ridiculously high wait time to account for build machines of various beefiness.
# Capybara.default_wait_time = 30
# While there are a lot of failures, wait less, avoiding travis timeout
Capybara.default_wait_time = 15
# While there are a lot of failures, wait less, avoiding travis timeout
Capybara.default_wait_time = 15
# If you set this to false, any error raised from within your app will bubble
# up to your step definition and out to cucumber unless you catch it somewhere
# on the way. You can make Rails rescue errors and render error pages on a
# per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
#
# If you set this to true, Rails will rescue all errors and render error
# pages, more or less in the same way your application would behave in the
# default production environment. It's not recommended to do this for all
# of your scenarios, as this makes it hard to discover errors in your application.
ActionController::Base.allow_rescue = false
# If you set this to false, any error raised from within your app will bubble
# up to your step definition and out to cucumber unless you catch it somewhere
# on the way. You can make Rails rescue errors and render error pages on a
# per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
#
# If you set this to true, Rails will rescue all errors and render error
# pages, more or less in the same way your application would behave in the
# default production environment. It's not recommended to do this for all
# of your scenarios, as this makes it hard to discover errors in your application.
ActionController::Base.allow_rescue = false
require 'database_cleaner'
require 'database_cleaner/cucumber'
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.orm = "active_record"
Cucumber::Rails::World.use_transactional_fixtures = false
require 'database_cleaner'
require 'database_cleaner/cucumber'
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.orm = "active_record"
Cucumber::Rails::World.use_transactional_fixtures = false
require File.join(File.dirname(__FILE__), "database_cleaner_patches")
require File.join(File.dirname(__FILE__), "integration_sessions_controller")
require File.join(File.dirname(__FILE__), "poor_mans_webmock")
require File.join(File.dirname(__FILE__), "database_cleaner_patches")
require File.join(File.dirname(__FILE__), "integration_sessions_controller")
require File.join(File.dirname(__FILE__), "poor_mans_webmock")
require 'sidekiq/testing/inline'
require 'sidekiq/testing/inline'
require Rails.root.join('spec', 'helper_methods')
require Rails.root.join('spec', 'support', 'inlined_jobs')
require Rails.root.join('spec', 'support', 'user_methods')
include HelperMethods
require Rails.root.join('spec', 'helper_methods')
require Rails.root.join('spec', 'support', 'inlined_jobs')
require Rails.root.join('spec', 'support', 'user_methods')
include HelperMethods
# require 'webmock/cucumber'
# WebMock.disable_net_connect!(:allow_localhost => true)
# require 'webmock/cucumber'
# WebMock.disable_net_connect!(:allow_localhost => true)
#hax to get rubymine to run spork, set RUBYMINE_HOME in your .bash_profile
if ENV["RUBYMINE_HOME"]
puts "Loading rubymine spork extensions"
$:.unshift(File.expand_path("rb/testing/patch/common", ENV["RUBYMINE_HOME"]))
$:.unshift(File.expand_path("rb/testing/patch/bdd", ENV["RUBYMINE_HOME"]))
end
Before do
Devise.mailer.deliveries = []
end
each_run = proc do
Before do
DatabaseCleaner.clean
Devise.mailer.deliveries = []
end
After do
if Capybara.current_session.driver.respond_to?(:browser)
Capybara.reset_sessions!
# Capybara.current_session.driver.browser.manage.delete_all_cookies
end
end
Before('@localserver') do
TestServerFixture.start_if_needed
CapybaraSettings.instance.save
Capybara.current_driver = :selenium
Capybara.run_server = false
end
After('@localserver') do
CapybaraSettings.instance.restore
After do
if Capybara.current_session.driver.respond_to?(:browser)
Capybara.reset_sessions!
# Capybara.current_session.driver.browser.manage.delete_all_cookies
end
end
begin
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Before('@localserver') do
TestServerFixture.start_if_needed
CapybaraSettings.instance.save
Capybara.current_driver = :selenium
Capybara.run_server = false
end
Spork.prefork(&prefork)
Spork.each_run(&each_run)
rescue LoadError
prefork.call
each_run.call
After('@localserver') do
CapybaraSettings.instance.restore
end
# give firefox more time to complete requests
......
......@@ -46,7 +46,7 @@ module Configuration
File.dirname(__FILE__)
)
unless File.exist? token_file
`bundle exec rake generate:secret_token`
`bin/rake generate:secret_token`
end
require token_file
Diaspora::Application.config.secret_key_base
......
......@@ -168,7 +168,7 @@ diaspora_setup() {
prepare_gem_bundle
log_inf "creating the default database specified in config/database.yml. please wait..."
run_or_error "bundle exec rake db:schema:load_if_ruby --trace"
run_or_error "bin/rake db:schema:load_if_ruby --trace"
printf "\n"
printf "$GOODBYE_MSG"
......
......@@ -64,14 +64,14 @@ fi
# Setup environment
if [ -z "$RAILS_ENV" ]
then
RAILS_ENV=$(bundle exec ruby ./script/get_config.rb server.rails_environment)
RAILS_ENV=$(bin/bundle exec ruby ./script/get_config.rb server.rails_environment)
on_failure "Couldn't parse config/diaspora.yml!"
export RAILS_ENV
fi
os=$(uname -s)
vars=$(bundle exec ruby ./script/get_config.rb \
vars=$(bin/bundle exec ruby ./script/get_config.rb \
port=server.port \
single_process_mode=environment.single_process_mode? \
embed_sidekiq_worker=server.embed_sidekiq_worker \
......@@ -125,7 +125,7 @@ then
fatal "You're running in production mode without having assets
precompiled. Now and after each update before you restart the
application, run:
bundle exec rake assets:precompile"
bin/rake assets:precompile"
fi
# Check for old curl versions (see https://github.com/diaspora/diaspora/issues/4202)
......@@ -173,4 +173,4 @@ else
fi
echo ""
exec bundle exec foreman start -m "xmpp=$vines,web=1,sidekiq=$workers" -p $port
exec bin/bundle exec foreman start -m "xmpp=$vines,web=1,sidekiq=$workers" -p $port
......@@ -2,114 +2,95 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
prefork = proc 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 "rails/application"
#Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
ENV["RAILS_ENV"] ||= 'test'
require File.join(File.dirname(__FILE__), '..', 'config', 'environment')
require Rails.root.join('spec', 'helper_methods')
require Rails.root.join('spec', 'spec-doc')
require 'rspec/rails'
require 'webmock/rspec'
require 'factory_girl'
require 'sidekiq/testing'
include HelperMethods
Dir["#{File.dirname(__FILE__)}/shared_behaviors/**/*.rb"].each do |f|
require f
end
ENV["RAILS_ENV"] ||= 'test'
require File.join(File.dirname(__FILE__), '..', 'config', 'environment')
require Rails.root.join('spec', 'helper_methods')
require Rails.root.join('spec', 'spec-doc')
require 'rspec/rails'
require 'webmock/rspec'
require 'factory_girl'
require 'sidekiq/testing'
include HelperMethods
Dir["#{File.dirname(__FILE__)}/shared_behaviors/**/*.rb"].each do |f|
require f
end
ProcessedImage.enable_processing = false
UnprocessedImage.enable_processing = false
ProcessedImage.enable_processing = false
UnprocessedImage.enable_processing = false
def set_up_friends
[local_luke, local_leia, remote_raphael]
end
def set_up_friends
[local_luke, local_leia, remote_raphael]
end
def alice
@alice ||= User.where(:username => 'alice').first
end
def alice
@alice ||= User.where(:username => 'alice').first
end
def bob
@bob ||= User.where(:username => 'bob').first
end
def bob
@bob ||= User.where(:username => 'bob').first
end
def eve
@eve ||= User.where(:username => 'eve').first
end
def eve
@eve ||= User.where(:username => 'eve').first
end
def local_luke
@local_luke ||= User.where(:username => 'luke').first
end
def local_luke
@local_luke ||= User.where(:username => 'luke').first
end
def local_leia
@local_leia ||= User.where(:username => 'leia').first
end
def local_leia
@local_leia ||= User.where(:username => 'leia').first
end
def remote_raphael
@remote_raphael ||= Person.where(:diaspora_handle => 'raphael@remote.net').first
end
def remote_raphael
@remote_raphael ||= Person.where(:diaspora_handle => 'raphael@remote.net').first
end
def photo_fixture_name
@photo_fixture_name = File.join(File.dirname(__FILE__), 'fixtures', 'button.png')
end
# Force fixture rebuild
FileUtils.rm_f(Rails.root.join('tmp', 'fixture_builder.yml'))
def photo_fixture_name
@photo_fixture_name = File.join(File.dirname(__FILE__), 'fixtures', 'button.png')
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
fixture_builder_file = "#{File.dirname(__FILE__)}/support/fixture_builder.rb"
support_files = Dir["#{File.dirname(__FILE__)}/support/**/*.rb"] - [fixture_builder_file]
support_files.each {|f| require f }
require fixture_builder_file
RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
config.mock_with :rspec
config.render_views
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!
config.before(:each) do
I18n.locale = :en
stub_request(:post, "https://pubsubhubbub.appspot.com/")
disable_typhoeus
$process_queue = false
allow_any_instance_of(Postzord::Dispatcher::Public).to receive(:deliver_to_remote)
allow_any_instance_of(Postzord::Dispatcher::Private).to receive(:deliver_to_remote)
end
# Force fixture rebuild
FileUtils.rm_f(Rails.root.join('tmp', 'fixture_builder.yml'))
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
fixture_builder_file = "#{File.dirname(__FILE__)}/support/fixture_builder.rb"
support_files = Dir["#{File.dirname(__FILE__)}/support/**/*.rb"] - [fixture_builder_file]
support_files.each {|f| require f }
require fixture_builder_file
RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
config.mock_with :rspec
config.render_views
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!
config.before(:each) do
I18n.locale = :en
stub_request(:post, "https://pubsubhubbub.appspot.com/")
disable_typhoeus
$process_queue = false
allow_any_instance_of(Postzord::Dispatcher::Public).to receive(:deliver_to_remote)
allow_any_instance_of(Postzord::Dispatcher::Private).to receive(:deliver_to_remote)
end
config.expect_with :rspec do |expect_config|
expect_config.syntax = :expect
end
config.after(:all) do
`rm -rf #{Rails.root}/tmp/uploads/*`
end
# Reset overridden settings
config.after(:each) do
AppConfig.reset_dynamic!
end
config.expect_with :rspec do |expect_config|
expect_config.syntax = :expect
end
end
begin
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
config.after(:all) do
`rm -rf #{Rails.root}/tmp/uploads/*`
end
Spork.prefork(&prefork)
rescue LoadError
prefork.call
# Reset overridden settings
config.after(:each) do
AppConfig.reset_dynamic!
end
end