From e3ab2e97475bcacaf9a1c6a071b0f9b63fdb7669 Mon Sep 17 00:00:00 2001 From: Brandon Turner Date: Fri, 12 Apr 2013 10:46:00 -0500 Subject: [PATCH] Fix specs with bundler groups Also output warnings when running Rake when the db group isn't included. --- Rakefile | 38 ++++++++++++++++++++++++-------------- spec/spec_helper.rb | 2 +- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Rakefile b/Rakefile index ca3a17809b..ea301b6a4a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,5 @@ require 'bundler/setup' -require 'metasploit_data_models' - pathname = Pathname.new(__FILE__) root = pathname.parent @@ -18,6 +16,8 @@ $LOAD_PATH.unshift(lib_pathname.to_s) rakefile_glob = root.join('lib', 'tasks', '**', '*.rake').to_path Dir.glob(rakefile_glob) do |rakefile| + # Skip database tasks, will load them later if MDM is present + next if rakefile =~ /database\.rake$/ load rakefile end @@ -36,6 +36,28 @@ else task :default => :spec end +begin + require 'metasploit_data_models' +rescue LoadError + puts "metasploit_data_models not in bundle, so can't set up db tasks. " \ + "To run database tasks, ensure to install the db bundler group." + + print_without = true +else + load 'lib/tasks/database.rake' + metasploit_data_models_task_glob = MetasploitDataModels.root.join( + 'lib', + 'tasks', + '**', + '*.rake' + ).to_s + # include tasks from metasplioit_data_models, such as `rake yard`. + # metasploit-framework specific yard options are in .yardopts + Dir.glob(metasploit_data_models_task_glob) do |path| + load path + end +end + begin require 'yard' rescue LoadError @@ -45,18 +67,6 @@ rescue LoadError print_without = true end -metasploit_data_models_task_glob = MetasploitDataModels.root.join( - 'lib', - 'tasks', - '**', - '*.rake' -).to_s - -# include tasks from metasplioit_data_models, such as `rake yard`. -# metasploit-framework specific yard options are in .yardopts -Dir.glob(metasploit_data_models_task_glob) do |path| - load path -end if print_without puts "Bundle currently installed " \ diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8f58fa6d0f..a1e1f1f409 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ require 'rubygems' require 'bundler' -Bundler.require(:default, :test) +Bundler.require(:default, :test, :db) # add project lib directory to load path spec_pathname = Pathname.new(__FILE__).dirname