mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Drop support for Rubinius
Fixes #1775 (Drop support for Rubinius) I am amazed how many hacks we've had just to support Rubinius. It feels good to be able to remove them and reduce the complexity of the codebase.
This commit is contained in:
parent
a6428b2f43
commit
743b905c81
24 changed files with 242 additions and 334 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,7 +11,6 @@ coverage/
|
||||||
/tags
|
/tags
|
||||||
vendor
|
vendor
|
||||||
*.gem
|
*.gem
|
||||||
.rbx/
|
|
||||||
.rvmrc
|
.rvmrc
|
||||||
Gemfile.lock
|
Gemfile.lock
|
||||||
*.swp
|
*.swp
|
||||||
|
|
|
@ -206,7 +206,6 @@ Layout/EmptyLinesAroundAccessModifier:
|
||||||
- 'lib/pry/helpers/table.rb'
|
- 'lib/pry/helpers/table.rb'
|
||||||
- 'lib/pry/history_array.rb'
|
- 'lib/pry/history_array.rb'
|
||||||
- 'lib/pry/plugins.rb'
|
- 'lib/pry/plugins.rb'
|
||||||
- 'lib/pry/rbx_path.rb'
|
|
||||||
- 'spec/method_spec.rb'
|
- 'spec/method_spec.rb'
|
||||||
|
|
||||||
# Offense count: 1
|
# Offense count: 1
|
||||||
|
@ -828,7 +827,6 @@ Naming/MethodName:
|
||||||
Naming/PredicateName:
|
Naming/PredicateName:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'spec/**/*'
|
- 'spec/**/*'
|
||||||
- 'lib/pry/rbx_path.rb'
|
|
||||||
|
|
||||||
# Offense count: 26
|
# Offense count: 26
|
||||||
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
||||||
|
@ -842,13 +840,6 @@ Performance/Casecmp:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'lib/pry/slop/option.rb'
|
- 'lib/pry/slop/option.rb'
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: IncludeActiveSupportAliases.
|
|
||||||
Performance/DoubleStartEndWith:
|
|
||||||
Exclude:
|
|
||||||
- 'lib/pry/rbx_path.rb'
|
|
||||||
|
|
||||||
# Offense count: 2
|
# Offense count: 2
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
Performance/InefficientHashSearch:
|
Performance/InefficientHashSearch:
|
||||||
|
@ -1050,7 +1041,6 @@ Style/DoubleNegation:
|
||||||
- 'lib/pry/method/weird_method_locator.rb'
|
- 'lib/pry/method/weird_method_locator.rb'
|
||||||
- 'lib/pry/pager.rb'
|
- 'lib/pry/pager.rb'
|
||||||
- 'lib/pry/platform.rb'
|
- 'lib/pry/platform.rb'
|
||||||
- 'lib/pry/rbx_path.rb'
|
|
||||||
- 'lib/pry/slop/option.rb'
|
- 'lib/pry/slop/option.rb'
|
||||||
- 'lib/pry/wrapped_module.rb'
|
- 'lib/pry/wrapped_module.rb'
|
||||||
|
|
||||||
|
|
6
Gemfile
6
Gemfile
|
@ -22,9 +22,3 @@ end
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem 'simplecov', '~> 0.8.0'
|
gem 'simplecov', '~> 0.8.0'
|
||||||
end
|
end
|
||||||
|
|
||||||
platform :rbx do
|
|
||||||
gem 'rubysl-singleton'
|
|
||||||
gem 'rubysl-prettyprint'
|
|
||||||
gem 'rb-readline'
|
|
||||||
end
|
|
||||||
|
|
|
@ -133,7 +133,6 @@ require 'pathname'
|
||||||
|
|
||||||
require 'pry/version'
|
require 'pry/version'
|
||||||
require 'pry/repl'
|
require 'pry/repl'
|
||||||
require 'pry/rbx_path'
|
|
||||||
require 'pry/code'
|
require 'pry/code'
|
||||||
require 'pry/history_array'
|
require 'pry/history_array'
|
||||||
require 'pry/helpers'
|
require 'pry/helpers'
|
||||||
|
|
|
@ -41,8 +41,6 @@ class Pry
|
||||||
Pry.line_buffer.drop(1)
|
Pry.line_buffer.drop(1)
|
||||||
elsif Pry::Method::Patcher.code_for(@filename)
|
elsif Pry::Method::Patcher.code_for(@filename)
|
||||||
Pry::Method::Patcher.code_for(@filename)
|
Pry::Method::Patcher.code_for(@filename)
|
||||||
elsif RbxPath.is_core_path?(@filename)
|
|
||||||
File.read(RbxPath.convert_path_to_full(@filename))
|
|
||||||
else
|
else
|
||||||
path = abs_path
|
path = abs_path
|
||||||
@code_type = type_from_filename(path)
|
@code_type = type_from_filename(path)
|
||||||
|
|
|
@ -317,7 +317,7 @@ class Pry
|
||||||
# `nil` if the filename is unavailable.
|
# `nil` if the filename is unavailable.
|
||||||
def source_file
|
def source_file
|
||||||
if source_location.nil?
|
if source_location.nil?
|
||||||
if !rbx? and source_type == :c
|
if source_type == :c
|
||||||
info = pry_doc_info
|
info = pry_doc_info
|
||||||
info.file if info
|
info.file if info
|
||||||
end
|
end
|
||||||
|
@ -531,9 +531,9 @@ class Pry
|
||||||
end
|
end
|
||||||
|
|
||||||
def ruby_source
|
def ruby_source
|
||||||
# clone of MethodSource.source_helper that knows to use our
|
# Clone of `MethodSource.source_helper` that knows to use our
|
||||||
# hacked version of source_location for rbx core methods, and
|
# hacked version of `source_location` for our input buffer for methods
|
||||||
# our input buffer for methods defined in (pry)
|
# defined in `(pry)`.
|
||||||
file, line = *source_location
|
file, line = *source_location
|
||||||
raise SourceNotFoundError, "Could not locate source for #{name_with_owner}!" unless file
|
raise SourceNotFoundError, "Could not locate source for #{name_with_owner}!" unless file
|
||||||
|
|
||||||
|
|
|
@ -100,8 +100,7 @@ class Pry
|
||||||
# __FILE__ and __LINE__ the binding is at, we can hope to disambiguate these cases.
|
# __FILE__ and __LINE__ the binding is at, we can hope to disambiguate these cases.
|
||||||
#
|
#
|
||||||
# This obviously won't work if the source is unavaiable for some reason, or if both
|
# This obviously won't work if the source is unavaiable for some reason, or if both
|
||||||
# methods have the same __FILE__ and __LINE__, or if we're in rbx where b.eval('__LINE__')
|
# methods have the same __FILE__ and __LINE__.
|
||||||
# is broken.
|
|
||||||
#
|
#
|
||||||
# @return [Pry::Method, nil] The Pry::Method representing the
|
# @return [Pry::Method, nil] The Pry::Method representing the
|
||||||
# superclass method.
|
# superclass method.
|
||||||
|
@ -122,9 +121,9 @@ class Pry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Uhoh... none of the methods in the chain had the right __FILE__ and __LINE__
|
# Uhoh... none of the methods in the chain had the right `__FILE__` and
|
||||||
# This may be caused by rbx https://github.com/rubinius/rubinius/issues/953,
|
# `__LINE__` due to unknown circumstances.
|
||||||
# or other unknown circumstances (TODO: we should warn the user when this happens)
|
# TODO: we should warn the user when this happens.
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -59,14 +59,6 @@ module Pry::Platform
|
||||||
jruby? and RbConfig::CONFIG['ruby_version'] == '1.9'
|
jruby? and RbConfig::CONFIG['ruby_version'] == '1.9'
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
|
||||||
# @return [Boolean]
|
|
||||||
# Returns true when Pry is being run from Rubinius.
|
|
||||||
#
|
|
||||||
def rbx?
|
|
||||||
RbConfig::CONFIG['ruby_install_name'] == 'rbx'
|
|
||||||
end
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true when Pry is being run from MRI (CRuby).
|
# Returns true when Pry is being run from MRI (CRuby).
|
||||||
|
@ -96,6 +88,6 @@ module Pry::Platform
|
||||||
# Returns an Array of Ruby engines that Pry is known to run on.
|
# Returns an Array of Ruby engines that Pry is known to run on.
|
||||||
#
|
#
|
||||||
def known_engines
|
def known_engines
|
||||||
[:jruby, :rbx, :mri]
|
[:jruby, :mri]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -93,9 +93,7 @@ class Pry
|
||||||
|
|
||||||
# Expand a file to its canonical name (following symlinks as appropriate)
|
# Expand a file to its canonical name (following symlinks as appropriate)
|
||||||
def self.real_path_to(file)
|
def self.real_path_to(file)
|
||||||
expanded = Pathname.new(File.expand_path(file)).realpath.to_s
|
Pathname.new(File.expand_path(file)).realpath.to_s
|
||||||
# For rbx 1.9 mode [see rubinius issue #2165]
|
|
||||||
File.exist?(expanded) ? expanded : nil
|
|
||||||
rescue Errno::ENOENT, Errno::EACCES
|
rescue Errno::ENOENT, Errno::EACCES
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
class Pry
|
|
||||||
module RbxPath
|
|
||||||
module_function
|
|
||||||
def is_core_path?(path)
|
|
||||||
Pry::Helpers::BaseHelpers.rbx? && (path.start_with?("kernel") || path.start_with?("lib")) && File.exist?(convert_path_to_full(path))
|
|
||||||
end
|
|
||||||
|
|
||||||
def convert_path_to_full(path)
|
|
||||||
if path.start_with?("kernel")
|
|
||||||
File.join File.dirname(Rubinius::KERNEL_PATH), path
|
|
||||||
elsif path.start_with?("lib")
|
|
||||||
File.join File.dirname(Rubinius::LIB_PATH), path
|
|
||||||
else
|
|
||||||
path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def rvm_ruby?(path)
|
|
||||||
!!(path =~ /\.rvm/)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -109,10 +109,6 @@ class Pry
|
||||||
def singleton_class?
|
def singleton_class?
|
||||||
if Pry::Method.safe_send(wrapped, :respond_to?, :singleton_class?)
|
if Pry::Method.safe_send(wrapped, :respond_to?, :singleton_class?)
|
||||||
Pry::Method.safe_send(wrapped, :singleton_class?)
|
Pry::Method.safe_send(wrapped, :singleton_class?)
|
||||||
elsif defined?(Rubinius)
|
|
||||||
# https://github.com/rubinius/rubinius/commit/2e71722dba53d1a92c54d5e3968d64d1042486fe singleton_class? added 30 Jul 2014
|
|
||||||
# https://github.com/rubinius/rubinius/commit/4310f6b2ef3c8fc88135affe697db4e29e4621c4 has been around since 2011
|
|
||||||
!!Rubinius::Type.singleton_class_object(wrapped)
|
|
||||||
else
|
else
|
||||||
wrapped != Pry::Method.safe_send(wrapped, :ancestors).first
|
wrapped != Pry::Method.safe_send(wrapped, :ancestors).first
|
||||||
end
|
end
|
||||||
|
@ -323,11 +319,11 @@ class Pry
|
||||||
|
|
||||||
# We only want methods that have a non-nil `source_location`. We also
|
# We only want methods that have a non-nil `source_location`. We also
|
||||||
# skip some spooky internal methods.
|
# skip some spooky internal methods.
|
||||||
# (i.e we skip `__class_init__` because it's an odd rbx specific thing that causes tests to fail.)
|
#
|
||||||
# @return [Array<Pry::Method>]
|
# @return [Array<Pry::Method>]
|
||||||
def all_relevant_methods_for(mod)
|
def all_relevant_methods_for(mod)
|
||||||
methods = all_methods_for(mod).select(&:source_location).
|
methods = all_methods_for(mod).select(&:source_location).
|
||||||
reject{ |x| x.name == '__class_init__' || method_defined_by_forwardable_module?(x) }
|
reject { |x| method_defined_by_forwardable_module?(x) }
|
||||||
|
|
||||||
return methods unless methods.empty?
|
return methods unless methods.empty?
|
||||||
|
|
||||||
|
|
|
@ -65,8 +65,6 @@ describe "cat" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# this doesnt work so well on rbx due to differences in backtrace
|
|
||||||
# so we currently skip rbx until we figure out a workaround
|
|
||||||
describe "with --ex" do
|
describe "with --ex" do
|
||||||
before do
|
before do
|
||||||
@o = Object.new
|
@o = Object.new
|
||||||
|
@ -77,26 +75,24 @@ describe "cat" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if !Pry::Helpers::BaseHelpers.rbx?
|
it 'cat --ex should display repl code that generated exception' do
|
||||||
it 'cat --ex should display repl code that generated exception' do
|
@t.eval unindent(<<-EOS)
|
||||||
@t.eval unindent(<<-EOS)
|
|
||||||
begin
|
|
||||||
this raises error
|
|
||||||
rescue => e
|
|
||||||
_pry_.last_exception = e
|
|
||||||
end
|
|
||||||
EOS
|
|
||||||
expect(@t.eval('cat --ex')).to match(/\d+:(\s*) this raises error/)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'cat --ex should correctly display code that generated exception' do
|
|
||||||
begin
|
begin
|
||||||
@o.broken_method
|
this raises error
|
||||||
rescue => e
|
rescue => e
|
||||||
@t.last_exception = e
|
_pry_.last_exception = e
|
||||||
end
|
end
|
||||||
expect(@t.eval('cat --ex')).to match(/this method is broken/)
|
EOS
|
||||||
|
expect(@t.eval('cat --ex')).to match(/\d+:(\s*) this raises error/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'cat --ex should correctly display code that generated exception' do
|
||||||
|
begin
|
||||||
|
@o.broken_method
|
||||||
|
rescue => e
|
||||||
|
@t.last_exception = e
|
||||||
end
|
end
|
||||||
|
expect(@t.eval('cat --ex')).to match(/this method is broken/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -77,10 +77,6 @@ describe "edit" do
|
||||||
Pry.config.editor = lambda { |file, line|
|
Pry.config.editor = lambda { |file, line|
|
||||||
File.open(file, 'w'){ |f| f << 'require_relative "baz.rb"' }
|
File.open(file, 'w'){ |f| f << 'require_relative "baz.rb"' }
|
||||||
File.open(file.gsub('bar.rb', 'baz.rb'), 'w'){ |f| f << "Pad.required = true; FileUtils.rm(__FILE__)" }
|
File.open(file.gsub('bar.rb', 'baz.rb'), 'w'){ |f| f << "Pad.required = true; FileUtils.rm(__FILE__)" }
|
||||||
|
|
||||||
if defined?(Rubinius::Compiler)
|
|
||||||
File.unlink Rubinius::Compiler.compiled_name file
|
|
||||||
end
|
|
||||||
nil
|
nil
|
||||||
}
|
}
|
||||||
pry_eval "edit #@tf_path"
|
pry_eval "edit #@tf_path"
|
||||||
|
@ -186,15 +182,12 @@ describe "edit" do
|
||||||
|
|
||||||
after do
|
after do
|
||||||
@tf.close(true)
|
@tf.close(true)
|
||||||
File.unlink("#{@path}c") if File.exist?("#{@path}c") #rbx
|
File.unlink("#{@path}c") if File.exist?("#{@path}c")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should reload the file" do
|
it "should reload the file" do
|
||||||
Pry.config.editor = lambda {|file, line|
|
Pry.config.editor = lambda {|file, line|
|
||||||
File.open(file, 'w'){|f| f << "FOO = 'BAR'" }
|
File.open(file, 'w'){|f| f << "FOO = 'BAR'" }
|
||||||
if defined?(Rubinius::Compiler)
|
|
||||||
File.unlink Rubinius::Compiler.compiled_name file
|
|
||||||
end
|
|
||||||
nil
|
nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,7 +366,7 @@ describe "edit" do
|
||||||
it "should write the evaluated command to history" do
|
it "should write the evaluated command to history" do
|
||||||
quote = 'history repeats itself, first as tradegy...'
|
quote = 'history repeats itself, first as tradegy...'
|
||||||
Pry.config.editor = lambda {|file, line|
|
Pry.config.editor = lambda {|file, line|
|
||||||
File.open(file, 'w') { |f|
|
File.open(file, 'w') { |f|
|
||||||
f << quote
|
f << quote
|
||||||
}
|
}
|
||||||
nil
|
nil
|
||||||
|
|
|
@ -116,13 +116,9 @@ describe "ls" do
|
||||||
expect { pry_eval("ls -M String.new") }.to raise_error(Pry::CommandError, /-M only makes sense with a Module or a Class/)
|
expect { pry_eval("ls -M String.new") }.to raise_error(Pry::CommandError, /-M only makes sense with a Module or a Class/)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should handle classes that (pathologically) define .ancestors" do
|
||||||
# see: https://travis-ci.org/pry/pry/jobs/5071918
|
output = pry_eval("ls Class.new{ def self.ancestors; end; def hihi; end }")
|
||||||
unless Pry::Helpers::BaseHelpers.rbx?
|
expect(output).to match(/hihi/)
|
||||||
it "should handle classes that (pathologically) define .ancestors" do
|
|
||||||
output = pry_eval("ls Class.new{ def self.ancestors; end; def hihi; end }")
|
|
||||||
expect(output).to match(/hihi/)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -211,12 +207,9 @@ describe "ls" do
|
||||||
|
|
||||||
describe "when no arguments given" do
|
describe "when no arguments given" do
|
||||||
describe "when at the top-level" do
|
describe "when at the top-level" do
|
||||||
# rubinius has a bug that means local_variables of "main" aren't reported inside eval()
|
it "should show local variables" do
|
||||||
unless Pry::Helpers::BaseHelpers.rbx?
|
expect(pry_eval("ls")).to match(/_pry_/)
|
||||||
it "should show local variables" do
|
expect(pry_eval("arbitrar = 1", "ls")).to match(/arbitrar/)
|
||||||
expect(pry_eval("ls")).to match(/_pry_/)
|
|
||||||
expect(pry_eval("arbitrar = 1", "ls")).to match(/arbitrar/)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ describe "save-file" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "saving commands" do
|
describe "saving commands" do
|
||||||
it 'should save a command to a file', expect_failure: [:rbx] do
|
it 'should save a command to a file' do
|
||||||
@t.eval "save-file --to '#{@path}' show-source"
|
@t.eval "save-file --to '#{@path}' show-source"
|
||||||
cmd_source = Pry.config.commands["show-source"].source
|
cmd_source = Pry.config.commands["show-source"].source
|
||||||
expect(File.read(@path)).to eq(cmd_source)
|
expect(File.read(@path)).to eq(cmd_source)
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe Pry::Command::ShellCommand do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "saves the current working directory" do
|
it "saves the current working directory" do
|
||||||
expect(Dir).to receive(:pwd).at_least(:once).and_return("initial_path") # called once in MRI, 2x in RBX
|
expect(Dir).to receive(:pwd).and_return("initial_path")
|
||||||
|
|
||||||
@t.eval ".cd new_path"
|
@t.eval ".cd new_path"
|
||||||
expect(@t.command_state.old_pwd).to eq("initial_path")
|
expect(@t.command_state.old_pwd).to eq("initial_path")
|
||||||
|
@ -47,7 +47,7 @@ describe Pry::Command::ShellCommand do
|
||||||
|
|
||||||
describe "given a prior directory" do
|
describe "given a prior directory" do
|
||||||
it "sends the user's last pry working directory to File.expand_path" do
|
it "sends the user's last pry working directory to File.expand_path" do
|
||||||
expect(Dir).to receive(:pwd).at_least(:twice).and_return("initial_path") # called 2x in MRI, 3x in RBX
|
expect(Dir).to receive(:pwd).twice.and_return("initial_path")
|
||||||
|
|
||||||
expect(Dir).to receive(:chdir).with(File.expand_path("new_path"))
|
expect(Dir).to receive(:chdir).with(File.expand_path("new_path"))
|
||||||
@t.eval ".cd new_path"
|
@t.eval ".cd new_path"
|
||||||
|
|
|
@ -467,110 +467,108 @@ describe "show-doc" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
unless Pry::Helpers::BaseHelpers.rbx?
|
describe "can't find class docs" do
|
||||||
describe "can't find class docs" do
|
describe "for classes" do
|
||||||
describe "for classes" do
|
before do
|
||||||
before do
|
module Jesus
|
||||||
module Jesus
|
class Brian; end
|
||||||
class Brian; end
|
|
||||||
|
|
||||||
# doink-doc
|
# doink-doc
|
||||||
class Jingle
|
class Jingle
|
||||||
def a; :doink; end
|
def a; :doink; end
|
||||||
end
|
|
||||||
|
|
||||||
class Jangle < Jingle; end
|
|
||||||
class Bangle < Jangle; end
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
class Jangle < Jingle; end
|
||||||
Object.remove_const(:Jesus)
|
class Bangle < Jangle; end
|
||||||
end
|
|
||||||
|
|
||||||
it 'shows superclass doc' do
|
|
||||||
t = pry_tester
|
|
||||||
t.process_command "show-doc Jesus::Jangle"
|
|
||||||
expect(t.last_output).to match(/doink-doc/)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'errors when class has no superclass to show' do
|
|
||||||
t = pry_tester
|
|
||||||
expect { t.process_command "show-doc Jesus::Brian" }.to raise_error(Pry::CommandError, /Couldn't locate/)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'shows warning when reverting to superclass docs' do
|
|
||||||
t = pry_tester
|
|
||||||
t.process_command "show-doc Jesus::Jangle"
|
|
||||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Jangle.*Showing.*Jesus::Jingle instead/)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'shows nth level superclass docs (when no intermediary superclasses have code either)' do
|
|
||||||
t = pry_tester
|
|
||||||
t.process_command "show-doc Jesus::Bangle"
|
|
||||||
expect(t.last_output).to match(/doink-doc/)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'shows correct warning when reverting to nth level superclass' do
|
|
||||||
t = pry_tester
|
|
||||||
t.process_command "show-doc Jesus::Bangle"
|
|
||||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Bangle.*Showing.*Jesus::Jingle instead/)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "for modules" do
|
after do
|
||||||
before do
|
Object.remove_const(:Jesus)
|
||||||
module Jesus
|
end
|
||||||
|
|
||||||
# alpha-doc
|
it 'shows superclass doc' do
|
||||||
module Alpha
|
t = pry_tester
|
||||||
def alpha; :alpha; end
|
t.process_command "show-doc Jesus::Jangle"
|
||||||
end
|
expect(t.last_output).to match(/doink-doc/)
|
||||||
|
end
|
||||||
|
|
||||||
module Zeta; end
|
it 'errors when class has no superclass to show' do
|
||||||
|
t = pry_tester
|
||||||
|
expect { t.process_command "show-doc Jesus::Brian" }.to raise_error(Pry::CommandError, /Couldn't locate/)
|
||||||
|
end
|
||||||
|
|
||||||
module Beta
|
it 'shows warning when reverting to superclass docs' do
|
||||||
include Alpha
|
t = pry_tester
|
||||||
end
|
t.process_command "show-doc Jesus::Jangle"
|
||||||
|
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Jangle.*Showing.*Jesus::Jingle instead/)
|
||||||
|
end
|
||||||
|
|
||||||
module Gamma
|
it 'shows nth level superclass docs (when no intermediary superclasses have code either)' do
|
||||||
include Beta
|
t = pry_tester
|
||||||
end
|
t.process_command "show-doc Jesus::Bangle"
|
||||||
|
expect(t.last_output).to match(/doink-doc/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'shows correct warning when reverting to nth level superclass' do
|
||||||
|
t = pry_tester
|
||||||
|
t.process_command "show-doc Jesus::Bangle"
|
||||||
|
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Bangle.*Showing.*Jesus::Jingle instead/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "for modules" do
|
||||||
|
before do
|
||||||
|
module Jesus
|
||||||
|
|
||||||
|
# alpha-doc
|
||||||
|
module Alpha
|
||||||
|
def alpha; :alpha; end
|
||||||
|
end
|
||||||
|
|
||||||
|
module Zeta; end
|
||||||
|
|
||||||
|
module Beta
|
||||||
|
include Alpha
|
||||||
|
end
|
||||||
|
|
||||||
|
module Gamma
|
||||||
|
include Beta
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
Object.remove_const(:Jesus)
|
Object.remove_const(:Jesus)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows included module doc' do
|
it 'shows included module doc' do
|
||||||
t = pry_tester
|
t = pry_tester
|
||||||
t.process_command "show-doc Jesus::Beta"
|
t.process_command "show-doc Jesus::Beta"
|
||||||
expect(t.last_output).to match(/alpha-doc/)
|
expect(t.last_output).to match(/alpha-doc/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows warning when reverting to included module doc' do
|
it 'shows warning when reverting to included module doc' do
|
||||||
t = pry_tester
|
t = pry_tester
|
||||||
t.process_command "show-doc Jesus::Beta"
|
t.process_command "show-doc Jesus::Beta"
|
||||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Beta.*Showing.*Jesus::Alpha instead/)
|
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Beta.*Showing.*Jesus::Alpha instead/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'errors when module has no included module to show' do
|
it 'errors when module has no included module to show' do
|
||||||
t = pry_tester
|
t = pry_tester
|
||||||
expect { t.process_command "show-source Jesus::Zeta" }.to raise_error(Pry::CommandError, /Couldn't locate/)
|
expect { t.process_command "show-source Jesus::Zeta" }.to raise_error(Pry::CommandError, /Couldn't locate/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows nth level included module doc (when no intermediary modules have code either)' do
|
it 'shows nth level included module doc (when no intermediary modules have code either)' do
|
||||||
t = pry_tester
|
t = pry_tester
|
||||||
t.process_command "show-doc Jesus::Gamma"
|
t.process_command "show-doc Jesus::Gamma"
|
||||||
expect(t.last_output).to match(/alpha-doc/)
|
expect(t.last_output).to match(/alpha-doc/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows correct warning when reverting to nth level included module' do
|
it 'shows correct warning when reverting to nth level included module' do
|
||||||
t = pry_tester
|
t = pry_tester
|
||||||
t.process_command "show-source Jesus::Gamma"
|
t.process_command "show-source Jesus::Gamma"
|
||||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Gamma.*Showing.*Jesus::Alpha instead/)
|
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Gamma.*Showing.*Jesus::Alpha instead/)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -649,13 +649,13 @@ describe "show-source" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when current context is a C object" do
|
describe "when current context is a C object" do
|
||||||
it "should display a warning, and not monkey-patched definition", expect_failure: [:rbx] do
|
it "should display a warning, and not monkey-patched definition" do
|
||||||
out = pry_eval([1, 2, 3], 'show-source')
|
out = pry_eval([1, 2, 3], 'show-source')
|
||||||
expect(out).not_to match(/doge/)
|
expect(out).not_to match(/doge/)
|
||||||
expect(out).to match(/warning/i)
|
expect(out).to match(/warning/i)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "recommends to use the --all switch when other candidates are found", expect_failure: [:rbx] do
|
it "recommends to use the --all switch when other candidates are found" do
|
||||||
out = pry_eval([], 'show-source')
|
out = pry_eval([], 'show-source')
|
||||||
expect(out).to match(/'--all' switch/i)
|
expect(out).to match(/'--all' switch/i)
|
||||||
end
|
end
|
||||||
|
@ -770,116 +770,114 @@ describe "show-source" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
unless Pry::Helpers::BaseHelpers.rbx?
|
describe "can't find class/module code" do
|
||||||
describe "can't find class/module code" do
|
describe "for classes" do
|
||||||
describe "for classes" do
|
before do
|
||||||
before do
|
module Jesus
|
||||||
module Jesus
|
module Pig
|
||||||
module Pig
|
def lillybing; :lillybing; end
|
||||||
def lillybing; :lillybing; end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Brian; end
|
|
||||||
class Jingle
|
|
||||||
def a; :doink; end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Jangle < Jingle; include Pig; end
|
|
||||||
class Bangle < Jangle; end
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
class Brian; end
|
||||||
Object.remove_const(:Jesus)
|
class Jingle
|
||||||
end
|
def a; :doink; end
|
||||||
|
end
|
||||||
|
|
||||||
it 'shows superclass code' do
|
class Jangle < Jingle; include Pig; end
|
||||||
t = pry_tester
|
class Bangle < Jangle; end
|
||||||
t.process_command "show-source Jesus::Jangle"
|
|
||||||
expect(t.last_output).to match(/doink/)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'ignores included modules' do
|
|
||||||
t = pry_tester
|
|
||||||
t.process_command "show-source Jesus::Jangle"
|
|
||||||
expect(t.last_output).not_to match(/lillybing/)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'errors when class has no superclass to show' do
|
|
||||||
t = pry_tester
|
|
||||||
expect { t.process_command "show-source Jesus::Brian" }.to raise_error(Pry::CommandError, /Couldn't locate/)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'shows warning when reverting to superclass code' do
|
|
||||||
t = pry_tester
|
|
||||||
t.process_command "show-source Jesus::Jangle"
|
|
||||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Jangle.*Showing.*Jesus::Jingle instead/)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'shows nth level superclass code (when no intermediary superclasses have code either)' do
|
|
||||||
t = pry_tester
|
|
||||||
t.process_command "show-source Jesus::Bangle"
|
|
||||||
expect(t.last_output).to match(/doink/)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'shows correct warning when reverting to nth level superclass' do
|
|
||||||
t = pry_tester
|
|
||||||
t.process_command "show-source Jesus::Bangle"
|
|
||||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Bangle.*Showing.*Jesus::Jingle instead/)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "for modules" do
|
after do
|
||||||
before do
|
Object.remove_const(:Jesus)
|
||||||
module Jesus
|
end
|
||||||
module Alpha
|
|
||||||
def alpha; :alpha; end
|
|
||||||
end
|
|
||||||
|
|
||||||
module Zeta; end
|
it 'shows superclass code' do
|
||||||
|
t = pry_tester
|
||||||
|
t.process_command "show-source Jesus::Jangle"
|
||||||
|
expect(t.last_output).to match(/doink/)
|
||||||
|
end
|
||||||
|
|
||||||
module Beta
|
it 'ignores included modules' do
|
||||||
include Alpha
|
t = pry_tester
|
||||||
end
|
t.process_command "show-source Jesus::Jangle"
|
||||||
|
expect(t.last_output).not_to match(/lillybing/)
|
||||||
|
end
|
||||||
|
|
||||||
module Gamma
|
it 'errors when class has no superclass to show' do
|
||||||
include Beta
|
t = pry_tester
|
||||||
end
|
expect { t.process_command "show-source Jesus::Brian" }.to raise_error(Pry::CommandError, /Couldn't locate/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'shows warning when reverting to superclass code' do
|
||||||
|
t = pry_tester
|
||||||
|
t.process_command "show-source Jesus::Jangle"
|
||||||
|
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Jangle.*Showing.*Jesus::Jingle instead/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'shows nth level superclass code (when no intermediary superclasses have code either)' do
|
||||||
|
t = pry_tester
|
||||||
|
t.process_command "show-source Jesus::Bangle"
|
||||||
|
expect(t.last_output).to match(/doink/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'shows correct warning when reverting to nth level superclass' do
|
||||||
|
t = pry_tester
|
||||||
|
t.process_command "show-source Jesus::Bangle"
|
||||||
|
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Bangle.*Showing.*Jesus::Jingle instead/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "for modules" do
|
||||||
|
before do
|
||||||
|
module Jesus
|
||||||
|
module Alpha
|
||||||
|
def alpha; :alpha; end
|
||||||
|
end
|
||||||
|
|
||||||
|
module Zeta; end
|
||||||
|
|
||||||
|
module Beta
|
||||||
|
include Alpha
|
||||||
|
end
|
||||||
|
|
||||||
|
module Gamma
|
||||||
|
include Beta
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
Object.remove_const(:Jesus)
|
Object.remove_const(:Jesus)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows included module code' do
|
it 'shows included module code' do
|
||||||
t = pry_tester
|
t = pry_tester
|
||||||
t.process_command "show-source Jesus::Beta"
|
t.process_command "show-source Jesus::Beta"
|
||||||
expect(t.last_output).to match(/alpha/)
|
expect(t.last_output).to match(/alpha/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows warning when reverting to included module code' do
|
it 'shows warning when reverting to included module code' do
|
||||||
t = pry_tester
|
t = pry_tester
|
||||||
t.process_command "show-source Jesus::Beta"
|
t.process_command "show-source Jesus::Beta"
|
||||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Beta.*Showing.*Jesus::Alpha instead/)
|
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Beta.*Showing.*Jesus::Alpha instead/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'errors when module has no included module to show' do
|
it 'errors when module has no included module to show' do
|
||||||
t = pry_tester
|
t = pry_tester
|
||||||
expect { t.process_command "show-source Jesus::Zeta" }.to raise_error(Pry::CommandError, /Couldn't locate/)
|
expect { t.process_command "show-source Jesus::Zeta" }.to raise_error(Pry::CommandError, /Couldn't locate/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows nth level included module code (when no intermediary modules have code either)' do
|
it 'shows nth level included module code (when no intermediary modules have code either)' do
|
||||||
t = pry_tester
|
t = pry_tester
|
||||||
t.process_command "show-source Jesus::Gamma"
|
t.process_command "show-source Jesus::Gamma"
|
||||||
expect(t.last_output).to match(/alpha/)
|
expect(t.last_output).to match(/alpha/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows correct warning when reverting to nth level included module' do
|
it 'shows correct warning when reverting to nth level included module' do
|
||||||
t = pry_tester
|
t = pry_tester
|
||||||
t.process_command "show-source Jesus::Gamma"
|
t.process_command "show-source Jesus::Gamma"
|
||||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Gamma.*Showing.*Jesus::Alpha instead/)
|
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Gamma.*Showing.*Jesus::Alpha instead/)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -195,18 +195,15 @@ describe "whereami" do
|
||||||
expect(out).to match(/blimey/)
|
expect(out).to match(/blimey/)
|
||||||
end
|
end
|
||||||
|
|
||||||
# https://github.com/rubinius/rubinius/pull/2247
|
it 'should show class when -c option used, and binding is outside a method' do
|
||||||
unless Pry::Helpers::BaseHelpers.rbx?
|
class Cor
|
||||||
it 'should show class when -c option used, and binding is outside a method' do
|
def blimey;end
|
||||||
class Cor
|
|
||||||
def blimey;end
|
|
||||||
|
|
||||||
out = pry_eval(binding, 'whereami -c')
|
out = pry_eval(binding, 'whereami -c')
|
||||||
out.should =~ /class Cor/
|
out.should =~ /class Cor/
|
||||||
out.should =~ /blimey/
|
out.should =~ /blimey/
|
||||||
end
|
|
||||||
Object.remove_const(:Cor)
|
|
||||||
end
|
end
|
||||||
|
Object.remove_const(:Cor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ end.new(nil)
|
||||||
|
|
||||||
# to help with tracking down bugs that cause an infinite loop in the test suite
|
# to help with tracking down bugs that cause an infinite loop in the test suite
|
||||||
if ENV["SET_TRACE_FUNC"]
|
if ENV["SET_TRACE_FUNC"]
|
||||||
require 'set_trace' if Pry::Helpers::BaseHelpers.rbx?
|
|
||||||
set_trace_func proc { |event, file, line, id, binding, classname|
|
set_trace_func proc { |event, file, line, id, binding, classname|
|
||||||
STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
|
STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,19 +118,16 @@ describe Pry::Method do
|
||||||
expect(m.name).to eq "bar"
|
expect(m.name).to eq "bar"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Our source_location trick doesn't work, due to https://github.com/rubinius/rubinius/issues/953
|
it 'should find the super method correctly' do
|
||||||
unless Pry::Helpers::BaseHelpers.rbx?
|
a = Class.new{ def gag33; binding; end; def self.line; __LINE__; end }
|
||||||
it 'should find the super method correctly' do
|
b = Class.new(a){ def gag33; super; end }
|
||||||
a = Class.new{ def gag33; binding; end; def self.line; __LINE__; end }
|
|
||||||
b = Class.new(a){ def gag33; super; end }
|
|
||||||
|
|
||||||
g = b.new.gag33
|
g = b.new.gag33
|
||||||
m = Pry::Method.from_binding(g)
|
m = Pry::Method.from_binding(g)
|
||||||
|
|
||||||
expect(m.owner).to eq a
|
expect(m.owner).to eq a
|
||||||
expect(m.source_line).to eq a.line
|
expect(m.source_line).to eq a.line
|
||||||
expect(m.name).to eq "gag33"
|
expect(m.name).to eq "gag33"
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should find the right method if a super method exists' do
|
it 'should find the right method if a super method exists' do
|
||||||
|
@ -144,16 +141,13 @@ describe Pry::Method do
|
||||||
expect(m.name).to eq "gag"
|
expect(m.name).to eq "gag"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Temporarily disabled to work around rubinius/rubinius#2871.
|
it "should find the right method from a BasicObject" do
|
||||||
unless Pry::Helpers::BaseHelpers.rbx?
|
a = Class.new(BasicObject) { def gag; ::Kernel.binding; end; def self.line; __LINE__; end }
|
||||||
it "should find the right method from a BasicObject" do
|
|
||||||
a = Class.new(BasicObject) { def gag; ::Kernel.binding; end; def self.line; __LINE__; end }
|
|
||||||
|
|
||||||
m = Pry::Method.from_binding(a.new.gag)
|
m = Pry::Method.from_binding(a.new.gag)
|
||||||
expect(m.owner).to eq a
|
expect(m.owner).to eq a
|
||||||
expect(m.source_file).to eq __FILE__
|
expect(m.source_file).to eq __FILE__
|
||||||
expect(m.source_line).to eq a.line
|
expect(m.source_line).to eq a.line
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should find the right method even if it was renamed and replaced' do
|
it 'should find the right method even if it was renamed and replaced' do
|
||||||
|
|
|
@ -369,13 +369,10 @@ describe "test Pry defaults" do
|
||||||
expect(Pry.toplevel_binding.eval('self')).to equal(TOPLEVEL_BINDING.eval('self'))
|
expect(Pry.toplevel_binding.eval('self')).to equal(TOPLEVEL_BINDING.eval('self'))
|
||||||
end
|
end
|
||||||
|
|
||||||
# https://github.com/rubinius/rubinius/issues/1779
|
it 'should define private methods on Object' do
|
||||||
unless Pry::Helpers::BaseHelpers.rbx?
|
TOPLEVEL_BINDING.eval 'def gooey_fooey; end'
|
||||||
it 'should define private methods on Object' do
|
expect(method(:gooey_fooey).owner).to eq Object
|
||||||
TOPLEVEL_BINDING.eval 'def gooey_fooey; end'
|
expect(Pry::Method(method(:gooey_fooey)).visibility).to eq :private
|
||||||
expect(method(:gooey_fooey).owner).to eq Object
|
|
||||||
expect(Pry::Method(method(:gooey_fooey)).visibility).to eq :private
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ describe Pry do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not load the pryrc if pryrc's directory permissions do not allow this", expect_failure: [:rbx] do
|
it "should not load the pryrc if pryrc's directory permissions do not allow this" do
|
||||||
Dir.mktmpdir do |dir|
|
Dir.mktmpdir do |dir|
|
||||||
File.chmod 0000, dir
|
File.chmod 0000, dir
|
||||||
Pry::LOCAL_RC_FILE.replace File.join(dir, '.pryrc')
|
Pry::LOCAL_RC_FILE.replace File.join(dir, '.pryrc')
|
||||||
|
|
|
@ -28,10 +28,10 @@ describe Pry do
|
||||||
["puts )("],
|
["puts )("],
|
||||||
["1 1"],
|
["1 1"],
|
||||||
["puts :"]
|
["puts :"]
|
||||||
] + (Pry::Helpers::BaseHelpers.rbx? ? [] : [
|
] + [
|
||||||
["def", "method(1"], # in this case the syntax error is "expecting ')'".
|
["def", "method(1"], # in this case the syntax error is "expecting ')'".
|
||||||
["o = Object.new.tap{ def o.render;","'MEH'", "}"] # in this case the syntax error is "expecting keyword_end".
|
["o = Object.new.tap{ def o.render;","'MEH'", "}"] # in this case the syntax error is "expecting keyword_end".
|
||||||
])).compact.each do |foo|
|
]).compact.each do |foo|
|
||||||
it "should raise an error on invalid syntax like #{foo.inspect}" do
|
it "should raise an error on invalid syntax like #{foo.inspect}" do
|
||||||
redirect_pry_io(InputTester.new(*foo), @str_output) do
|
redirect_pry_io(InputTester.new(*foo), @str_output) do
|
||||||
Pry.start
|
Pry.start
|
||||||
|
|
Loading…
Reference in a new issue