From a580171e3239a298f8edc7f500a7041ef3fa4171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Sun, 30 Nov 2014 21:09:43 +0100 Subject: [PATCH] Replace spork with spring, update & use binstubs Spring is the recommended application preloader for rails --- .rspec | 1 - Gemfile | 7 +- Gemfile.lock | 21 ++-- Guardfile | 20 +--- Procfile | 6 +- bin/autospec | 16 --- bin/compass | 16 --- bin/cucumber | 17 +--- bin/foreman | 16 --- bin/rails | 4 + bin/rake | 4 + bin/rspec | 17 +--- bin/sass | 16 --- bin/sass-convert | 16 --- bin/scss | 16 --- bin/spork | 16 --- bin/spring | 18 ++++ config/unicorn.rb | 4 +- features/support/env.rb | 141 +++++++++++--------------- lib/configuration_methods.rb | 2 +- script/install/setup | 2 +- script/server | 8 +- spec/spec_helper.rb | 187 ++++++++++++++++------------------- 23 files changed, 205 insertions(+), 366 deletions(-) delete mode 100755 bin/autospec delete mode 100755 bin/compass delete mode 100755 bin/foreman delete mode 100755 bin/sass delete mode 100755 bin/sass-convert delete mode 100755 bin/scss delete mode 100755 bin/spork create mode 100755 bin/spring diff --git a/.rspec b/.rspec index 7b862b57b..174e25596 100644 --- a/.rspec +++ b/.rspec @@ -3,4 +3,3 @@ --color --tag ~performance --order random ---drb diff --git a/Gemfile b/Gemfile index 6a017c3fb..101d789de 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 3b6b785ee..3dc8c4732 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/Guardfile b/Guardfile index 6da0408e0..f366958ed 100644 --- a/Guardfile +++ b/Guardfile @@ -1,7 +1,4 @@ -# 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' } diff --git a/Procfile b/Procfile index ba5e1bdc0..4119cf536 100644 --- a/Procfile +++ b/Procfile @@ -1,3 +1,3 @@ -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 diff --git a/bin/autospec b/bin/autospec deleted file mode 100755 index 64dcb9cb0..000000000 --- a/bin/autospec +++ /dev/null @@ -1,16 +0,0 @@ -#!/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') diff --git a/bin/compass b/bin/compass deleted file mode 100755 index e1ac74938..000000000 --- a/bin/compass +++ /dev/null @@ -1,16 +0,0 @@ -#!/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') diff --git a/bin/cucumber b/bin/cucumber index caa06543c..12971cdce 100755 --- a/bin/cucumber +++ b/bin/cucumber @@ -1,16 +1,7 @@ #!/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') diff --git a/bin/foreman b/bin/foreman deleted file mode 100755 index 586c07e08..000000000 --- a/bin/foreman +++ /dev/null @@ -1,16 +0,0 @@ -#!/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') diff --git a/bin/rails b/bin/rails index 728cd85aa..7feb6a30e 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,8 @@ #!/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' diff --git a/bin/rake b/bin/rake index 17240489f..8017a0271 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,8 @@ #!/usr/bin/env ruby +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/bin/rspec b/bin/rspec index 0c86b5c6f..20060ebd7 100755 --- a/bin/rspec +++ b/bin/rspec @@ -1,16 +1,7 @@ #!/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') diff --git a/bin/sass b/bin/sass deleted file mode 100755 index d65bb10a3..000000000 --- a/bin/sass +++ /dev/null @@ -1,16 +0,0 @@ -#!/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') diff --git a/bin/sass-convert b/bin/sass-convert deleted file mode 100755 index ddde743f3..000000000 --- a/bin/sass-convert +++ /dev/null @@ -1,16 +0,0 @@ -#!/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') diff --git a/bin/scss b/bin/scss deleted file mode 100755 index 9f5e435d6..000000000 --- a/bin/scss +++ /dev/null @@ -1,16 +0,0 @@ -#!/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') diff --git a/bin/spork b/bin/spork deleted file mode 100755 index a127260ef..000000000 --- a/bin/spork +++ /dev/null @@ -1,16 +0,0 @@ -#!/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') diff --git a/bin/spring b/bin/spring new file mode 100755 index 000000000..7f24d96fb --- /dev/null +++ b/bin/spring @@ -0,0 +1,18 @@ +#!/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 diff --git a/config/unicorn.rb b/config/unicorn.rb index 52963a762..719c357c2 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -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' diff --git a/features/support/env.rb b/features/support/env.rb index cd22cd58d..f96fb26a6 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,109 +1,84 @@ 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) +Before do + Devise.mailer.deliveries = [] +end - #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"])) +After do + if Capybara.current_session.driver.respond_to?(:browser) + Capybara.reset_sessions! + # Capybara.current_session.driver.browser.manage.delete_all_cookies end 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 - end +Before('@localserver') do + TestServerFixture.start_if_needed + CapybaraSettings.instance.save + Capybara.current_driver = :selenium + Capybara.run_server = false end -begin - require 'spork' - #uncomment the following line to use spork with the debugger - #require 'spork/ext/ruby-debug' - - 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 diff --git a/lib/configuration_methods.rb b/lib/configuration_methods.rb index de99b40c8..2daa0ed4c 100644 --- a/lib/configuration_methods.rb +++ b/lib/configuration_methods.rb @@ -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 diff --git a/script/install/setup b/script/install/setup index 503538740..586e7a0f0 100644 --- a/script/install/setup +++ b/script/install/setup @@ -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" diff --git a/script/server b/script/server index 18bd2666e..46b17b90d 100755 --- a/script/server +++ b/script/server @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d8cb8a519..499e52fbf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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. +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' - #require "rails/application" - #Spork.trap_method(Rails::Application::RoutesReloader, :reload!) +include HelperMethods - 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 - - def set_up_friends - [local_luke, local_leia, remote_raphael] - end - - def alice - @alice ||= User.where(:username => 'alice').first - end - - def bob - @bob ||= User.where(:username => 'bob').first - end - - def eve - @eve ||= User.where(:username => 'eve').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 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')) - - # 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 - end +Dir["#{File.dirname(__FILE__)}/shared_behaviors/**/*.rb"].each do |f| + require f end -begin - require 'spork' - #uncomment the following line to use spork with the debugger - #require 'spork/ext/ruby-debug' +ProcessedImage.enable_processing = false +UnprocessedImage.enable_processing = false - Spork.prefork(&prefork) -rescue LoadError - prefork.call +def set_up_friends + [local_luke, local_leia, remote_raphael] +end + +def alice + @alice ||= User.where(:username => 'alice').first +end + +def bob + @bob ||= User.where(:username => 'bob').first +end + +def eve + @eve ||= User.where(:username => 'eve').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 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')) + +# 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 end # https://makandracards.com/makandra/950-speed-up-rspec-by-deferring-garbage-collection