Use Msf::Config.install_root instead of Msf.root

Msf::Config.install_root already existed, but I didn't know about it
until egypt pointed it out, so remove the new Msf.root and use
Msf::Config.install_root in the specs instead.
This commit is contained in:
Luke Imhoff
2012-10-30 10:46:02 -05:00
parent 055f95898d
commit 5709ffc42b
3 changed files with 11 additions and 36 deletions
-14
View File
@@ -19,20 +19,6 @@ require 'rex/ui'
module Msf
LogSource = "core"
# Returns Pathname of the root of the Metasploit Framework source
#
# @return [Pathname] root directory above lib, data, modules, etc.
def self.root
unless instance_variable_defined? :@root
msf_pathname = Pathname.new(__FILE__).dirname
lib_pathname = msf_pathname.parent
@root = lib_pathname.parent
end
@root
end
end
# General
+11 -6
View File
@@ -3,6 +3,10 @@ require 'spec_helper'
require 'msf/core'
describe Msf::Modules::Loader::Base do
let(:described_class_pathname) do
root_pathname.join('lib', 'msf', 'core', 'modules', 'loader', 'base.rb')
end
let(:malformed_module_content) do
<<-EOS
class Metasploit3
@@ -38,7 +42,11 @@ describe Msf::Modules::Loader::Base do
end
let(:parent_pathname) do
Msf.root.join('modules')
root_pathname.join('modules')
end
let(:root_pathname) do
Pathname.new(Msf::Config.install_root)
end
let(:type) do
@@ -46,9 +54,6 @@ describe Msf::Modules::Loader::Base do
end
context 'CONSTANTS' do
let(:pathname) do
Msf.root.join('lib', 'msf', 'core', 'modules', 'loader', 'base.rb')
end
context 'DIRECTORY_BY_TYPE' do
let(:directory_by_type) do
@@ -88,7 +93,7 @@ describe Msf::Modules::Loader::Base do
it 'should be line number for first line of NAMESPACE_MODULE_CONTENT' do
file_lines = []
pathname.open do |f|
described_class_pathname.open do |f|
file_lines = f.to_a
end
@@ -820,7 +825,7 @@ describe Msf::Modules::Loader::Base do
:module_eval
).with(
anything,
Msf.root.join('lib', 'msf', 'core', 'modules', 'loader', 'base.rb').to_s,
described_class_pathname.to_s,
anything
)
-16
View File
@@ -1,16 +0,0 @@
require 'spec_helper'
require 'msf/core'
describe Msf do
context 'root' do
it 'should be the project root' do
spec_lib_msf_pathname = Pathname.new(__FILE__).dirname
spec_lib_pathname = spec_lib_msf_pathname.parent
spec_pathname = spec_lib_pathname.parent
root_pathname = spec_pathname.parent
Msf.root.should == root_pathname
end
end
end