From 51c0397531d115fd4da56228340008c5e13b4549 Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sun, 20 Nov 2011 21:39:46 +1100 Subject: [PATCH] Removed spork to get spec helper working. Will readd later if required. --- Gemfile | 1 - Gemfile.lock | 2 - .../locomotive/liquid/drops/contents_spec.rb | 3 - spec/spec_helper.rb | 108 +++++------------- 4 files changed, 28 insertions(+), 86 deletions(-) diff --git a/Gemfile b/Gemfile index d286bc46..9c3c9d5a 100644 --- a/Gemfile +++ b/Gemfile @@ -78,7 +78,6 @@ group :test do gem 'capybara' gem 'database_cleaner' - gem 'spork', '~> 0.9.0.rc' gem 'launchy' gem 'mocha', '0.9.12' # :git => 'git://github.com/floehopper/mocha.git' end diff --git a/Gemfile.lock b/Gemfile.lock index 027d3d5e..3f66eab6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -300,7 +300,6 @@ GEM ffi (= 1.0.9) json_pure rubyzip - spork (0.9.0.rc9) sprockets (2.0.3) hike (~> 1.2) rack (~> 1.0) @@ -383,7 +382,6 @@ DEPENDENCIES rubyzip sanitize (~> 2.0.3) sass-rails (~> 3.1.4) - spork (~> 0.9.0.rc) tinymce-rails uglifier (~> 1.0.4) unicorn diff --git a/spec/lib/locomotive/liquid/drops/contents_spec.rb b/spec/lib/locomotive/liquid/drops/contents_spec.rb index a0bb806d..d39758b1 100644 --- a/spec/lib/locomotive/liquid/drops/contents_spec.rb +++ b/spec/lib/locomotive/liquid/drops/contents_spec.rb @@ -3,9 +3,6 @@ require 'spec_helper' describe Locomotive::Liquid::Drops::Contents do before(:each) do - # Reload the file (needed for spork) - load File.join(Rails.root, 'lib', 'locomotive', 'liquid', 'drops', 'contents.rb') - @site = FactoryGirl.build(:site) @content_type = FactoryGirl.build(:content_type, :site => @site, :slug => 'projects') end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5ef675c5..a745e68c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,93 +1,41 @@ -# Note: if segmentation fault with spork / imagemagick on mac os x, take a look at: -# http://stackoverflow.com/questions/2838307/why-is-this-rmagick-call-generating-a-segmentation-fault +ENV["RAILS_ENV"] ||= 'test' -require 'rubygems' -require 'spork' +require 'rails/mongoid' +require File.join(File.dirname(__FILE__), 'dummy', 'config', 'environment.rb') +require 'rspec/rails' +require 'factory_girl' -# figure out where we are being loaded from -if $LOADED_FEATURES.grep(/spec\/spec_helper\.rb/).any? - begin - raise "foo" - rescue => e - puts <<-MSG - =================================================== - It looks like spec_helper.rb has been loaded - multiple times. Normalize the require to: +# 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 } - require "spec/spec_helper" +Locomotive.configure_for_test - Things like File.join and File.expand_path will - cause it to be loaded multiple times. +RSpec.configure do |config| - Loaded this time from: + config.include(Locomotive::RSpec::Matchers) - #{e.backtrace.join("\n ")} - =================================================== - MSG + config.mock_with :mocha + + config.before(:each) do + Locomotive.config.heroku = false end -end + require 'database_cleaner' + config.before(:suite) do + DatabaseCleaner.strategy = :truncation + DatabaseCleaner.orm = 'mongoid' + end -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. - - # This file is copied to spec/ when you run 'rails generate rspec:install' - ENV["RAILS_ENV"] ||= 'test' - - # Avoid preloading models - require 'rails/mongoid' - Spork.trap_class_method(Rails::Mongoid, :load_models) - - require File.expand_path('../../config/environment', __FILE__) - - require 'rspec/rails' - - require 'factory_girl' - Spork.trap_class_method(FactoryGirl, :find_definitions) - - # 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 } - - Locomotive.configure_for_test - - RSpec.configure do |config| - - config.include(Locomotive::RSpec::Matchers) - - config.mock_with :mocha - - config.before(:each) do - Locomotive.config.heroku = false - end - - require 'database_cleaner' - config.before(:suite) do - DatabaseCleaner.strategy = :truncation - DatabaseCleaner.orm = 'mongoid' - end - - config.before(:each) do - if self.described_class != Locomotive::Import::Job - DatabaseCleaner.clean - end - end - - config.before(:all) do - if self.described_class == Locomotive::Import::Job - DatabaseCleaner.clean - end + config.before(:each) do + if self.described_class != Locomotive::Import::Job + DatabaseCleaner.clean end end + config.before(:all) do + if self.described_class == Locomotive::Import::Job + DatabaseCleaner.clean + end + end end - -Spork.each_run do - # This code will be run each time you run your specs. - Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } - - # loading ruby file directly breaks the tests - # Dir[Rails.root.join('app/models/*.rb')].each { |f| load f } -end \ No newline at end of file