2013-04-17 19:26:16 +00:00
|
|
|
# -*- coding:binary -*-
|
2012-10-08 21:14:37 +00:00
|
|
|
require 'rubygems'
|
|
|
|
require 'bundler'
|
2013-04-12 15:46:00 +00:00
|
|
|
Bundler.require(:default, :test, :db)
|
2012-10-08 21:14:37 +00:00
|
|
|
|
2013-07-18 17:44:48 +00:00
|
|
|
FILE_FIXTURES_PATH = File.expand_path(File.dirname(__FILE__)) + "/file_fixtures/"
|
|
|
|
|
2012-10-08 21:14:37 +00:00
|
|
|
# add project lib directory to load path
|
|
|
|
spec_pathname = Pathname.new(__FILE__).dirname
|
|
|
|
root_pathname = spec_pathname.join('..').expand_path
|
|
|
|
lib_pathname = root_pathname.join('lib')
|
|
|
|
$LOAD_PATH.unshift(lib_pathname.to_s)
|
|
|
|
|
2012-11-06 22:30:41 +00:00
|
|
|
# must be first require and started before any other requires so that it can measure coverage of all following required
|
|
|
|
# code. It is after the rubygems and bundler only because Bundler.setup supplies the LOAD_PATH to simplecov.
|
|
|
|
require 'simplecov'
|
|
|
|
|
2013-03-14 20:46:18 +00:00
|
|
|
# now that simplecov is loaded, load everything else
|
2012-10-08 21:14:37 +00:00
|
|
|
require 'rspec/core'
|
|
|
|
|
|
|
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
|
|
# in spec/support/ and its subdirectories.
|
|
|
|
support_glob = root_pathname.join('spec', 'support', '**', '*.rb')
|
|
|
|
|
|
|
|
Dir.glob(support_glob) do |path|
|
|
|
|
require path
|
|
|
|
end
|
|
|
|
|
|
|
|
RSpec.configure do |config|
|
|
|
|
config.mock_with :rspec
|
2013-04-01 21:06:40 +00:00
|
|
|
|
|
|
|
# Can't use factory_girl_rails since not using rails, so emulate
|
|
|
|
# factory_girl.set_factory_paths initializer and after_initialize for
|
|
|
|
# FactoryGirl::Railtie
|
|
|
|
config.before(:suite) do
|
|
|
|
# Need to load Mdm models first so factories can use them
|
|
|
|
MetasploitDataModels.require_models
|
|
|
|
|
|
|
|
FactoryGirl.definition_file_paths = [
|
|
|
|
MetasploitDataModels.root.join('spec', 'factories'),
|
|
|
|
# Have metasploit-framework's definition file path last so it can
|
|
|
|
# modify gem factories.
|
|
|
|
Metasploit::Framework.root.join('spec', 'factories')
|
|
|
|
]
|
|
|
|
|
|
|
|
FactoryGirl.find_definitions
|
|
|
|
end
|
2012-10-08 21:14:37 +00:00
|
|
|
end
|
|
|
|
|