Refactor Rakefile and spec files for better organization and readability

This commit is contained in:
Stephen
2024-05-05 03:27:23 +10:00
parent 0ff092902f
commit ed7c9e8d3b
6 changed files with 27 additions and 36 deletions

View File

@@ -3,24 +3,27 @@
# Browser Exploitation Framework (BeEF) - https://beefproject.com
# See the file 'doc/COPYING' for copying permission
#
require 'yaml'
require 'bundler/setup'
load 'tasks/otr-activerecord.rake'
require 'rspec/core/rake_task'
# load 'tasks/otr-activerecord.rake'
task :default => ["spec"]
task :default => ["short"]
desc 'Generate API documentation to doc/rdocs/index.html'
task :rdoc do
Rake::Task['rdoc:rerdoc'].invoke
RSpec::Core::RakeTask.new(:short) do |task|
task.rspec_opts = ['--tag ~run_on_browserstack', '--tag ~run_on_long_tests']
end
## RSPEC
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |task|
RSpec::Core::RakeTask.new(:long) do |task|
task.rspec_opts = ['--tag ~run_on_browserstack']
end
RSpec::Core::RakeTask.new(:long_only) do |task|
task.rspec_opts = ['--tag ~run_on_browserstack', '--tag run_on_long_tests']
end
################################
# Browserstack
RSpec::Core::RakeTask.new(:browserstack) do |task|
task.rspec_opts = ['--tag run_on_browserstack']
end
@@ -53,7 +56,7 @@ namespace :ssl do
end
Rake::Task['ssl:replace'].invoke
end
desc 'Re-generate SSL certificate'
task :replace do
if File.file?('/usr/local/bin/openssl')
@@ -68,6 +71,14 @@ namespace :ssl do
end
end
################################
# Generate API documentation
desc 'Generate API documentation to doc/rdocs/index.html'
task :rdoc do
Rake::Task['rdoc:rerdoc'].invoke
end
################################
# rdoc
@@ -113,7 +124,6 @@ end
@beef_process_id = nil;
@beef_config_file = 'tmp/rk_beef_conf.yaml';
task :beef_start => 'beef' do
# read environment param for creds or use bad_fred
test_user = ENV['TEST_BEEF_USER'] || 'bad_fred'
@@ -188,24 +198,6 @@ file '/tmp/msf-test/msfconsole' do
sh "cd test;git clone https://github.com/rapid7/metasploit-framework.git /tmp/msf-test"
end
################################
# Create Mac DMG File
task :dmg do
puts "\nCreating Working Directory\n";
sh "mkdir dmg";
sh "mkdir dmg/BeEF";
sh "rsync * dmg/BeEF --exclude=dmg -r";
sh "ln -s /Applications dmg/";
puts "\nCreating DMG File\n"
sh "hdiutil create ./BeEF.dmg -srcfolder dmg -volname BeEF -ov";
puts "\nCleaning Up\n"
sh "rm -r dmg";
puts "\nBeEF.dmg created\n"
end
################################
# ActiveRecord
namespace :db do

View File

@@ -4,7 +4,7 @@
# See the file 'doc/COPYING' for copying permission
#
RSpec.describe 'BeEF API Rate Limit' do
RSpec.describe 'BeEF API Rate Limit', run_on_long_tests: true do
before(:each) do
@pid = start_beef_server_and_wait

View File

@@ -8,7 +8,7 @@ require 'rest-client'
require 'spec/support/constants.rb'
require 'spec/support/ui_support.rb'
RSpec.describe 'Load All Modules Integration' do
RSpec.describe 'Load All Modules Integration', run_on_long_tests: true do
before(:each) do
@pid, @beef_session, @hooked_browser = start_beef_and_hook_browser
end

View File

@@ -8,7 +8,7 @@ require 'rest-client'
require 'spec/support/constants.rb'
require 'spec/support/ui_support.rb'
RSpec.describe 'Debug Modules Integration' do
RSpec.describe 'Debug Modules Integration', run_on_long_tests: true do
before(:each) do
@pid, @beef_session, @hooked_browser = start_beef_and_hook_browser
end

View File

@@ -7,7 +7,7 @@ require 'spec_helper'
require 'capybara/rspec'
require_relative '../support/beef_test'
RSpec.describe BeefTest do
RSpec.describe BeefTest, run_on_long_tests: true do
before(:each) do
@pid = start_beef_server_and_wait

View File

@@ -6,12 +6,11 @@
require 'rspec'
require 'spec/support/constants.rb'
RSpec.describe 'Beef Login' do
RSpec.describe 'Beef Login', run_on_long_tests: true do
let(:session) { Capybara::Session.new(:selenium_headless) }
before(:each) do
@pid = start_beef_server
# sleep 2.0
end
after(:each) do