From 8c5584be6d08c71f5f19e743498da83083dd7e0f Mon Sep 17 00:00:00 2001 From: Philip Arndt Date: Sun, 20 Nov 2011 13:07:49 +1300 Subject: [PATCH 1/2] Refactored else + if to elsif --- core/lib/tasks/core.rake | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/lib/tasks/core.rake b/core/lib/tasks/core.rake index 1ce4fa97c3f..9b1131b1e3a 100644 --- a/core/lib/tasks/core.rake +++ b/core/lib/tasks/core.rake @@ -12,11 +12,9 @@ For .rb use rake db:load_file[/absolute/path/to/sample/filename.rb]} if %w{.csv .yml}.include? file.extname puts "loading fixture #{Pathname.new(args.dir).join(file)}" Spree::Core::Fixtures.create_fixtures(args.dir, file.to_s.sub(file.extname, "")) - else - if file.exist? - puts "loading ruby #{file}" - require file - end + elsif file.exist? + puts "loading ruby #{file}" + require file end end From 6a2d3674e4bff1e933b3457cef10285826ad2a7d Mon Sep 17 00:00:00 2001 From: Philip Arndt Date: Sun, 20 Nov 2011 13:30:28 +1300 Subject: [PATCH 2/2] Improved performance of creating every single test_app by making a command rake test_app that runs in the spree root directory (not inside an engine). --- Rakefile | 10 ++++++++++ core/lib/generators/spree/dummy/dummy_generator.rb | 2 +- core/lib/spree/core/testing_support/common_rake.rb | 4 +++- core/lib/tasks/core.rake | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 6d12b30087e..7951cc1dc11 100644 --- a/Rakefile +++ b/Rakefile @@ -2,6 +2,7 @@ require 'rake' require 'rubygems/package_task' require 'thor/group' require File.expand_path('../lib/generators/spree/install/install_generator', __FILE__) +require 'spree/core/testing_support/common_rake' spec = eval(File.read('spree.gemspec')) Gem::PackageTask.new(spec) do |pkg| @@ -21,6 +22,15 @@ def run_all_tests(database_name) #end end +desc "Generates a dummy app for testing for every Spree engine" +task :test_app do + %w(api auth core dash promo).each do |engine| + ENV['LIB_NAME'] = File.join('spree', engine) + ENV['DUMMY_PATH'] = File.expand_path("../#{engine}/spec/dummy", __FILE__) + Rake::Task['common:test_app'].execute + end +end + task :default => :all_tests desc "Run all tests for sqlite3 only" diff --git a/core/lib/generators/spree/dummy/dummy_generator.rb b/core/lib/generators/spree/dummy/dummy_generator.rb index db377ac7edb..cf215bb850d 100644 --- a/core/lib/generators/spree/dummy/dummy_generator.rb +++ b/core/lib/generators/spree/dummy/dummy_generator.rb @@ -67,7 +67,7 @@ def cucumber_environment protected def dummy_path - 'spec/dummy' + ENV['DUMMY_PATH'] || 'spec/dummy' end def module_name diff --git a/core/lib/spree/core/testing_support/common_rake.rb b/core/lib/spree/core/testing_support/common_rake.rb index 6ff768a45af..c01bb8a6d30 100644 --- a/core/lib/spree/core/testing_support/common_rake.rb +++ b/core/lib/spree/core/testing_support/common_rake.rb @@ -1,4 +1,6 @@ -require '../lib/generators/spree/install/install_generator' +unless defined?(Spree::InstallGenerator) + require '../lib/generators/spree/install/install_generator' +end desc "Generates a dummy app for testing" namespace :common do diff --git a/core/lib/tasks/core.rake b/core/lib/tasks/core.rake index 9b1131b1e3a..0c74999bda5 100644 --- a/core/lib/tasks/core.rake +++ b/core/lib/tasks/core.rake @@ -2,7 +2,7 @@ require 'active_record' require 'spree/core/custom_fixtures' namespace :db do - desc %q{Loads a specified fixture file: + desc %q{Loads a specified fixture file: For .yml/.csv use rake db:load_file[spree/filename.yml, /absolute/path/to/parent/] For .rb use rake db:load_file[/absolute/path/to/sample/filename.rb]}