# Configure Rails Environment ENV['RAILS_ENV'] = 'test' require 'rubygems' require 'bundler' Bundler.setup(:default, :test) # Require simplecov before loading ..dummy/config/environment.rb because it will cause metasploit_data_models/lib to # be loaded, which would result in Coverage not recording hits for any of the files. require 'simplecov' require 'coveralls' if ENV['TRAVIS'] == 'true' # don't generate local report as it is inaccessible on travis-ci, which is why coveralls is being used. SimpleCov.formatter = Coveralls::SimpleCov::Formatter else SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ # either generate the local report SimpleCov::Formatter::HTMLFormatter ] end require File.expand_path('../dummy/config/environment.rb', __FILE__) require 'rspec/rails' require 'rspec/autorun' # full backtrace in logs so its easier to trace errors Rails.backtrace_cleaner.remove_silencers! # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. engines = [ Metasploit::Concern::Engine, MetasploitDataModels::Engine ] engines.each do |engine| support_glob = engine.root.join('spec', 'support', '**', '*.rb') Dir.glob(support_glob) do |path| require path end end RSpec.configure do |config| config.before(:each) do # Rex is only available when testing with metasploit-framework or pro, so stub out the methods that require it Mdm::Workspace.any_instance.stub(:valid_ip_or_range? => true) end config.mock_with :rspec config.use_transactional_fixtures = true config.order = :random end