mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/mspec@b60306d
This commit is contained in:
parent
3e7c42a239
commit
5a1ab740fc
5 changed files with 11 additions and 27 deletions
|
@ -95,7 +95,9 @@ class MkSpec
|
||||||
|
|
||||||
def write_spec(file, meth, exists)
|
def write_spec(file, meth, exists)
|
||||||
if 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)
|
return if out.include?(meth)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -133,18 +135,6 @@ EOS
|
||||||
end
|
end
|
||||||
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
|
def self.main
|
||||||
ENV['MSPEC_RUNNER'] = '1'
|
ENV['MSPEC_RUNNER'] = '1'
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,10 @@ class NameMap
|
||||||
SpecVersion
|
SpecVersion
|
||||||
]
|
]
|
||||||
|
|
||||||
|
ALWAYS_PRIVATE = %w[
|
||||||
|
initialize initialize_copy initialize_clone initialize_dup respond_to_missing?
|
||||||
|
].map(&:to_sym)
|
||||||
|
|
||||||
def initialize(filter = false)
|
def initialize(filter = false)
|
||||||
@seen = {}
|
@seen = {}
|
||||||
@filter = filter
|
@filter = filter
|
||||||
|
@ -86,7 +90,8 @@ class NameMap
|
||||||
hash["#{name}."] = ms.sort unless ms.empty?
|
hash["#{name}."] = ms.sort unless ms.empty?
|
||||||
|
|
||||||
ms = m.public_instance_methods(false) +
|
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 }
|
ms.map! { |x| x.to_s }
|
||||||
hash["#{name}#"] = ms.sort unless ms.empty?
|
hash["#{name}#"] = ms.sort unless ms.empty?
|
||||||
|
|
||||||
|
|
|
@ -84,12 +84,7 @@ class MSpecScript
|
||||||
|
|
||||||
names.each do |name|
|
names.each do |name|
|
||||||
config[:path].each do |dir|
|
config[:path].each do |dir|
|
||||||
begin
|
file = File.expand_path name, dir
|
||||||
file = File.expand_path name, dir
|
|
||||||
rescue ArgumentError
|
|
||||||
# File.expand_path can issue error e.g. if HOME is not available
|
|
||||||
next
|
|
||||||
end
|
|
||||||
if @loaded.include?(file)
|
if @loaded.include?(file)
|
||||||
return true
|
return true
|
||||||
elsif File.exist? file
|
elsif File.exist? file
|
||||||
|
@ -288,7 +283,6 @@ class MSpecScript
|
||||||
|
|
||||||
script = new
|
script = new
|
||||||
script.load_default
|
script.load_default
|
||||||
script.try_load '~/.mspecrc'
|
|
||||||
script.options
|
script.options
|
||||||
script.signals
|
script.signals
|
||||||
script.register
|
script.register
|
||||||
|
|
|
@ -194,7 +194,7 @@ RSpec.describe MkSpec, "#write_spec" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "checks if specs exist for the method if the spec file exists" do
|
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(
|
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")
|
%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)
|
@script.write_spec("spec/core/tcejbo/inspect_spec.rb", "Object#inspect", true)
|
||||||
|
|
|
@ -96,11 +96,6 @@ RSpec.describe MSpecScript, ".main" do
|
||||||
MSpecScript.main
|
MSpecScript.main
|
||||||
end
|
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
|
it "calls the #options method on the script" do
|
||||||
expect(@script).to receive(:options)
|
expect(@script).to receive(:options)
|
||||||
MSpecScript.main
|
MSpecScript.main
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue