diff --git a/spec/mspec/lib/mspec/commands/mkspec.rb b/spec/mspec/lib/mspec/commands/mkspec.rb index d10cc35d18..a31cb2191c 100755 --- a/spec/mspec/lib/mspec/commands/mkspec.rb +++ b/spec/mspec/lib/mspec/commands/mkspec.rb @@ -95,7 +95,9 @@ class MkSpec def write_spec(file, meth, exists) if exists - out = `#{ruby} #{MSPEC_HOME}/bin/mspec-run --dry-run --unguarded -fs -e '#{meth}' #{file}` + command = "#{RbConfig.ruby} #{MSPEC_HOME}/bin/mspec-run --dry-run --unguarded -fs -e '#{meth}' #{file}" + puts "$ #{command}" if $DEBUG + out = `#{command}` return if out.include?(meth) end @@ -133,18 +135,6 @@ EOS end end - ## - # Determine and return the path of the ruby executable. - - def ruby - ruby = File.join(RbConfig::CONFIG['bindir'], - RbConfig::CONFIG['ruby_install_name']) - - ruby.gsub! File::SEPARATOR, File::ALT_SEPARATOR if File::ALT_SEPARATOR - - return ruby - end - def self.main ENV['MSPEC_RUNNER'] = '1' diff --git a/spec/mspec/lib/mspec/utils/name_map.rb b/spec/mspec/lib/mspec/utils/name_map.rb index a389b9d1de..bf70e651a2 100644 --- a/spec/mspec/lib/mspec/utils/name_map.rb +++ b/spec/mspec/lib/mspec/utils/name_map.rb @@ -51,6 +51,10 @@ class NameMap SpecVersion ] + ALWAYS_PRIVATE = %w[ + initialize initialize_copy initialize_clone initialize_dup respond_to_missing? + ].map(&:to_sym) + def initialize(filter = false) @seen = {} @filter = filter @@ -86,7 +90,8 @@ class NameMap hash["#{name}."] = ms.sort unless ms.empty? ms = m.public_instance_methods(false) + - m.protected_instance_methods(false) + m.protected_instance_methods(false) + + (m.private_instance_methods(false) & ALWAYS_PRIVATE) ms.map! { |x| x.to_s } hash["#{name}#"] = ms.sort unless ms.empty? diff --git a/spec/mspec/lib/mspec/utils/script.rb b/spec/mspec/lib/mspec/utils/script.rb index dd1603c20a..e86beaab86 100644 --- a/spec/mspec/lib/mspec/utils/script.rb +++ b/spec/mspec/lib/mspec/utils/script.rb @@ -84,12 +84,7 @@ class MSpecScript names.each do |name| config[:path].each do |dir| - begin - file = File.expand_path name, dir - rescue ArgumentError - # File.expand_path can issue error e.g. if HOME is not available - next - end + file = File.expand_path name, dir if @loaded.include?(file) return true elsif File.exist? file @@ -288,7 +283,6 @@ class MSpecScript script = new script.load_default - script.try_load '~/.mspecrc' script.options script.signals script.register diff --git a/spec/mspec/spec/commands/mkspec_spec.rb b/spec/mspec/spec/commands/mkspec_spec.rb index 825add7212..32262723de 100644 --- a/spec/mspec/spec/commands/mkspec_spec.rb +++ b/spec/mspec/spec/commands/mkspec_spec.rb @@ -194,7 +194,7 @@ RSpec.describe MkSpec, "#write_spec" do end it "checks if specs exist for the method if the spec file exists" do - name = Regexp.escape(@script.ruby) + name = Regexp.escape(RbConfig.ruby) expect(@script).to receive(:`).with( %r"#{name} #{MSPEC_HOME}/bin/mspec-run --dry-run --unguarded -fs -e 'Object#inspect' spec/core/tcejbo/inspect_spec.rb") @script.write_spec("spec/core/tcejbo/inspect_spec.rb", "Object#inspect", true) diff --git a/spec/mspec/spec/utils/script_spec.rb b/spec/mspec/spec/utils/script_spec.rb index d9f6eac9a9..c35bda8b47 100644 --- a/spec/mspec/spec/utils/script_spec.rb +++ b/spec/mspec/spec/utils/script_spec.rb @@ -96,11 +96,6 @@ RSpec.describe MSpecScript, ".main" do MSpecScript.main end - it "attempts to load the '~/.mspecrc' script" do - expect(@script).to receive(:try_load).with('~/.mspecrc') - MSpecScript.main - end - it "calls the #options method on the script" do expect(@script).to receive(:options) MSpecScript.main