Skip to content

Commit b3e76f7

Browse files
author
Brent Cook
committed
Land rapid7#6484, handle rspec failures gracefully if there is no database
2 parents 9327a2f + 478cd2e commit b3e76f7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/metasploit/framework/require.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def self.optionally(name, without_warning)
4949
#
5050
# @return [void]
5151
def self.optionally_active_record_railtie
52-
if ::File.exist?(Rails.application.config.paths['config/database'].first)
52+
if ::Rails.application.config.paths['config/database'].any?
5353
optionally(
5454
'active_record/railtie',
5555
'activerecord not in the bundle, so database support will be disabled.'

spec/spec_helper.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
# Must be explicit as activerecord is optional dependency
1212
require 'active_record/railtie'
1313

14+
require 'metasploit/framework/database'
15+
# check if database.yml is present
16+
unless Metasploit::Framework::Database.configurations_pathname.try(:to_path)
17+
fail 'RSPEC currently needs a configured database'
18+
end
19+
1420
require File.expand_path('../../config/environment', __FILE__)
1521

1622
# Don't `require 'rspec/rails'` as it includes support for pieces of rails that metasploit-framework doesn't use

0 commit comments

Comments
 (0)