diff --git a/lib/msf/core.rb b/lib/msf/core.rb index af2cbe4e13..5cbaf19efa 100644 --- a/lib/msf/core.rb +++ b/lib/msf/core.rb @@ -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 diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index f3b41ea186..df0207d4c4 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -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 ) diff --git a/spec/lib/msf/core_spec.rb b/spec/lib/msf/core_spec.rb deleted file mode 100644 index 206510a6f7..0000000000 --- a/spec/lib/msf/core_spec.rb +++ /dev/null @@ -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 \ No newline at end of file