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
|
||||
vendor
|
||||
*.gem
|
||||
.rbx/
|
||||
.rvmrc
|
||||
Gemfile.lock
|
||||
*.swp
|
||||
|
|
|
@ -206,7 +206,6 @@ Layout/EmptyLinesAroundAccessModifier:
|
|||
- 'lib/pry/helpers/table.rb'
|
||||
- 'lib/pry/history_array.rb'
|
||||
- 'lib/pry/plugins.rb'
|
||||
- 'lib/pry/rbx_path.rb'
|
||||
- 'spec/method_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
|
@ -828,7 +827,6 @@ Naming/MethodName:
|
|||
Naming/PredicateName:
|
||||
Exclude:
|
||||
- 'spec/**/*'
|
||||
- 'lib/pry/rbx_path.rb'
|
||||
|
||||
# Offense count: 26
|
||||
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
||||
|
@ -842,13 +840,6 @@ Performance/Casecmp:
|
|||
Exclude:
|
||||
- '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
|
||||
# Cop supports --auto-correct.
|
||||
Performance/InefficientHashSearch:
|
||||
|
@ -1050,7 +1041,6 @@ Style/DoubleNegation:
|
|||
- 'lib/pry/method/weird_method_locator.rb'
|
||||
- 'lib/pry/pager.rb'
|
||||
- 'lib/pry/platform.rb'
|
||||
- 'lib/pry/rbx_path.rb'
|
||||
- 'lib/pry/slop/option.rb'
|
||||
- 'lib/pry/wrapped_module.rb'
|
||||
|
||||
|
|
6
Gemfile
6
Gemfile
|
@ -22,9 +22,3 @@ end
|
|||
group :development, :test do
|
||||
gem 'simplecov', '~> 0.8.0'
|
||||
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/repl'
|
||||
require 'pry/rbx_path'
|
||||
require 'pry/code'
|
||||
require 'pry/history_array'
|
||||
require 'pry/helpers'
|
||||
|
|
|
@ -41,8 +41,6 @@ class Pry
|
|||
Pry.line_buffer.drop(1)
|
||||
elsif 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
|
||||
path = abs_path
|
||||
@code_type = type_from_filename(path)
|
||||
|
|
|
@ -317,7 +317,7 @@ class Pry
|
|||
# `nil` if the filename is unavailable.
|
||||
def source_file
|
||||
if source_location.nil?
|
||||
if !rbx? and source_type == :c
|
||||
if source_type == :c
|
||||
info = pry_doc_info
|
||||
info.file if info
|
||||
end
|
||||
|
@ -531,9 +531,9 @@ class Pry
|
|||
end
|
||||
|
||||
def ruby_source
|
||||
# clone of MethodSource.source_helper that knows to use our
|
||||
# hacked version of source_location for rbx core methods, and
|
||||
# our input buffer for methods defined in (pry)
|
||||
# Clone of `MethodSource.source_helper` that knows to use our
|
||||
# hacked version of `source_location` for our input buffer for methods
|
||||
# defined in `(pry)`.
|
||||
file, line = *source_location
|
||||
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.
|
||||
#
|
||||
# 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__')
|
||||
# is broken.
|
||||
# methods have the same __FILE__ and __LINE__.
|
||||
#
|
||||
# @return [Pry::Method, nil] The Pry::Method representing the
|
||||
# superclass method.
|
||||
|
@ -122,9 +121,9 @@ class Pry
|
|||
end
|
||||
end
|
||||
|
||||
# Uhoh... none of the methods in the chain had the right __FILE__ and __LINE__
|
||||
# This may be caused by rbx https://github.com/rubinius/rubinius/issues/953,
|
||||
# or other unknown circumstances (TODO: we should warn the user when this happens)
|
||||
# Uhoh... none of the methods in the chain had the right `__FILE__` and
|
||||
# `__LINE__` due to unknown circumstances.
|
||||
# TODO: we should warn the user when this happens.
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -59,14 +59,6 @@ module Pry::Platform
|
|||
jruby? and RbConfig::CONFIG['ruby_version'] == '1.9'
|
||||
end
|
||||
|
||||
#
|
||||
# @return [Boolean]
|
||||
# Returns true when Pry is being run from Rubinius.
|
||||
#
|
||||
def rbx?
|
||||
RbConfig::CONFIG['ruby_install_name'] == 'rbx'
|
||||
end
|
||||
|
||||
#
|
||||
# @return [Boolean]
|
||||
# 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.
|
||||
#
|
||||
def known_engines
|
||||
[:jruby, :rbx, :mri]
|
||||
[:jruby, :mri]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -93,9 +93,7 @@ class Pry
|
|||
|
||||
# Expand a file to its canonical name (following symlinks as appropriate)
|
||||
def self.real_path_to(file)
|
||||
expanded = Pathname.new(File.expand_path(file)).realpath.to_s
|
||||
# For rbx 1.9 mode [see rubinius issue #2165]
|
||||
File.exist?(expanded) ? expanded : nil
|
||||
Pathname.new(File.expand_path(file)).realpath.to_s
|
||||
rescue Errno::ENOENT, Errno::EACCES
|
||||
nil
|
||||
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?
|
||||
if Pry::Method.safe_send(wrapped, :respond_to?, :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
|
||||
wrapped != Pry::Method.safe_send(wrapped, :ancestors).first
|
||||
end
|
||||
|
@ -323,11 +319,11 @@ class Pry
|
|||
|
||||
# We only want methods that have a non-nil `source_location`. We also
|
||||
# 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>]
|
||||
def all_relevant_methods_for(mod)
|
||||
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?
|
||||
|
||||
|
|
|
@ -65,8 +65,6 @@ describe "cat" do
|
|||
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
|
||||
before do
|
||||
@o = Object.new
|
||||
|
@ -77,26 +75,24 @@ describe "cat" do
|
|||
end
|
||||
end
|
||||
|
||||
if !Pry::Helpers::BaseHelpers.rbx?
|
||||
it 'cat --ex should display repl code that generated exception' do
|
||||
@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
|
||||
it 'cat --ex should display repl code that generated exception' do
|
||||
@t.eval unindent(<<-EOS)
|
||||
begin
|
||||
@o.broken_method
|
||||
this raises error
|
||||
rescue => e
|
||||
@t.last_exception = e
|
||||
_pry_.last_exception = e
|
||||
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
|
||||
expect(@t.eval('cat --ex')).to match(/this method is broken/)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -77,10 +77,6 @@ describe "edit" do
|
|||
Pry.config.editor = lambda { |file, line|
|
||||
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__)" }
|
||||
|
||||
if defined?(Rubinius::Compiler)
|
||||
File.unlink Rubinius::Compiler.compiled_name file
|
||||
end
|
||||
nil
|
||||
}
|
||||
pry_eval "edit #@tf_path"
|
||||
|
@ -186,15 +182,12 @@ describe "edit" do
|
|||
|
||||
after do
|
||||
@tf.close(true)
|
||||
File.unlink("#{@path}c") if File.exist?("#{@path}c") #rbx
|
||||
File.unlink("#{@path}c") if File.exist?("#{@path}c")
|
||||
end
|
||||
|
||||
it "should reload the file" do
|
||||
Pry.config.editor = lambda {|file, line|
|
||||
File.open(file, 'w'){|f| f << "FOO = 'BAR'" }
|
||||
if defined?(Rubinius::Compiler)
|
||||
File.unlink Rubinius::Compiler.compiled_name file
|
||||
end
|
||||
nil
|
||||
}
|
||||
|
||||
|
@ -373,7 +366,7 @@ describe "edit" do
|
|||
it "should write the evaluated command to history" do
|
||||
quote = 'history repeats itself, first as tradegy...'
|
||||
Pry.config.editor = lambda {|file, line|
|
||||
File.open(file, 'w') { |f|
|
||||
File.open(file, 'w') { |f|
|
||||
f << quote
|
||||
}
|
||||
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/)
|
||||
end
|
||||
|
||||
|
||||
# see: https://travis-ci.org/pry/pry/jobs/5071918
|
||||
unless Pry::Helpers::BaseHelpers.rbx?
|
||||
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
|
||||
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
|
||||
|
||||
|
@ -211,12 +207,9 @@ describe "ls" do
|
|||
|
||||
describe "when no arguments given" do
|
||||
describe "when at the top-level" do
|
||||
# rubinius has a bug that means local_variables of "main" aren't reported inside eval()
|
||||
unless Pry::Helpers::BaseHelpers.rbx?
|
||||
it "should show local variables" do
|
||||
expect(pry_eval("ls")).to match(/_pry_/)
|
||||
expect(pry_eval("arbitrar = 1", "ls")).to match(/arbitrar/)
|
||||
end
|
||||
it "should show local variables" do
|
||||
expect(pry_eval("ls")).to match(/_pry_/)
|
||||
expect(pry_eval("arbitrar = 1", "ls")).to match(/arbitrar/)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ describe "save-file" do
|
|||
end
|
||||
|
||||
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"
|
||||
cmd_source = Pry.config.commands["show-source"].source
|
||||
expect(File.read(@path)).to eq(cmd_source)
|
||||
|
|
|
@ -18,7 +18,7 @@ describe Pry::Command::ShellCommand do
|
|||
end
|
||||
|
||||
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"
|
||||
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
|
||||
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"))
|
||||
@t.eval ".cd new_path"
|
||||
|
|
|
@ -467,110 +467,108 @@ describe "show-doc" do
|
|||
end
|
||||
end
|
||||
|
||||
unless Pry::Helpers::BaseHelpers.rbx?
|
||||
describe "can't find class docs" do
|
||||
describe "for classes" do
|
||||
before do
|
||||
module Jesus
|
||||
class Brian; end
|
||||
describe "can't find class docs" do
|
||||
describe "for classes" do
|
||||
before do
|
||||
module Jesus
|
||||
class Brian; end
|
||||
|
||||
# doink-doc
|
||||
class Jingle
|
||||
def a; :doink; end
|
||||
end
|
||||
|
||||
class Jangle < Jingle; end
|
||||
class Bangle < Jangle; end
|
||||
# doink-doc
|
||||
class Jingle
|
||||
def a; :doink; end
|
||||
end
|
||||
end
|
||||
|
||||
after do
|
||||
Object.remove_const(:Jesus)
|
||||
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/)
|
||||
class Jangle < Jingle; end
|
||||
class Bangle < Jangle; end
|
||||
end
|
||||
end
|
||||
|
||||
describe "for modules" do
|
||||
before do
|
||||
module Jesus
|
||||
after do
|
||||
Object.remove_const(:Jesus)
|
||||
end
|
||||
|
||||
# alpha-doc
|
||||
module Alpha
|
||||
def alpha; :alpha; 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
|
||||
|
||||
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
|
||||
include Alpha
|
||||
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
|
||||
|
||||
module Gamma
|
||||
include Beta
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
after do
|
||||
Object.remove_const(:Jesus)
|
||||
end
|
||||
after do
|
||||
Object.remove_const(:Jesus)
|
||||
end
|
||||
|
||||
it 'shows included module doc' do
|
||||
t = pry_tester
|
||||
t.process_command "show-doc Jesus::Beta"
|
||||
expect(t.last_output).to match(/alpha-doc/)
|
||||
end
|
||||
it 'shows included module doc' do
|
||||
t = pry_tester
|
||||
t.process_command "show-doc Jesus::Beta"
|
||||
expect(t.last_output).to match(/alpha-doc/)
|
||||
end
|
||||
|
||||
it 'shows warning when reverting to included module doc' do
|
||||
t = pry_tester
|
||||
t.process_command "show-doc Jesus::Beta"
|
||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Beta.*Showing.*Jesus::Alpha instead/)
|
||||
end
|
||||
it 'shows warning when reverting to included module doc' do
|
||||
t = pry_tester
|
||||
t.process_command "show-doc Jesus::Beta"
|
||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Beta.*Showing.*Jesus::Alpha instead/)
|
||||
end
|
||||
|
||||
it 'errors when module has no included module to show' do
|
||||
t = pry_tester
|
||||
expect { t.process_command "show-source Jesus::Zeta" }.to raise_error(Pry::CommandError, /Couldn't locate/)
|
||||
end
|
||||
it 'errors when module has no included module to show' do
|
||||
t = pry_tester
|
||||
expect { t.process_command "show-source Jesus::Zeta" }.to raise_error(Pry::CommandError, /Couldn't locate/)
|
||||
end
|
||||
|
||||
it 'shows nth level included module doc (when no intermediary modules have code either)' do
|
||||
t = pry_tester
|
||||
t.process_command "show-doc Jesus::Gamma"
|
||||
expect(t.last_output).to match(/alpha-doc/)
|
||||
end
|
||||
it 'shows nth level included module doc (when no intermediary modules have code either)' do
|
||||
t = pry_tester
|
||||
t.process_command "show-doc Jesus::Gamma"
|
||||
expect(t.last_output).to match(/alpha-doc/)
|
||||
end
|
||||
|
||||
it 'shows correct warning when reverting to nth level included module' do
|
||||
t = pry_tester
|
||||
t.process_command "show-source Jesus::Gamma"
|
||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Gamma.*Showing.*Jesus::Alpha instead/)
|
||||
end
|
||||
it 'shows correct warning when reverting to nth level included module' do
|
||||
t = pry_tester
|
||||
t.process_command "show-source Jesus::Gamma"
|
||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Gamma.*Showing.*Jesus::Alpha instead/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -649,13 +649,13 @@ describe "show-source" do
|
|||
end
|
||||
|
||||
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')
|
||||
expect(out).not_to match(/doge/)
|
||||
expect(out).to match(/warning/i)
|
||||
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')
|
||||
expect(out).to match(/'--all' switch/i)
|
||||
end
|
||||
|
@ -770,116 +770,114 @@ describe "show-source" do
|
|||
end
|
||||
end
|
||||
|
||||
unless Pry::Helpers::BaseHelpers.rbx?
|
||||
describe "can't find class/module code" do
|
||||
describe "for classes" do
|
||||
before do
|
||||
module Jesus
|
||||
module Pig
|
||||
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
|
||||
describe "can't find class/module code" do
|
||||
describe "for classes" do
|
||||
before do
|
||||
module Jesus
|
||||
module Pig
|
||||
def lillybing; :lillybing; end
|
||||
end
|
||||
end
|
||||
|
||||
after do
|
||||
Object.remove_const(:Jesus)
|
||||
end
|
||||
class Brian; end
|
||||
class Jingle
|
||||
def a; :doink; end
|
||||
end
|
||||
|
||||
it 'shows superclass code' do
|
||||
t = pry_tester
|
||||
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/)
|
||||
class Jangle < Jingle; include Pig; end
|
||||
class Bangle < Jangle; end
|
||||
end
|
||||
end
|
||||
|
||||
describe "for modules" do
|
||||
before do
|
||||
module Jesus
|
||||
module Alpha
|
||||
def alpha; :alpha; end
|
||||
end
|
||||
after do
|
||||
Object.remove_const(:Jesus)
|
||||
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
|
||||
include Alpha
|
||||
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
|
||||
|
||||
module Gamma
|
||||
include Beta
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
after do
|
||||
Object.remove_const(:Jesus)
|
||||
end
|
||||
after do
|
||||
Object.remove_const(:Jesus)
|
||||
end
|
||||
|
||||
it 'shows included module code' do
|
||||
t = pry_tester
|
||||
t.process_command "show-source Jesus::Beta"
|
||||
expect(t.last_output).to match(/alpha/)
|
||||
end
|
||||
it 'shows included module code' do
|
||||
t = pry_tester
|
||||
t.process_command "show-source Jesus::Beta"
|
||||
expect(t.last_output).to match(/alpha/)
|
||||
end
|
||||
|
||||
it 'shows warning when reverting to included module code' do
|
||||
t = pry_tester
|
||||
t.process_command "show-source Jesus::Beta"
|
||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Beta.*Showing.*Jesus::Alpha instead/)
|
||||
end
|
||||
it 'shows warning when reverting to included module code' do
|
||||
t = pry_tester
|
||||
t.process_command "show-source Jesus::Beta"
|
||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Beta.*Showing.*Jesus::Alpha instead/)
|
||||
end
|
||||
|
||||
it 'errors when module has no included module to show' do
|
||||
t = pry_tester
|
||||
expect { t.process_command "show-source Jesus::Zeta" }.to raise_error(Pry::CommandError, /Couldn't locate/)
|
||||
end
|
||||
it 'errors when module has no included module to show' do
|
||||
t = pry_tester
|
||||
expect { t.process_command "show-source Jesus::Zeta" }.to raise_error(Pry::CommandError, /Couldn't locate/)
|
||||
end
|
||||
|
||||
it 'shows nth level included module code (when no intermediary modules have code either)' do
|
||||
t = pry_tester
|
||||
t.process_command "show-source Jesus::Gamma"
|
||||
expect(t.last_output).to match(/alpha/)
|
||||
end
|
||||
it 'shows nth level included module code (when no intermediary modules have code either)' do
|
||||
t = pry_tester
|
||||
t.process_command "show-source Jesus::Gamma"
|
||||
expect(t.last_output).to match(/alpha/)
|
||||
end
|
||||
|
||||
it 'shows correct warning when reverting to nth level included module' do
|
||||
t = pry_tester
|
||||
t.process_command "show-source Jesus::Gamma"
|
||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Gamma.*Showing.*Jesus::Alpha instead/)
|
||||
end
|
||||
it 'shows correct warning when reverting to nth level included module' do
|
||||
t = pry_tester
|
||||
t.process_command "show-source Jesus::Gamma"
|
||||
expect(t.last_output).to match(/Warning.*?Cannot find.*?Jesus::Gamma.*Showing.*Jesus::Alpha instead/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -195,18 +195,15 @@ describe "whereami" do
|
|||
expect(out).to match(/blimey/)
|
||||
end
|
||||
|
||||
# https://github.com/rubinius/rubinius/pull/2247
|
||||
unless Pry::Helpers::BaseHelpers.rbx?
|
||||
it 'should show class when -c option used, and binding is outside a method' do
|
||||
class Cor
|
||||
def blimey;end
|
||||
it 'should show class when -c option used, and binding is outside a method' do
|
||||
class Cor
|
||||
def blimey;end
|
||||
|
||||
out = pry_eval(binding, 'whereami -c')
|
||||
out.should =~ /class Cor/
|
||||
out.should =~ /blimey/
|
||||
end
|
||||
Object.remove_const(:Cor)
|
||||
out = pry_eval(binding, 'whereami -c')
|
||||
out.should =~ /class Cor/
|
||||
out.should =~ /blimey/
|
||||
end
|
||||
Object.remove_const(:Cor)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ end.new(nil)
|
|||
|
||||
# to help with tracking down bugs that cause an infinite loop in the test suite
|
||||
if ENV["SET_TRACE_FUNC"]
|
||||
require 'set_trace' if Pry::Helpers::BaseHelpers.rbx?
|
||||
set_trace_func proc { |event, file, line, id, binding, 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"
|
||||
end
|
||||
|
||||
# Our source_location trick doesn't work, due to https://github.com/rubinius/rubinius/issues/953
|
||||
unless Pry::Helpers::BaseHelpers.rbx?
|
||||
it 'should find the super method correctly' do
|
||||
a = Class.new{ def gag33; binding; end; def self.line; __LINE__; end }
|
||||
b = Class.new(a){ def gag33; super; end }
|
||||
it 'should find the super method correctly' do
|
||||
a = Class.new{ def gag33; binding; end; def self.line; __LINE__; end }
|
||||
b = Class.new(a){ def gag33; super; end }
|
||||
|
||||
g = b.new.gag33
|
||||
m = Pry::Method.from_binding(g)
|
||||
g = b.new.gag33
|
||||
m = Pry::Method.from_binding(g)
|
||||
|
||||
expect(m.owner).to eq a
|
||||
expect(m.source_line).to eq a.line
|
||||
expect(m.name).to eq "gag33"
|
||||
end
|
||||
expect(m.owner).to eq a
|
||||
expect(m.source_line).to eq a.line
|
||||
expect(m.name).to eq "gag33"
|
||||
end
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
# Temporarily disabled to work around rubinius/rubinius#2871.
|
||||
unless Pry::Helpers::BaseHelpers.rbx?
|
||||
it "should find the right method from a BasicObject" do
|
||||
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)
|
||||
expect(m.owner).to eq a
|
||||
expect(m.source_file).to eq __FILE__
|
||||
expect(m.source_line).to eq a.line
|
||||
end
|
||||
m = Pry::Method.from_binding(a.new.gag)
|
||||
expect(m.owner).to eq a
|
||||
expect(m.source_file).to eq __FILE__
|
||||
expect(m.source_line).to eq a.line
|
||||
end
|
||||
|
||||
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'))
|
||||
end
|
||||
|
||||
# https://github.com/rubinius/rubinius/issues/1779
|
||||
unless Pry::Helpers::BaseHelpers.rbx?
|
||||
it 'should define private methods on Object' do
|
||||
TOPLEVEL_BINDING.eval 'def gooey_fooey; end'
|
||||
expect(method(:gooey_fooey).owner).to eq Object
|
||||
expect(Pry::Method(method(:gooey_fooey)).visibility).to eq :private
|
||||
end
|
||||
it 'should define private methods on Object' do
|
||||
TOPLEVEL_BINDING.eval 'def gooey_fooey; end'
|
||||
expect(method(:gooey_fooey).owner).to eq Object
|
||||
expect(Pry::Method(method(:gooey_fooey)).visibility).to eq :private
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ describe Pry do
|
|||
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|
|
||||
File.chmod 0000, dir
|
||||
Pry::LOCAL_RC_FILE.replace File.join(dir, '.pryrc')
|
||||
|
|
|
@ -28,10 +28,10 @@ describe Pry do
|
|||
["puts )("],
|
||||
["1 1"],
|
||||
["puts :"]
|
||||
] + (Pry::Helpers::BaseHelpers.rbx? ? [] : [
|
||||
] + [
|
||||
["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".
|
||||
])).compact.each do |foo|
|
||||
]).compact.each do |foo|
|
||||
it "should raise an error on invalid syntax like #{foo.inspect}" do
|
||||
redirect_pry_io(InputTester.new(*foo), @str_output) do
|
||||
Pry.start
|
||||
|
|
Loading…
Reference in a new issue