1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Fix more warnings

This commit is contained in:
Matijs van Zuijlen 2015-01-23 10:30:41 +01:00
parent 2f0b5a4f6d
commit 3376e6a0db
26 changed files with 477 additions and 459 deletions

View file

@ -27,16 +27,17 @@ class Pry
end
def backtrace_level
return @backtrace_level if @backtrace_level
@backtrace_level ||=
begin
bl = if opts[:ex].nil?
ex.bt_index
else
ex.bt_index = absolute_index_number(opts[:ex], ex.backtrace.size)
end
bl = if opts[:ex].nil?
ex.bt_index
else
ex.bt_index = absolute_index_number(opts[:ex], ex.backtrace.size)
end
increment_backtrace_level
@backtrace_level = bl
increment_backtrace_level
bl
end
end
def increment_backtrace_level

View file

@ -51,21 +51,23 @@ class Pry
#
# @return [String]
def content
return @content if @content
raise CommandError, "Only one of --out, --in, --doc and CODE_OBJECT may be specified." if bad_option_combination?
@content ||=
begin
raise CommandError, "Only one of --out, --in, --doc and CODE_OBJECT may be specified." if bad_option_combination?
content = case
when opts.present?(:o)
pry_output_content
when opts.present?(:i)
pry_input_content
when opts.present?(:d)
code_object_doc
else
code_object_source_or_file
end
content = case
when opts.present?(:o)
pry_output_content
when opts.present?(:i)
pry_input_content
when opts.present?(:d)
code_object_doc
else
code_object_source_or_file
end
@content ||= restrict_to_lines(content, line_range)
restrict_to_lines(content, line_range)
end
end
# The code object
@ -141,7 +143,7 @@ class Pry
end
def file_content
if File.exists?(obj_name)
if File.exist?(obj_name)
# Set the file accessor.
self.file = obj_name
File.read(obj_name)

View file

@ -7,7 +7,7 @@ class Pry
end
def from_code_object(code_object, filename_argument)
if File.exists?(code_object.source_file.to_s)
if File.exist?(code_object.source_file.to_s)
[code_object.source_file, code_object.source_line]
else
raise CommandError, "Cannot find a file for #{filename_argument}!"

View file

@ -11,6 +11,7 @@ class Pry
super(_pry_)
@interrogatee = interrogatee
@no_user_opts = no_user_opts
@ppp_switch = nil
end
def output_self

View file

@ -31,7 +31,7 @@ class Pry
end
def reload_current_file
if !File.exists?(current_file)
if !File.exist?(current_file)
raise CommandError, "Current file: #{current_file} cannot be found on disk!"
end
@ -49,7 +49,7 @@ class Pry
def check_for_reloadability(code_object, identifier)
if !code_object || !code_object.source_file
raise CommandError, "Cannot locate #{identifier}!"
elsif !File.exists?(code_object.source_file)
elsif !File.exist?(code_object.source_file)
raise CommandError,
"Cannot reload #{identifier} as it has no associated file on disk. " \
"File found was: #{code_object.source_file}"

View file

@ -10,7 +10,7 @@ class Pry
end
def eval!
@previous_value = @value
@previous_value = value
@value = Pry::ColorPrinter.pp(target_eval(target, source), "")
end

View file

@ -159,12 +159,12 @@ class Pry
end
def class_code
return @class_code if @class_code
mod = @method ? Pry::WrappedModule(@method.owner) : target_class
idx = mod.candidates.find_index { |v| expand_path(v.source_file) == @file }
@class_code = idx && Pry::Code.from_module(mod, idx)
@class_code ||=
begin
mod = @method ? Pry::WrappedModule(@method.owner) : target_class
idx = mod.candidates.find_index { |v| expand_path(v.source_file) == @file }
idx && Pry::Code.from_module(mod, idx)
end
end
def valid_method?

View file

@ -232,12 +232,13 @@ describe "Pry::Command" do
end
def process
args.should == ['four']
opts[:f].should == 4
output.puts args.inspect
output.puts opts[:f]
end
end
mock_command(cmd, %w(--four 4 four))
result = mock_command(cmd, %w(--four 4 four))
result.output.split.should eq ['["four"]', '4']
end
it 'should allow overriding options after definition' do
@ -257,12 +258,13 @@ describe "Pry::Command" do
end
def process
opts.fetch_command(:blahblah).should == nil
opts.fetch_command(:yell).present?.should == true
output.puts opts.fetch_command(:blahblah).inspect
output.puts opts.fetch_command(:yell).present?
end
end
mock_command(cmd, ['yell'])
result = mock_command(cmd, ['yell'])
result.output.split.should eq ['nil', 'true']
end
it "should create subcommand options" do
@ -274,13 +276,14 @@ describe "Pry::Command" do
end
def process
args.should == ['papa']
opts.fetch_command(:yell).present?.should == true
opts.fetch_command(:yell).person?.should == true
output.puts args.inspect
output.puts opts.fetch_command(:yell).present?
output.puts opts.fetch_command(:yell).person?
end
end
mock_command(cmd, %w|yell --person papa|)
result = mock_command(cmd, %w|yell --person papa|)
result.output.split.should eq ['["papa"]', 'true', 'true']
end
it "should accept top-level arguments" do

View file

@ -6,21 +6,21 @@ describe "amend-line" do
end
it 'should amend the last line of input when no line number specified' do
@t.push *unindent(<<-STR).split("\n")
@t.push(*unindent(<<-STR).split("\n"))
def hello
puts :bing
STR
@t.process_command 'amend-line puts :blah'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
def hello
puts :blah
STR
end
it 'should amend the specified line of input when line number given' do
@t.push *unindent(<<-STR).split("\n")
@t.push(*unindent(<<-STR).split("\n"))
def hello
puts :bing
puts :bang
@ -28,7 +28,7 @@ describe "amend-line" do
@t.process_command 'amend-line 1 def goodbye'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
def goodbye
puts :bing
puts :bang
@ -36,7 +36,7 @@ describe "amend-line" do
end
it 'should amend the first line of input when 0 given as line number' do
@t.push *unindent(<<-STR).split("\n")
@t.push(*unindent(<<-STR).split("\n"))
def hello
puts :bing
puts :bang
@ -44,7 +44,7 @@ describe "amend-line" do
@t.process_command 'amend-line 0 def goodbye'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
def goodbye
puts :bing
puts :bang
@ -52,7 +52,7 @@ describe "amend-line" do
end
it 'should amend a specified line when negative number given' do
@t.push *unindent(<<-STR).split("\n")
@t.push(*unindent(<<-STR).split("\n"))
def hello
puts :bing
puts :bang
@ -60,7 +60,7 @@ describe "amend-line" do
@t.process_command 'amend-line -1 puts :bink'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
def hello
puts :bing
puts :bink
@ -68,7 +68,7 @@ describe "amend-line" do
@t.process_command 'amend-line -2 puts :bink'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
def hello
puts :bink
puts :bink
@ -76,7 +76,7 @@ describe "amend-line" do
end
it 'should amend a range of lines of input when negative numbers given' do
@t.push *unindent(<<-STR).split("\n")
@t.push(*unindent(<<-STR).split("\n"))
def hello
puts :bing
puts :bang
@ -85,7 +85,7 @@ describe "amend-line" do
@t.process_command 'amend-line -3..-2 puts :bink'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
def hello
puts :bink
puts :boat
@ -93,7 +93,7 @@ describe "amend-line" do
end
it 'should correctly amend the specified line with interpolated text' do
@t.push *unindent(<<-STR).split("\n")
@t.push(*unindent(<<-STR).split("\n"))
def hello
puts :bing
puts :bang
@ -101,7 +101,7 @@ describe "amend-line" do
@t.process_command 'amend-line puts "#{goodbye}"'
@t.eval_string.should == unindent(<<-'STR')
@t.eval_string.should eq unindent(<<-'STR')
def hello
puts :bing
puts "#{goodbye}"
@ -122,7 +122,7 @@ describe "amend-line" do
end
it 'should correctly amend the specified range of lines' do
@t.push *unindent(<<-STR).split("\n")
@t.push(*unindent(<<-STR).split("\n"))
def hello
puts :bing
puts :bang
@ -131,7 +131,7 @@ describe "amend-line" do
@t.process_command 'amend-line 2..3 puts :bong'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
def hello
puts :bong
puts :heart
@ -139,7 +139,7 @@ describe "amend-line" do
end
it 'should correctly delete a specific line using the ! for content' do
@t.push *unindent(<<-STR).split("\n")
@t.push(*unindent(<<-STR).split("\n"))
def hello
puts :bing
puts :bang
@ -149,7 +149,7 @@ describe "amend-line" do
@t.process_command 'amend-line 3 !'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
def hello
puts :bing
puts :boast
@ -158,7 +158,7 @@ describe "amend-line" do
end
it 'should correctly delete a range of lines using the ! for content' do
@t.push *unindent(<<-STR).split("\n")
@t.push(*unindent(<<-STR).split("\n"))
def hello
puts :bing
puts :bang
@ -168,14 +168,14 @@ describe "amend-line" do
@t.process_command 'amend-line 2..4 !'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
def hello
puts :heart
STR
end
it 'should correctly delete the previous line using the ! for content' do
@t.push *unindent(<<-STR).split("\n")
@t.push(*unindent(<<-STR).split("\n"))
def hello
puts :bing
puts :bang
@ -185,7 +185,7 @@ describe "amend-line" do
@t.process_command 'amend-line !'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
def hello
puts :bing
puts :bang
@ -194,7 +194,7 @@ describe "amend-line" do
end
it 'should amend the specified range of lines, with numbers < 0 in range' do
@t.push *unindent(<<-STR).split("\n")
@t.push(*unindent(<<-STR).split("\n"))
def hello
puts :bing
puts :bang
@ -204,7 +204,7 @@ describe "amend-line" do
@t.process_command 'amend-line 2..-2 puts :bong'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
def hello
puts :bong
puts :heart
@ -212,7 +212,7 @@ describe "amend-line" do
end
it 'should correctly insert a line before a specified line using >' do
@t.push *unindent(<<-STR).split("\n")
@t.push(*unindent(<<-STR).split("\n"))
def hello
puts :bing
puts :bang
@ -220,7 +220,7 @@ describe "amend-line" do
@t.process_command 'amend-line 2 > puts :inserted'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
def hello
puts :inserted
puts :bing
@ -229,7 +229,7 @@ describe "amend-line" do
end
it 'should ignore second value of range with > syntax' do
@t.push *unindent(<<-STR).split("\n")
@t.push(*unindent(<<-STR).split("\n"))
def hello
puts :bing
puts :bang
@ -237,7 +237,7 @@ describe "amend-line" do
@t.process_command 'amend-line 2..21 > puts :inserted'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
def hello
puts :inserted
puts :bing

View file

@ -13,32 +13,32 @@ describe Pry::Command::Cat::FileFormatter do
file_with_embedded_line = "C:/Ruby193/pry_instance.rb"
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should == "C:/Ruby193/pry_instance.rb"
line_num.should == nil
file_name.should eq "C:/Ruby193/pry_instance.rb"
line_num.should eq nil
end
it "should parse '/'style absolute path with line_num" do
file_with_embedded_line = "C:/Ruby193/pry_instance.rb:2"
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should == "C:/Ruby193/pry_instance.rb"
line_num.should == 2
file_name.should eq "C:/Ruby193/pry_instance.rb"
line_num.should eq 2
end
it "should parse '\\'style absolute path without line_num" do
file_with_embedded_line = "C:\\Ruby193\\pry_instance.rb"
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should == "C:\\Ruby193\\pry_instance.rb"
line_num.should == nil
file_name.should eq "C:\\Ruby193\\pry_instance.rb"
line_num.should eq nil
end
it "should parse '\\'style absolute path with line_num" do
file_with_embedded_line = "C:\\Ruby193\\pry_instance.rb:2"
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should == "C:\\Ruby193\\pry_instance.rb"
line_num.should == 2
file_name.should eq "C:\\Ruby193\\pry_instance.rb"
line_num.should eq 2
end
end
@ -47,16 +47,16 @@ describe Pry::Command::Cat::FileFormatter do
file_with_embedded_line = "/Ruby193/pry_instance.rb"
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should == "/Ruby193/pry_instance.rb"
line_num.should == nil
file_name.should eq "/Ruby193/pry_instance.rb"
line_num.should eq nil
end
it "should parse absolute path with line_num" do
file_with_embedded_line = "/Ruby193/pry_instance.rb:2"
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should == "/Ruby193/pry_instance.rb"
line_num.should == 2
file_name.should eq "/Ruby193/pry_instance.rb"
line_num.should eq 2
end
end
@ -64,16 +64,16 @@ describe Pry::Command::Cat::FileFormatter do
file_with_embedded_line = "pry_instance.rb"
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should == "pry_instance.rb"
line_num.should == nil
file_name.should eq "pry_instance.rb"
line_num.should eq nil
end
it "should parse relative path with line_num" do
file_with_embedded_line = "pry_instance.rb:2"
ff = Pry::Command::Cat::FileFormatter.new(file_with_embedded_line, @p, @opt)
file_name, line_num = ff.file_and_line
file_name.should == "pry_instance.rb"
line_num.should == 2
file_name.should eq "pry_instance.rb"
line_num.should eq 2
end
end
end

View file

@ -8,8 +8,8 @@ describe 'cd' do
@o.instance_variable_set(:@obj, @obj)
@t = pry_tester(@o) do
def assert_binding_stack(other)
binding_stack.map { |b| b.eval('self') }.should == other
def mapped_binding_stack
binding_stack.map { |b| b.eval('self') }
end
def binding_stack
@ -37,7 +37,7 @@ describe 'cd' do
it 'should not toggle when there is no old stack' do
2.times do
@t.eval 'cd -'
@t.assert_binding_stack [@o]
@t.mapped_binding_stack.should eq [@o]
end
end
end
@ -46,88 +46,88 @@ describe 'cd' do
it 'should not toggle and should keep correct stacks' do
expect { @t.eval 'cd %' }.to raise_error Pry::CommandError
@t.old_stack.should == []
@t.assert_binding_stack [@o]
@t.old_stack.should eq []
@t.mapped_binding_stack.should eq [@o]
@t.eval 'cd -'
@t.old_stack.should == []
@t.assert_binding_stack [@o]
@t.old_stack.should eq []
@t.mapped_binding_stack.should eq [@o]
end
end
describe 'when using simple cd syntax' do
it 'should toggle' do
@t.eval 'cd :mon_dogg', 'cd -'
@t.assert_binding_stack [@o]
@t.mapped_binding_stack.should eq [@o]
@t.eval 'cd -'
@t.assert_binding_stack [@o, :mon_dogg]
@t.mapped_binding_stack.should eq [@o, :mon_dogg]
end
end
describe "when using complex cd syntax" do
it 'should toggle with a complex path (simple case)' do
@t.eval 'cd 1/2/3', 'cd -'
@t.assert_binding_stack [@o]
@t.mapped_binding_stack.should eq [@o]
@t.eval 'cd -'
@t.assert_binding_stack [@o, 1, 2, 3]
@t.mapped_binding_stack.should eq [@o, 1, 2, 3]
end
it 'should toggle with a complex path (more complex case)' do
@t.eval 'cd 1/2/3', 'cd ../4', 'cd -'
@t.assert_binding_stack [@o, 1, 2, 3]
@t.mapped_binding_stack.should eq [@o, 1, 2, 3]
@t.eval 'cd -'
@t.assert_binding_stack [@o, 1, 2, 4]
@t.mapped_binding_stack.should eq [@o, 1, 2, 4]
end
end
describe 'series of cd calls' do
it 'should toggle with fuzzy `cd -` calls' do
@t.eval 'cd :mon_dogg', 'cd -', 'cd 42', 'cd -'
@t.assert_binding_stack [@o]
@t.mapped_binding_stack.should eq [@o]
@t.eval 'cd -'
@t.assert_binding_stack [@o, 42]
@t.mapped_binding_stack.should eq [@o, 42]
end
end
describe 'when using cd ..' do
it 'should toggle with a simple path' do
@t.eval 'cd :john_dogg', 'cd ..'
@t.assert_binding_stack [@o]
@t.mapped_binding_stack.should eq [@o]
@t.eval 'cd -'
@t.assert_binding_stack [@o, :john_dogg]
@t.mapped_binding_stack.should eq [@o, :john_dogg]
end
it 'should toggle with a complex path' do
@t.eval 'cd 1/2/3/../4', 'cd -'
@t.assert_binding_stack [@o]
@t.mapped_binding_stack.should eq [@o]
@t.eval 'cd -'
@t.assert_binding_stack [@o, 1, 2, 4]
@t.mapped_binding_stack.should eq [@o, 1, 2, 4]
end
end
describe 'when using cd ::' do
it 'should toggle' do
@t.eval 'cd ::', 'cd -'
@t.assert_binding_stack [@o]
@t.mapped_binding_stack.should eq [@o]
@t.eval 'cd -'
@t.assert_binding_stack [@o, TOPLEVEL_BINDING.eval('self')]
@t.mapped_binding_stack.should eq [@o, TOPLEVEL_BINDING.eval('self')]
end
end
describe 'when using cd /' do
it 'should toggle' do
@t.eval 'cd /', 'cd -'
@t.assert_binding_stack [@o]
@t.mapped_binding_stack.should eq [@o]
@t.eval 'cd :john_dogg', 'cd /', 'cd -'
@t.assert_binding_stack [@o, :john_dogg]
@t.mapped_binding_stack.should eq [@o, :john_dogg]
end
end
@ -135,90 +135,90 @@ describe 'cd' do
it 'should keep correct old binding' do
@t.eval 'cd :john_dogg', 'cd :mon_dogg', 'cd :kyr_dogg',
'Pry::DEFAULT_CONTROL_D_HANDLER.call("", _pry_)'
@t.assert_binding_stack [@o, :john_dogg, :mon_dogg]
@t.mapped_binding_stack.should eq [@o, :john_dogg, :mon_dogg]
@t.eval 'cd -'
@t.assert_binding_stack [@o, :john_dogg, :mon_dogg, :kyr_dogg]
@t.mapped_binding_stack.should eq [@o, :john_dogg, :mon_dogg, :kyr_dogg]
@t.eval 'cd -'
@t.assert_binding_stack [@o, :john_dogg, :mon_dogg]
@t.mapped_binding_stack.should eq [@o, :john_dogg, :mon_dogg]
end
end
end
it 'should cd into simple input' do
@t.eval 'cd :mon_ouie'
@t.eval('self').should == :mon_ouie
@t.eval('self').should eq :mon_ouie
end
it 'should break out of session with cd ..' do
@t.eval 'cd :outer', 'cd :inner'
@t.eval('self').should == :inner
@t.eval('self').should eq :inner
@t.eval 'cd ..'
@t.eval('self').should == :outer
@t.eval('self').should eq :outer
end
it "should not leave the REPL session when given 'cd ..'" do
@t.eval 'cd ..'
@t.eval('self').should == @o
@t.eval('self').should eq @o
end
it 'should break out to outer-most session with cd /' do
@t.eval 'cd :inner'
@t.eval('self').should == :inner
@t.eval('self').should eq :inner
@t.eval 'cd 5'
@t.eval('self').should == 5
@t.eval('self').should eq 5
@t.eval 'cd /'
@t.eval('self').should == @o
@t.eval('self').should eq @o
end
it 'should break out to outer-most session with just cd (no args)' do
@t.eval 'cd :inner'
@t.eval('self').should == :inner
@t.eval('self').should eq :inner
@t.eval 'cd 5'
@t.eval('self').should == 5
@t.eval('self').should eq 5
@t.eval 'cd'
@t.eval('self').should == @o
@t.eval('self').should eq @o
end
it 'should cd into an object and its ivar using cd obj/@ivar syntax' do
@t.eval 'cd @obj/@x'
@t.assert_binding_stack [@o, @obj, 66]
@t.mapped_binding_stack.should eq [@o, @obj, 66]
end
it 'should cd into an object and its ivar using cd obj/@ivar/ syntax (note following /)' do
@t.eval 'cd @obj/@x/'
@t.assert_binding_stack [@o, @obj, 66]
@t.mapped_binding_stack.should eq [@o, @obj, 66]
end
it 'should cd into previous object and its local using cd ../local syntax' do
@t.eval 'cd @obj', 'local = :local', 'cd @x', 'cd ../local'
@t.assert_binding_stack [@o, @obj, :local]
@t.mapped_binding_stack.should eq [@o, @obj, :local]
end
it 'should cd into an object and its ivar and back again using cd obj/@ivar/.. syntax' do
@t.eval 'cd @obj/@x/..'
@t.assert_binding_stack [@o, @obj]
@t.mapped_binding_stack.should eq [@o, @obj]
end
it 'should cd into an object and its ivar and back and then into another ivar using cd obj/@ivar/../@y syntax' do
@t.eval 'cd @obj/@x/../@y'
@t.assert_binding_stack [@o, @obj, 79]
@t.mapped_binding_stack.should eq [@o, @obj, 79]
end
it 'should cd back to top-level and then into another ivar using cd /@ivar/ syntax' do
@t.eval '@z = 20', 'cd @obj/@x/', 'cd /@z'
@t.assert_binding_stack [@o, 20]
@t.mapped_binding_stack.should eq [@o, 20]
end
it 'should start a session on TOPLEVEL_BINDING with cd ::' do
@t.eval 'cd ::'
@t.eval('self').should == TOPLEVEL_BINDING.eval('self')
@t.eval('self').should eq TOPLEVEL_BINDING.eval('self')
end
it 'should cd into complex input (with spaces)' do
@ -227,23 +227,23 @@ describe 'cd' do
end
@t.eval 'cd hello 1, 2, 3'
@t.eval('self').should == :mon_ouie
@t.eval('self').should eq :mon_ouie
end
it 'should not cd into complex input when it encounters an exception' do
expect { @t.eval 'cd 1/2/swoop_a_doop/3' }.to raise_error Pry::CommandError
@t.assert_binding_stack [@o]
@t.mapped_binding_stack.should eq [@o]
end
it 'can cd into an expression containing a string with slashes in it' do
@t.eval 'cd ["http://google.com"]'
@t.eval('self').should == ["http://google.com"]
@t.eval('self').should eq ["http://google.com"]
end
it 'can cd into an expression with division in it' do
@t.eval 'cd (10/2)/even?'
@t.eval('self').should == false
@t.eval('self').should eq false
end
# Regression test for ticket #516.

View file

@ -14,8 +14,8 @@ describe "disable-pry" do
end
it "should set DISABLE_PRY" do
ENV['DISABLE_PRY'].should == nil
ENV['DISABLE_PRY'].should eq nil
expect { @t.process_command 'disable-pry' }.to throw_symbol :breakout
ENV['DISABLE_PRY'].should == 'true'
ENV['DISABLE_PRY'].should eq 'true'
end
end

View file

@ -31,7 +31,7 @@ describe "edit" do
end
after do
FileUtils.rm(@tf_path) if File.exists?(@tf_path)
FileUtils.rm(@tf_path) if File.exist?(@tf_path)
end
it "should not allow patching any known kind of file" do
@ -43,32 +43,32 @@ describe "edit" do
it "should invoke Pry.config.editor with absolutified filenames" do
pry_eval 'edit lib/pry.rb'
@file.should == File.expand_path('lib/pry.rb')
@file.should eq File.expand_path('lib/pry.rb')
pry_eval "edit #@tf_path"
@file.should == @tf_path
@file.should eq @tf_path
end
it "should guess the line number from a colon" do
pry_eval 'edit lib/pry.rb:10'
@line.should == 10
@line.should eq 10
end
it "should use the line number from -l" do
pry_eval 'edit -l 10 lib/pry.rb'
@line.should == 10
@line.should eq 10
end
it "should not delete the file!" do
pry_eval 'edit Rakefile'
File.exist?(@file).should == true
File.exist?(@file).should eq true
end
it "works with files that contain blanks in their names" do
tf_path = File.join(File.dirname(@tf_path), 'swoop and doop.rb')
FileUtils.touch(tf_path)
pry_eval "edit #{ tf_path }"
@file.should == tf_path
@file.should eq tf_path
FileUtils.rm(tf_path)
end
@ -84,7 +84,7 @@ describe "edit" do
nil
}
pry_eval "edit #@tf_path"
Pad.required.should == true
Pad.required.should eq true
end
end
@ -104,7 +104,7 @@ describe "edit" do
pry_eval "edit #{path}"
Pad.counter.should == counter + 1
Pad.counter.should eq counter + 1
end
end
@ -115,7 +115,7 @@ describe "edit" do
pry_eval "edit #{path}"
Pad.counter.should == counter
Pad.counter.should eq counter
end
end
@ -124,7 +124,9 @@ describe "edit" do
counter = Pad.counter
path = tf.path
Pad.counter.should == counter
pry_eval "edit -n #{path}"
Pad.counter.should eq counter
end
end
@ -135,7 +137,7 @@ describe "edit" do
pry_eval "edit -r #{path}"
Pad.counter.should == counter + 1
Pad.counter.should eq counter + 1
end
end
end
@ -151,9 +153,9 @@ describe "edit" do
it "should pass the editor a reloading arg" do
pry_eval 'edit lib/pry.rb'
@reloading.should == true
@reloading.should eq true
pry_eval 'edit -n lib/pry.rb'
@reloading.should == false
@reloading.should eq false
end
end
end
@ -184,7 +186,7 @@ describe "edit" do
after do
@tf.close(true)
File.unlink("#{@path}c") if File.exists?("#{@path}c") #rbx
File.unlink("#{@path}c") if File.exist?("#{@path}c") #rbx
end
it "should reload the file" do
@ -200,7 +202,7 @@ describe "edit" do
@t.eval 'edit --ex'
FOO.should == 'BAR'
FOO.should eq 'BAR'
end
# regression test (this used to edit the current method instead
@ -220,7 +222,7 @@ describe "edit" do
Object.new.pry
end
source_location.should == [@path, 3]
source_location.should eq [@path, 3]
Pad.clear
end
@ -250,11 +252,11 @@ describe "edit" do
@t.eval 'edit --ex --patch'
FOO3.should == 'PIYO'
FOO3.should eq 'PIYO'
@tf.rewind
@tf.read.should == "1\n2\nraise RuntimeError"
@patched_def.should == "FOO3 = 'PIYO'"
@tf.read.should eq "1\n2\nraise RuntimeError"
@patched_def.should eq "FOO3 = 'PIYO'"
end
end
end
@ -272,26 +274,26 @@ describe "edit" do
it 'should start on first level of backtrace with just --ex' do
@t.eval 'edit -n --ex'
@__ex_file__.should == "a"
@__ex_line__.should == 1
@__ex_file__.should eq "a"
@__ex_line__.should eq 1
end
it 'should start editor on first level of backtrace with --ex 0' do
@t.eval 'edit -n --ex 0'
@__ex_file__.should == "a"
@__ex_line__.should == 1
@__ex_file__.should eq "a"
@__ex_line__.should eq 1
end
it 'should start editor on second level of backtrace with --ex 1' do
@t.eval 'edit -n --ex 1'
@__ex_file__.should == "b"
@__ex_line__.should == 2
@__ex_file__.should eq "b"
@__ex_line__.should eq 2
end
it 'should start editor on third level of backtrace with --ex 2' do
@t.eval 'edit -n --ex 2'
@__ex_file__.should == "c"
@__ex_line__.should == 3
@__ex_file__.should eq "c"
@__ex_line__.should eq 3
end
it 'should display error message when backtrace level is invalid' do
@ -308,29 +310,29 @@ describe "edit" do
it "should edit the current expression if it's incomplete" do
@t.push 'def a'
@t.process_command 'edit'
@contents.should == "def a\n"
@contents.should eq "def a\n"
end
it "should edit the previous expression if the current is empty" do
@t.eval 'def a; 2; end', 'edit'
@contents.should == "def a; 2; end\n"
@contents.should eq "def a; 2; end\n"
end
it "should use a blank file if -t is specified" do
@t.eval 'def a; 5; end', 'edit -t'
@contents.should == "\n"
@contents.should eq "\n"
end
it "should use a blank file if -t given, even during an expression" do
@t.push 'def a;'
@t.process_command 'edit -t'
@contents.should == "\n"
@contents.should eq "\n"
end
it "should position the cursor at the end of the expression" do
@t.eval "def a; 2;\nend"
@t.process_command 'edit'
@line.should == 2
@line.should eq 2
end
it "should evaluate the expression" do
@ -339,7 +341,7 @@ describe "edit" do
nil
}
@t.process_command 'edit'
@t.eval_string.should == "'FOO'\n"
@t.eval_string.should eq "'FOO'\n"
end
it "should ignore -n for tempfiles" do
@ -348,7 +350,7 @@ describe "edit" do
nil
}
@t.process_command "edit -n"
@t.eval_string.should == "'FOO'\n"
@t.eval_string.should eq "'FOO'\n"
end
it "should not evaluate a file with -n" do
@ -358,8 +360,8 @@ describe "edit" do
}
begin
@t.process_command 'edit -n spec/fixtures/foo.rb'
File.read("spec/fixtures/foo.rb").should == "'FOO'\n"
@t.eval_string.should == ''
File.read("spec/fixtures/foo.rb").should eq "'FOO'\n"
@t.eval_string.should eq ''
ensure
FileUtils.rm "spec/fixtures/foo.rb"
end
@ -369,22 +371,22 @@ describe "edit" do
describe "with --in" do
it "should edit the nth line of _in_" do
pry_eval '10', '11', 'edit --in -2'
@contents.should == "10\n"
@contents.should eq "10\n"
end
it "should edit the last line if no argument is given" do
pry_eval '10', '11', 'edit --in'
@contents.should == "11\n"
@contents.should eq "11\n"
end
it "should edit a range of lines if a range is given" do
pry_eval "10", "11", "edit -i 1,2"
@contents.should == "10\n11\n"
@contents.should eq "10\n11\n"
end
it "should edit a multi-line expression as it occupies one line of _in_" do
pry_eval "class Fixnum\n def invert; -self; end\nend", "edit -i 1"
@contents.should == "class Fixnum\n def invert; -self; end\nend\n"
@contents.should eq "class Fixnum\n def invert; -self; end\nend\n"
end
it "should not work with a filename" do
@ -398,7 +400,6 @@ describe "edit" do
describe 'when editing a method by name' do
def use_editor(tester, options)
initial_editor = tester.pry.editor
tester.pry.config.editor = lambda do |filename, line|
File.open(filename, 'w') { |f| f.write options.fetch(:replace_all) }
nil
@ -414,18 +415,18 @@ describe "edit" do
klass = Class.new do
def m; 1; end
end
klass.new.m.should == 1
klass.new.m.should eq 1
# now patch it
use_editor(tester, replace_all: 'def m; 2; end').eval('edit --patch klass#m')
klass.new.m.should == 2
klass.new.m.should eq 2
# edit by name, no --patch
use_editor(tester, replace_all: 'def m; 3; end').eval("edit klass#m")
klass.new.m.should == 3
klass.new.m.should eq 3
# original file is unchanged
File.readlines(filename)[line-1].strip.should == 'def m; 1; end'
File.readlines(filename)[line-1].strip.should eq 'def m; 1; end'
end
it 'can repeatedly edit methods that were defined in the console' do
@ -434,21 +435,23 @@ describe "edit" do
tester.eval("klass = Class.new do\n"\
" def m; 1; end\n"\
"end")
tester.eval("klass.new.m").should == 1
tester.eval("klass.new.m").should eq 1
# first edit
use_editor(tester, replace_all: 'def m; 2; end').eval('edit klass#m')
tester.eval('klass.new.m').should == 2
tester.eval('klass.new.m').should eq 2
# repeat edit
use_editor(tester, replace_all: 'def m; 3; end').eval('edit klass#m')
tester.eval('klass.new.m').should == 3
tester.eval('klass.new.m').should eq 3
end
end
describe "old edit-method tests now migrated to edit" do
describe "on a method defined in a file" do
before do
Object.remove_const :X if defined? ::X
Object.remove_const :A if defined? ::A
@tempfile = (Tempfile.new(['pry', '.rb']))
@tempfile.puts <<-EOS
module A
@ -485,7 +488,7 @@ describe "edit" do
G = :nawt
def foo
:possibly
_foo = :possibly
G
end
end
@ -513,33 +516,33 @@ describe "edit" do
it "should correctly find a class method" do
pry_eval 'edit X.x'
@file.should == @tempfile_path
@line.should == 14
@file.should eq @tempfile_path
@line.should eq 14
end
it "should correctly find an instance method" do
pry_eval 'edit X#x'
@file.should == @tempfile_path
@line.should == 18
@file.should eq @tempfile_path
@line.should eq 18
end
it "should correctly find a method on an instance" do
pry_eval 'x = X.new', 'edit x.x'
@file.should == @tempfile_path
@line.should == 18
@file.should eq @tempfile_path
@line.should eq 18
end
it "should correctly find a method from a module" do
pry_eval 'edit X#a'
@file.should == @tempfile_path
@line.should == 2
@file.should eq @tempfile_path
@line.should eq 2
end
it "should correctly find an aliased method" do
pry_eval 'edit X#c'
@file.should == @tempfile_path
@line.should == 22
@file.should eq @tempfile_path
@line.should eq 22
end
end
@ -562,44 +565,44 @@ describe "edit" do
class << X
X.method(:x).owner.should == self
end
X.method(:x).receiver.should == X
X.x.should == :maybe
X.method(:x).receiver.should eq X
X.x.should eq :maybe
end
it "should successfully replace an instance method" do
pry_eval 'edit -p X#x'
X.instance_method(:x).owner.should == X
X.new.x.should == :maybe
X.instance_method(:x).owner.should eq X
X.new.x.should eq :maybe
end
it "should successfully replace a method on an instance" do
pry_eval 'instance = X.new', 'edit -p instance.x'
instance = X.new
instance.method(:x).owner.should == X
instance.x.should == :maybe
instance.method(:x).owner.should eq X
instance.x.should eq :maybe
end
it "should successfully replace a method from a module" do
pry_eval 'edit -p X#a'
X.instance_method(:a).owner.should == A
X.new.a.should == :maybe
X.instance_method(:a).owner.should eq A
X.new.a.should eq :maybe
end
it "should successfully replace a method with a question mark" do
pry_eval 'edit -p X#y?'
X.instance_method(:y?).owner.should == X
X.new.y?.should == :maybe
X.instance_method(:y?).owner.should eq X
X.new.y?.should eq :maybe
end
it "should preserve module nesting" do
pry_eval 'edit -p X::B#foo'
X::B.instance_method(:foo).owner.should == X::B
X::B.new.foo.should == :nawt
X::B.instance_method(:foo).owner.should eq X::B
X::B.new.foo.should eq :nawt
end
describe "monkey-patching" do
@ -611,7 +614,7 @@ describe "edit" do
# @return [String] the stripped line from the tempfile at +lineno+
def stripped_line_at(lineno)
@tempfile.rewind
@tempfile.lines.to_a[lineno].strip
@tempfile.each_line.to_a[lineno].strip
end
# Applies the monkey patch for +method+ with help of evaluation of
@ -638,54 +641,54 @@ describe "edit" do
def_before, def_after =
apply_monkey_patch(X.method(:x), "#@edit X.x")
def_before.should == ':double_yup'
def_after.should == ':double_yup'
@patched_def.should == ':maybe'
def_before.should eq ':double_yup'
def_after.should eq ':double_yup'
@patched_def.should eq ':maybe'
end
it "should work for an instance method" do
def_before, def_after =
apply_monkey_patch(X.instance_method(:x), "#@edit X#x")
def_before.should == ':nope'
def_after.should == ':nope'
@patched_def.should == ':maybe'
def_before.should eq ':nope'
def_after.should eq ':nope'
@patched_def.should eq ':maybe'
end
it "should work for a method on an instance" do
def_before, def_after =
apply_monkey_patch(X.instance_method(:x), 'instance = X.new', "#@edit instance.x")
def_before.should == ':nope'
def_after.should == ':nope'
@patched_def.should == ':maybe'
def_before.should eq ':nope'
def_after.should eq ':nope'
@patched_def.should eq ':maybe'
end
it "should work for a method from a module" do
def_before, def_after =
apply_monkey_patch(X.instance_method(:a), "#@edit X#a")
def_before.should == ':yup'
def_after.should == ':yup'
@patched_def.should == ':maybe'
def_before.should eq ':yup'
def_after.should eq ':yup'
@patched_def.should eq ':maybe'
end
it "should work for a method with a question mark" do
def_before, def_after =
apply_monkey_patch(X.instance_method(:y?), "#@edit X#y?")
def_before.should == ':because'
def_after.should == ':because'
@patched_def.should == ':maybe'
def_before.should eq ':because'
def_after.should eq ':because'
@patched_def.should eq ':maybe'
end
it "should work with nesting" do
def_before, def_after =
apply_monkey_patch(X::B.instance_method(:foo), "#@edit X::B#foo")
def_before.should == ':possibly'
def_after.should == ':possibly'
@patched_def.should == ':maybe'
def_before.should eq '_foo = :possibly'
def_after.should eq '_foo = :possibly'
@patched_def.should eq ':maybe'
end
end
end
@ -708,10 +711,10 @@ describe "edit" do
pry_eval 'edit -p X#c'
Pry::Method.from_str("X#c").alias?.should == true
Pry::Method.from_str("X#c").alias?.should eq true
X.new.b.should == :kinda
X.new.c.should == :kindaaa
X.new.b.should eq :kinda
X.new.c.should eq :kindaaa
$x = nil
end
end
@ -727,9 +730,9 @@ describe "edit" do
it "should pass the editor a reloading arg" do
pry_eval 'edit X.x'
@reloading.should == true
@reloading.should eq true
pry_eval 'edit -n X.x'
@reloading.should == false
@reloading.should eq false
end
end
end
@ -746,7 +749,7 @@ describe "edit" do
}
def m2
:jeremy_jones
_foo = :jeremy_jones
binding
end
end
@ -758,7 +761,7 @@ describe "edit" do
it 'should edit method context' do
Pry.config.editor = lambda do |file, line|
[file, line].should == BinkyWink.instance_method(:m2).source_location
[file, line].should eq BinkyWink.instance_method(:m2).source_location
nil
end
@ -768,7 +771,7 @@ describe "edit" do
it 'errors when cannot find method context' do
Pry.config.editor = lambda do |file, line|
[file, line].should == BinkyWink.instance_method(:m1).source_location
[file, line].should eq BinkyWink.instance_method(:m1).source_location
nil
end

View file

@ -5,9 +5,9 @@ describe "exit" do
it "should pop a binding" do
@pry.eval "cd :inner"
@pry.evaluate_ruby("self").should == :inner
@pry.evaluate_ruby("self").should eq :inner
@pry.eval "exit"
@pry.evaluate_ruby("self").should == :outer
@pry.evaluate_ruby("self").should eq :outer
end
it "should break out of the repl when binding_stack has only one binding" do
@ -17,7 +17,7 @@ describe "exit" do
it "should break out of the repl and return user-given value" do
@pry.eval("exit :john").should equal false
@pry.exit_value.should == :john
@pry.exit_value.should eq :john
end
it "should break out of the repl even after an exception" do

View file

@ -17,7 +17,7 @@ describe "help" do
end
it 'should display help for a regex command with a "listing"' do
@set.command /bar(.*)/, "Test listing", :listing => "foo" do; end
@set.command(/bar(.*)/, "Test listing", :listing => "foo") do; end
pry_eval('help foo').should =~ /Test listing/
end
@ -27,7 +27,7 @@ describe "help" do
end
it 'should display help for all commands with a description' do
@set.command /bar(.*)/, "Test listing", :listing => "foo" do; end
@set.command(/bar(.*)/, "Test listing", :listing => "foo") do; end
@set.command "b", "description for b", :listing => "foo" do; end
@set.command "c" do;end
@set.command "d", "" do;end

View file

@ -24,7 +24,7 @@ describe "hist" do
@t.push_binding o
@t.eval 'hist --replay -1'
o.instance_variable_get(:@z).should == 30
o.instance_variable_get(:@z).should eq 30
end
it 'should replay a range of history correctly (range of items)' do
@ -34,19 +34,18 @@ describe "hist" do
@t.push_binding o
@t.eval 'hist --replay 0..2'
@t.eval('[@x, @y]').should == [10, 20]
@t.eval('[@x, @y]').should eq [10, 20]
end
# this is to prevent a regression where input redirection is
# replaced by just appending to `eval_string`
it 'should replay a range of history correctly (range of commands)' do
o = Object.new
@hist.push "cd 1"
@hist.push "cd 2"
@t.eval("hist --replay 0..2")
stack = @t.eval("Pad.stack = _pry_.binding_stack.dup")
stack.map{ |b| b.eval("self") }.should == [TOPLEVEL_BINDING.eval("self"), 1, 2]
stack.map{ |b| b.eval("self") }.should eq [TOPLEVEL_BINDING.eval("self"), 1, 2]
end
it 'should grep for correct lines in history' do
@ -75,7 +74,7 @@ describe "hist" do
end
out = @t.eval 'hist --tail 3'
out.each_line.count.should == 3
out.each_line.count.should eq 3
out.should =~ /x\n\d+:.*y\n\d+:.*z/
end
@ -93,7 +92,7 @@ describe "hist" do
@hist.push "puts 5"
out = @t.eval 'hist --tail 2 --grep print'
out.each_line.count.should == 2
out.each_line.count.should eq 2
out.should =~ /\d:.*?print 2\n\d:.*?print 4/
end
@ -105,7 +104,7 @@ describe "hist" do
@hist.push "print 5"
out = @t.eval 'hist --head 2 --grep print'
out.each_line.count.should == 2
out.each_line.count.should eq 2
out.should =~ /\d:.*?print 2\n\d:.*?print 4/
end
@ -117,7 +116,7 @@ describe "hist" do
end
out = @t.eval 'hist --head 4'
out.each_line.count.should == 4
out.each_line.count.should eq 4
out.should =~ /a\n\d+:.*b\n\d+:.*c/
end
@ -129,7 +128,7 @@ describe "hist" do
end
out = @t.eval 'hist --show 1..4'
out.each_line.count.should == 4
out.each_line.count.should eq 4
out.should =~ /b\n\d+:.*c\n\d+:.*d/
end
@ -146,7 +145,7 @@ describe "hist" do
@t.eval("hist --replay 1..3")
output = @t.eval("hist")
output.should == "1: :banzai\n2: :geronimo\n3: :huzzah\n4: hist --replay 1..3\n"
output.should eq "1: :banzai\n2: :geronimo\n3: :huzzah\n4: hist --replay 1..3\n"
end
it "should raise CommandError when index of `--replay` points out to another `hist --replay`" do
@ -161,14 +160,14 @@ describe "hist" do
@t.eval "a += 1"
@t.eval "hist --replay 2"
expect { @t.eval "hist --replay 3" }.to raise_error Pry::CommandError
@t.eval("a").should == 2
@t.eval("hist").lines.to_a.size.should == 5
@t.eval("a").should eq 2
@t.eval("hist").lines.to_a.size.should eq 5
end
it "excludes Pry commands from the history with `-e` switch" do
@hist.push('a = 20')
@hist.push('ls')
pry_eval('hist -e').should == "1: a = 20\n"
pry_eval('hist -e').should eq "1: a = 20\n"
end
describe "sessions" do

View file

@ -9,10 +9,10 @@ RSpec.describe "jump-to" do
end
it 'prints an error when trying to jump to the same binding index' do
expect(pry_eval obj, "cd 1", "cd 2", "jump-to 2").to match /Already/
expect(pry_eval obj, "cd 1", "cd 2", "jump-to 2").to match(/Already/)
end
it 'prints error when trying to jump to a non-existent binding index' do
expect(pry_eval obj, "cd 1", "cd 2", "jump-to 3").to match /Invalid nest level/
expect(pry_eval obj, "cd 1", "cd 2", "jump-to 3").to match(/Invalid nest level/)
end
end

View file

@ -39,7 +39,7 @@ describe "play" do
describe "playing a file" do
it 'should play a file' do
@t.process_command 'play spec/fixtures/whereami_helper.rb'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
class Cor
def a; end
def b; end
@ -52,7 +52,7 @@ describe "play" do
it 'should output file contents with print option' do
@t.process_command 'play --print spec/fixtures/whereami_helper.rb'
@t.last_output.should == unindent(<<-STR)
@t.last_output.should eq unindent(<<-STR)
1: class Cor
2: def a; end
3: def b; end
@ -71,6 +71,8 @@ describe "play" do
end
it 'should play documentation with the -d switch' do
@o.singleton_class.send :remove_method, :test_method
# @v = 10
# @y = 20
def @o.test_method
@ -78,13 +80,15 @@ describe "play" do
end
@t.process_command 'play -d test_method'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
@v = 10
@y = 20
STR
end
it 'should restrict -d switch with --lines' do
@o.singleton_class.send :remove_method, :test_method
# @x = 0
# @v = 10
# @y = 20
@ -94,7 +98,7 @@ describe "play" do
end
@t.process_command 'play -d test_method --lines 2..3'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
@v = 10
@y = 20
STR
@ -106,16 +110,18 @@ describe "play" do
it 'should play a method (a single line)' do
@t.process_command 'play test_method --lines 2'
@t.eval_string.should == ":test_method_content\n"
@t.eval_string.should eq ":test_method_content\n"
end
it 'should properly reindent lines' do
@o.singleton_class.send :remove_method, :test_method
def @o.test_method
'hello world'
end
@t.process_command 'play test_method --lines 2'
@t.eval_string.should == "'hello world'\n"
@t.eval_string.should eq "'hello world'\n"
end
it 'should APPEND to the input buffer when playing a method line, not replace it' do
@ -125,13 +131,15 @@ describe "play" do
@t.process_command 'play test_method --lines 2'
@t.eval_string.should == unindent(<<-STR)
@t.eval_string.should eq unindent(<<-STR)
def another_test_method
:test_method_content
STR
end
it 'should play a method (multiple lines)' do
@o.singleton_class.send :remove_method, :test_method
def @o.test_method
@var0 = 10
@var1 = 20
@ -140,7 +148,7 @@ describe "play" do
end
@t.process_command 'play test_method --lines 3..4'
@t.eval_string.should == unindent(<<-STR, 0)
@t.eval_string.should eq unindent(<<-STR, 0)
@var1 = 20
@var2 = 30
STR
@ -155,13 +163,16 @@ describe "play" do
binding.pry
end
[a, b, c].all? { |v| v.should == 2 }
d.should == 1
[a, b, c].all? { |v| v.should eq 2 }
d.should eq 1
e.should eq 1
end
end
describe "play -e" do
it 'should run an expression from given line number' do
@o.singleton_class.send :remove_method, :test_method
def @o.test_method
@s = [
1,2,3,
@ -170,7 +181,7 @@ describe "play" do
end
@t.process_command 'play test_method -e 2'
@t.eval_string.should == unindent(<<-STR, 0)
@t.eval_string.should eq unindent(<<-STR, 0)
@s = [
1,2,3,
4,5,6

View file

@ -29,8 +29,8 @@ describe "raise-up" do
Pry.start(:outer)
end
Pad.inner.should == :inner
Pad.outer.should == :outer
Pad.inner.should eq :inner
Pad.outer.should eq :outer
end
it "should raise the most recently raised exception" do
@ -45,9 +45,9 @@ describe "raise-up" do
expect { Pry.start(:outer) }.to raise_error NoMethodError
end
Pad.deep.should == :deep
Pad.inner.should == :inner
Pad.outer.should == :outer
Pad.deep.should eq :deep
Pad.inner.should eq :inner
Pad.outer.should eq :outer
end
it "should jump immediately out of nested contexts with !" do

View file

@ -115,10 +115,10 @@ describe "show-doc" do
describe "rdoc highlighting" do
it "should syntax highlight code in rdoc" do
c = Class.new{
_c = Class.new{
# This can initialize your class:
#
# a = c.new :foo
# a = _c.new :foo
#
# @param foo
def initialize(foo); end
@ -126,19 +126,19 @@ describe "show-doc" do
begin
t = pry_tester(binding)
t.eval("show-doc c#initialize").should =~ /c.new :foo/
t.eval("show-doc _c#initialize").should =~ /_c.new :foo/
Pry.config.color = true
# I don't want the test to rely on which colour codes are there, just to
# assert that "something" is being colourized.
t.eval("show-doc c#initialize").should_not =~ /c.new :foo/
t.eval("show-doc _c#initialize").should_not =~ /_c.new :foo/
ensure
Pry.config.color = false
end
end
it "should syntax highlight `code` in rdoc" do
c = Class.new{
# After initializing your class with `c.new(:foo)`, go have fun!
_c = Class.new{
# After initializing your class with `_c.new(:foo)`, go have fun!
#
# @param foo
def initialize(foo); end
@ -146,11 +146,11 @@ describe "show-doc" do
begin
t = pry_tester(binding)
t.eval("show-doc c#initialize").should =~ /c.new\(:foo\)/
t.eval("show-doc _c#initialize").should =~ /_c.new\(:foo\)/
Pry.config.color = true
# I don't want the test to rely on which colour codes are there, just to
# assert that "something" is being colourized.
t.eval("show-doc c#initialize").should_not =~ /c.new\(:foo\)/
t.eval("show-doc _c#initialize").should_not =~ /_c.new\(:foo\)/
ensure
Pry.config.color = false
end
@ -158,7 +158,7 @@ describe "show-doc" do
end
it "should not syntax highlight `` inside code" do
c = Class.new{
_c = Class.new{
# Convert aligned output (from many shell commands) into nested arrays:
#
# a = decolumnize `ls -l $HOME`
@ -170,8 +170,8 @@ describe "show-doc" do
begin
t = pry_tester(binding)
Pry.config.color = true
t.eval("show-doc c#decolumnize").should =~ /ls -l \$HOME/
t.eval("show-doc c#decolumnize").should_not =~ /`ls -l \$HOME`/
t.eval("show-doc _c#decolumnize").should =~ /ls -l \$HOME/
t.eval("show-doc _c#decolumnize").should_not =~ /`ls -l \$HOME`/
ensure
Pry.config.color = false
end
@ -181,8 +181,8 @@ describe "show-doc" do
describe "on sourcable objects" do
it "should show documentation for object" do
# this is a documentation
hello = proc { puts 'hello world!' }
mock_pry(binding, "show-doc hello").should =~ /this is a documentation/
_hello = proc { puts 'hello world!' }
mock_pry(binding, "show-doc _hello").should =~ /this is a documentation/
end
end
@ -296,7 +296,7 @@ describe "show-doc" do
it 'should show the docs for all monkeypatches defined in different files' do
# local monkeypatch
class TestClassForShowSource
def beta
def epsilon
end
end
@ -321,7 +321,7 @@ describe "show-doc" do
'(when -a not used and more than one candidate exists for class)' do
# Still reading boring tests, eh?
class TestClassForShowSource
def beta
def delta
end
end
@ -413,7 +413,7 @@ describe "show-doc" do
end
it 'should display help for a regex command with a "listing"' do
@set.command /bar(.*)/, "Test listing", :listing => "foo" do; end
@set.command(/bar(.*)/, "Test listing", :listing => "foo") do; end
pry_eval('show-doc foo').should =~ /Test listing/
end

View file

@ -6,7 +6,7 @@ describe "show-input" do
end
it 'should correctly show the current lines in the input buffer' do
@t.push *unindent(<<-STR).split("\n")
@t.push(*unindent(<<-STR).split("\n"))
def hello
puts :bing
STR

View file

@ -8,6 +8,7 @@ describe "show-source" do
:sample
end
Object.remove_const :Test if Object.const_defined? :Test
Object.const_set(:Test, Module.new)
end
@ -47,7 +48,7 @@ describe "show-source" do
it "should find methods even if there are spaces in the arguments" do
def @o.foo(*bars)
"Mr flibble"
@foo = "Mr flibble"
self
end
@ -56,22 +57,22 @@ describe "show-source" do
end
it "should find methods even if the object overrides method method" do
c = Class.new{
_c = Class.new{
def method;
98
end
}
pry_eval(binding, "show-source c.new.method").should =~ /98/
pry_eval(binding, "show-source _c.new.method").should =~ /98/
end
it "should not show the source when a non-extant method is requested" do
c = Class.new{ def method; 98; end }
mock_pry(binding, "show-source c#wrongmethod").should =~ /Couldn't locate/
_c = Class.new{ def method; 98; end }
mock_pry(binding, "show-source _c#wrongmethod").should =~ /Couldn't locate/
end
it "should find instance_methods if the class overrides instance_method" do
c = Class.new{
_c = Class.new{
def method;
98
end
@ -79,43 +80,43 @@ describe "show-source" do
def self.instance_method; 789; end
}
pry_eval(binding, "show-source c#method").should =~ /98/
pry_eval(binding, "show-source _c#method").should =~ /98/
end
it "should find instance methods with self#moo" do
c = Class.new{ def moo; "ve over!"; end }
_c = Class.new{ def moo; "ve over!"; end }
pry_eval(binding, "cd c", "show-source self#moo").should =~ /ve over/
pry_eval(binding, "cd _c", "show-source self#moo").should =~ /ve over/
end
it "should not find instance methods with self.moo" do
c = Class.new{ def moo; "ve over!"; end }
_c = Class.new{ def moo; "ve over!"; end }
expect { pry_eval(binding, 'cd c', 'show-source self.moo') }.to raise_error(Pry::CommandError, /Couldn't locate/)
expect { pry_eval(binding, 'cd _c', 'show-source self.moo') }.to raise_error(Pry::CommandError, /Couldn't locate/)
end
it "should find normal methods with self.moo" do
c = Class.new{ def self.moo; "ve over!"; end }
_c = Class.new{ def self.moo; "ve over!"; end }
pry_eval(binding, 'cd c', 'show-source self.moo').should =~ /ve over/
pry_eval(binding, 'cd _c', 'show-source self.moo').should =~ /ve over/
end
it "should not find normal methods with self#moo" do
c = Class.new{ def self.moo; "ve over!"; end }
_c = Class.new{ def self.moo; "ve over!"; end }
expect { pry_eval(binding, 'cd c', 'show-source self#moo') }.to raise_error(Pry::CommandError, /Couldn't locate/)
expect { pry_eval(binding, 'cd _c', 'show-source self#moo') }.to raise_error(Pry::CommandError, /Couldn't locate/)
end
it "should find normal methods (i.e non-instance methods) by default" do
c = Class.new{ def self.moo; "ve over!"; end }
_c = Class.new{ def self.moo; "ve over!"; end }
pry_eval(binding, "cd c", "show-source moo").should =~ /ve over/
pry_eval(binding, "cd _c", "show-source moo").should =~ /ve over/
end
it "should find instance methods if no normal methods available" do
c = Class.new{ def moo; "ve over!"; end }
_c = Class.new{ def moo; "ve over!"; end }
pry_eval(binding, "cd c", "show-source moo").should =~ /ve over/
pry_eval(binding, "cd _c", "show-source moo").should =~ /ve over/
end
describe "with -e option" do
@ -134,7 +135,7 @@ describe "show-source" do
it "evaluates the argument as ruby and shows the source code for the returned value" do
ReplTester.start target: binding do
input 'show-source -e FooBar.new'
output /class FooBar/
output(/class FooBar/)
end
end
end
@ -202,7 +203,7 @@ describe "show-source" do
it "finds super methods without explicit method argument" do
o = Foo.new
def o.foo(*bars)
:wibble
@foo = :wibble
pry_eval(binding, 'show-source --super')
end
@ -219,7 +220,7 @@ describe "show-source" do
}
def o.foo(*bars)
:wibble
@foo = :wibble
pry_eval(binding, 'show-source --super --super')
end
@ -236,8 +237,8 @@ describe "show-source" do
end
it "should output source for procs/lambdas stored in variables" do
hello = proc { puts 'hello world!' }
pry_eval(binding, 'show-source hello').should =~ /proc \{ puts/
_hello = proc { puts 'hello world!' }
pry_eval(binding, 'show-source _hello').should =~ /proc \{ puts/
end
it "should output source for procs/lambdas stored in constants" do
@ -248,8 +249,8 @@ describe "show-source" do
it "should output source for method objects" do
def @o.hi; puts 'hi world'; end
meth = @o.method(:hi)
pry_eval(binding, "show-source meth").should =~ /puts 'hi world'/
_meth = @o.method(:hi)
pry_eval(binding, "show-source _meth").should =~ /puts 'hi world'/
end
describe "on variables that shadow methods" do
@ -296,8 +297,8 @@ describe "show-source" do
end
it "should output source of its class if variable doesn't respond to source_location" do
test_host = TestHost.new
pry_eval(binding, 'show-source test_host').
_test_host = TestHost.new
pry_eval(binding, 'show-source _test_host').
should =~ /class TestHost\n.*def hello/
end
@ -499,7 +500,7 @@ describe "show-source" do
describe "messages relating to -a" do
it 'indicates all available monkeypatches can be shown with -a when (when -a not used and more than one candidate exists for class)' do
class TestClassForShowSource
def beta
def gamma
end
end
@ -637,7 +638,7 @@ describe "show-source" do
end
it 'should show source for a command by listing name' do
@set.command /foo(.*)/, :body_of_foo_bar_regex, :listing => "bar" do; end
@set.command(/foo(.*)/, :body_of_foo_bar_regex, :listing => "bar") do; end
pry_eval('show-source bar').should =~ /:body_of_foo_bar_regex/
end

View file

@ -71,126 +71,123 @@ describe "whereami" do
def blimey!
pry_eval(binding, 'whereami')
end
END
end
expect { Cor.instance_method(:blimey!).source }.to raise_error MethodSource::SourceNotFoundError
Cor.new.blimey!.should =~ /Cor#blimey!.*Look at me/m
Object.remove_const(:Cor)
END
end
# Now that we use stagger_output (paging output) we no longer get
# the "From: " line, as we output everything in one go (not separate output.puts)
# and so the user just gets a single `Error: Cannot open
# "not.found.file.erb" for reading.`
# which is good enough IMO. Unfortunately we can't test for it
# though, as we don't hook stdout.
#
# it 'should display a description and error if reading the file goes wrong' do
# class Cor
# def blimey!
# eval <<-END, binding, "not.found.file.erb", 7
# Pad.tester = pry_tester(binding)
# Pad.tester.eval('whereami')
# END
# end
# end
expect { Cor.instance_method(:blimey!).source }.to raise_error MethodSource::SourceNotFoundError
# proc { Cor.new.blimey! }.should.raise(MethodSource::SourceNotFoundError)
Cor.new.blimey!.should =~ /Cor#blimey!.*Look at me/m
Object.remove_const(:Cor)
end
# Pad.tester.last_output.should =~
# /From: not.found.file.erb @ line 7 Cor#blimey!:/
# Object.remove_const(:Cor)
# end
# Now that we use stagger_output (paging output) we no longer get
# the "From: " line, as we output everything in one go (not separate output.puts)
# and so the user just gets a single `Error: Cannot open
# "not.found.file.erb" for reading.`
# which is good enough IMO. Unfortunately we can't test for it
# though, as we don't hook stdout.
#
# it 'should display a description and error if reading the file goes wrong' do
# class Cor
# def blimey!
# eval <<-END, binding, "not.found.file.erb", 7
# Pad.tester = pry_tester(binding)
# Pad.tester.eval('whereami')
# END
# end
# end
it 'should show code window (not just method source) if parameter passed to whereami' do
# proc { Cor.new.blimey! }.should.raise(MethodSource::SourceNotFoundError)
# Pad.tester.last_output.should =~
# /From: not.found.file.erb @ line 7 Cor#blimey!:/
# Object.remove_const(:Cor)
# end
it 'should show code window (not just method source) if parameter passed to whereami' do
class Cor
def blimey!
pry_eval(binding, 'whereami 3').should =~ /class Cor/
end
end
Cor.new.blimey!
Object.remove_const(:Cor)
end
it 'should show entire method when -m option used' do
old_size, Pry.config.default_window_size = Pry.config.default_window_size, 1
old_cutoff, Pry::Command::Whereami.method_size_cutoff = Pry::Command::Whereami.method_size_cutoff, 1
class Cor
def blimey!
@foo = 1
@bar = 2
pry_eval(binding, 'whereami -m')
end
end
Pry::Command::Whereami.method_size_cutoff, Pry.config.default_window_size = old_cutoff, old_size
result = Cor.new.blimey!
Object.remove_const(:Cor)
result.should =~ /def blimey/
end
it 'should show entire file when -f option used' do
class Cor
def blimey!
pry_eval(binding, 'whereami -f')
end
end
result = Cor.new.blimey!
Object.remove_const(:Cor)
result.should =~ /show entire file when -f option used/
end
describe "-c" do
it 'should show class when -c option used, and locate correct candidate' do
require 'fixtures/whereami_helper'
class Cor
def blimey!
pry_eval(binding, 'whereami 3').should =~ /class Cor/
pry_eval(binding, 'whereami -c')
end
end
Cor.new.blimey!
out = Cor.new.blimey!
Object.remove_const(:Cor)
out.should =~ /class Cor/
out.should =~ /blimey/
end
it 'should show entire method when -m option used' do
old_size, Pry.config.default_window_size = Pry.config.default_window_size, 1
old_cutoff, Pry::Command::Whereami.method_size_cutoff = Pry::Command::Whereami.method_size_cutoff, 1
it 'should show class when -c option used, and locate correct superclass' do
class Cor
def blimey!
1
2
pry_eval(binding, 'whereami -m').should =~ /def blimey/
pry_eval(binding, 'whereami -c')
end
end
Pry::Command::Whereami.method_size_cutoff, Pry.config.default_window_size = old_cutoff, old_size
Cor.new.blimey!
Object.remove_const(:Cor)
end
it 'should show entire file when -f option used' do
class Cor
def blimey!
1
2
pry_eval(binding, 'whereami -f').should =~ /show entire file when -f option used/
end
class Horse < Cor
def pig;end
end
Cor.new.blimey!
out = Horse.new.blimey!
Object.remove_const(:Cor)
Object.remove_const(:Horse)
out.should =~ /class Cor/
out.should =~ /blimey/
end
describe "-c" do
it 'should show class when -c option used, and locate correct candidate' do
require 'fixtures/whereami_helper'
# 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!
1
2
out = pry_eval(binding, 'whereami -c')
out.should =~ /class Cor/
out.should =~ /blimey/
end
def blimey;end
out = pry_eval(binding, 'whereami -c')
out.should =~ /class Cor/
out.should =~ /blimey/
end
Cor.new.blimey!
Object.remove_const(:Cor)
end
it 'should show class when -c option used, and locate correct superclass' do
class Cor
def blimey!
1
2
out = pry_eval(binding, 'whereami -c')
out.should =~ /class Cor/
out.should =~ /blimey/
end
end
class Horse < Cor
def pig;end
end
Horse.new.blimey!
Object.remove_const(:Cor)
Object.remove_const(:Horse)
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
out = pry_eval(binding, 'whereami -c')
out.should =~ /class Cor/
out.should =~ /blimey/
end
Object.remove_const(:Cor)
end
end
end
end
it 'should not show line numbers or marker when -n switch is used' do
class Cor
@ -206,11 +203,11 @@ describe "whereami" do
it 'should use Pry.config.default_window_size for window size when outside a method context' do
old_size, Pry.config.default_window_size = Pry.config.default_window_size, 1
:litella
:pig
_foo = :litella
_foo = :pig
out = pry_eval(binding, 'whereami')
:punk
:sanders
_foo = :punk
_foo = :sanders
out.should_not =~ /:litella/
out.should =~ /:pig/

View file

@ -3,21 +3,21 @@ require_relative '../helper'
describe 'Formatting Table' do
it 'knows about colorized fitting' do
t = Pry::Helpers::Table.new %w(hihi), :column_count => 1
t.fits_on_line?(4).should == true
t.fits_on_line?(4).should eq true
t.items = []
t.fits_on_line?(4).should == true
t.fits_on_line?(4).should eq true
t.items = %w(hi hi)
t.fits_on_line?(4).should == true
t.fits_on_line?(4).should eq true
t.column_count = 2
t.fits_on_line?(4).should == false
t.fits_on_line?(4).should eq false
t.items = %w(
a ccc
bb dddd
).sort
t.fits_on_line?(8).should == true
t.fits_on_line?(7).should == false
t.fits_on_line?(8).should eq true
t.fits_on_line?(7).should eq false
end
describe 'formatting - should order downward and wrap to columns' do
@ -25,7 +25,7 @@ describe 'Formatting Table' do
def try_round_trip(expected)
things = expected.split(/\s+/).sort
actual = Pry::Helpers.tablify(things, FAKE_COLUMNS).to_s.strip
[expected, actual].each{|e| e.gsub! /\s+$/, ''}
[expected, actual].each{|e| e.gsub!(/\s+$/, '')}
if actual != expected
bar = '-'*25
puts \
@ -34,7 +34,7 @@ describe 'Formatting Table' do
bar+'actual'+bar,
actual
end
actual.should == expected
actual.should eq expected
end
it 'should handle a tiny case' do
@ -94,11 +94,11 @@ asfadsssaaad fasfaafdssd s
it 'should format output as one column' do
table = Pry::Helpers.tablify(@out, @elem_len - 1).to_s
table.should == "swizzle\ncrime \nfun "
table.should eq "swizzle\ncrime \nfun "
end
end
specify 'decide between one-line or indented output' do
Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == "head: ing\n"
Pry::Helpers.tablify_or_one_line('head', %w(ing)).should eq "head: ing\n"
end
end

View file

@ -9,26 +9,26 @@ describe Pry::Method::Patcher do
end
it "should change the behaviour of the method" do
@x.test.should == :before
@x.test.should eq :before
@method.redefine "def @x.test; :after; end\n"
@x.test.should == :after
@x.test.should eq :after
end
it "should return a new method with new source" do
@method.source.strip.should == "def @x.test; :before; end"
@method.source.strip.should eq "def @x.test; :before; end"
@method.redefine("def @x.test; :after; end\n").
source.strip.should == "def @x.test; :after; end"
source.strip.should eq "def @x.test; :after; end"
end
it "should change the source of new Pry::Method objects" do
@method.redefine "def @x.test; :after; end\n"
Pry::Method(@x.method(:test)).source.strip.should == "def @x.test; :after; end"
Pry::Method(@x.method(:test)).source.strip.should eq "def @x.test; :after; end"
end
it "should preserve visibility" do
class << @x; private :test; end
@method.visibility.should == :private
@method.visibility.should eq :private
@method.redefine "def @x.test; :after; end\n"
Pry::Method(@x.method(:test)).visibility.should == :private
Pry::Method(@x.method(:test)).visibility.should eq :private
end
end

View file

@ -39,15 +39,15 @@ describe Pry::WrappedModule do
describe "number_of_candidates" do
it 'should return the correct number of candidates' do
Pry::WrappedModule(Host::CandidateTest).number_of_candidates.should == 3
Pry::WrappedModule(Host::CandidateTest).number_of_candidates.should eq 3
end
it 'should return 0 candidates for a class with no nested modules or methods' do
Pry::WrappedModule(Host::PitifullyBlank).number_of_candidates.should == 0
Pry::WrappedModule(Host::PitifullyBlank).number_of_candidates.should eq 0
end
it 'should return 1 candidate for a class with a nested module with methods' do
Pry::WrappedModule(Host::ForeverAlone).number_of_candidates.should == 1
Pry::WrappedModule(Host::ForeverAlone).number_of_candidates.should eq 1
end
end
@ -72,24 +72,24 @@ describe Pry::WrappedModule do
describe "source_location" do
it 'should return primary candidates source_location by default' do
wm = Pry::WrappedModule(Host::CandidateTest)
wm.source_location.should == wm.candidate(0).source_location
wm.source_location.should eq wm.candidate(0).source_location
end
it 'should return the location of the outer module if an inner module has methods' do
wm = Pry::WrappedModule(Host::ForeverAlone)
File.expand_path(wm.source_location.first).should eq File.expand_path(__FILE__)
wm.source_location.last.should == Host::FOREVER_ALONE_LINE
wm.source_location.last.should eq Host::FOREVER_ALONE_LINE
end
it 'should return nil if no source_location can be found' do
Pry::WrappedModule(Host::PitifullyBlank).source_location.should == nil
Pry::WrappedModule(Host::PitifullyBlank).source_location.should eq nil
end
end
describe "source" do
it 'should return primary candidates source by default' do
wm = Pry::WrappedModule(Host::CandidateTest)
wm.source.should == wm.candidate(0).source
wm.source.should eq wm.candidate(0).source
end
it 'should return source for highest ranked candidate' do
@ -106,14 +106,14 @@ describe Pry::WrappedModule do
it 'should return source for deeply nested class' do
Pry::WrappedModule(Host::ForeverAlone::DoublyNested::TriplyNested).source.should =~ /nested_method/
Pry::WrappedModule(Host::ForeverAlone::DoublyNested::TriplyNested).source.lines.count.should == 4
Pry::WrappedModule(Host::ForeverAlone::DoublyNested::TriplyNested).source.lines.count.should eq 4
end
end
describe "doc" do
it 'should return primary candidates doc by default' do
wm = Pry::WrappedModule(Host::CandidateTest)
wm.doc.should == wm.candidate(0).doc
wm.doc.should eq wm.candidate(0).doc
end
it 'should return doc for highest ranked candidate' do
@ -145,19 +145,19 @@ describe Pry::WrappedModule do
end
it "should return Foo# for normal classes" do
Pry::WrappedModule.new(Foo).method_prefix.should == "Foo#"
Pry::WrappedModule.new(Foo).method_prefix.should eq "Foo#"
end
it "should return Bar# for modules" do
Pry::WrappedModule.new(Kernel).method_prefix.should == "Kernel#"
Pry::WrappedModule.new(Kernel).method_prefix.should eq "Kernel#"
end
it "should return Foo. for singleton classes of classes" do
Pry::WrappedModule.new(class << Foo; self; end).method_prefix.should == "Foo."
Pry::WrappedModule.new(class << Foo; self; end).method_prefix.should eq "Foo."
end
example "of singleton classes of objects" do
Pry::WrappedModule.new(class << @foo; self; end).method_prefix.should == "self."
Pry::WrappedModule.new(class << @foo; self; end).method_prefix.should eq "self."
end
example "of anonymous classes should not be empty" do
@ -171,15 +171,15 @@ describe Pry::WrappedModule do
describe ".singleton_class?" do
it "should be true for singleton classes" do
Pry::WrappedModule.new(class << ""; self; end).singleton_class?.should == true
Pry::WrappedModule.new(class << ""; self; end).singleton_class?.should eq true
end
it "should be false for normal classes" do
Pry::WrappedModule.new(Class.new).singleton_class?.should == false
Pry::WrappedModule.new(Class.new).singleton_class?.should eq false
end
it "should be false for modules" do
Pry::WrappedModule.new(Module.new).singleton_class?.should == false
Pry::WrappedModule.new(Module.new).singleton_class?.should eq false
end
end
@ -205,25 +205,25 @@ describe Pry::WrappedModule do
end
it 'should return superclass for a wrapped class' do
Pry::WrappedModule(@c).super.wrapped.should == @b
Pry::WrappedModule(@c).super.wrapped.should eq @b
end
it 'should return nth superclass for a wrapped class' do
d = Class.new(@c)
Pry::WrappedModule(d).super(2).wrapped.should == @b
Pry::WrappedModule(d).super(2).wrapped.should eq @b
end
it 'should ignore modules when retrieving nth superclass' do
Pry::WrappedModule(@c).super(2).wrapped.should == @a
Pry::WrappedModule(@c).super(2).wrapped.should eq @a
end
it 'should return nil when no nth superclass exists' do
Pry::WrappedModule(@c).super(10).should == nil
Pry::WrappedModule(@c).super(10).should eq nil
end
it 'should return self when .super(0) is used' do
c = Pry::WrappedModule(@c)
c.super(0).should == c
c.super(0).should eq c
end
end
@ -235,16 +235,16 @@ describe Pry::WrappedModule do
end
it 'should not ignore modules when retrieving supers' do
Pry::WrappedModule(@m3).super.wrapped.should == @m2
Pry::WrappedModule(@m3).super.wrapped.should eq @m2
end
it 'should retrieve nth super' do
Pry::WrappedModule(@m3).super(2).wrapped.should == @m1
Pry::WrappedModule(@m3).super(2).wrapped.should eq @m1
end
it 'should return self when .super(0) is used' do
m = Pry::WrappedModule(@m1)
m.super(0).should == m
m.super(0).should eq m
end
end
end
@ -259,19 +259,19 @@ describe Pry::WrappedModule do
it 'should lookup a constant' do
m = Pry::WrappedModule.from_str("Namespace::Value", binding)
m.wrapped.should == Namespace::Value
m.wrapped.should eq Namespace::Value
end
it 'should lookup a local' do
local = Namespace::Value
m = Pry::WrappedModule.from_str("local", binding)
m.wrapped.should == local
m.wrapped.should eq local
end
it 'should lookup an ivar' do
@ivar = Namespace::Value
m = Pry::WrappedModule.from_str("@ivar", binding)
m.wrapped.should == Namespace::Value
m.wrapped.should eq Namespace::Value
end
end
end