mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
added more tests for command interpolation, esp. regarding regex commands. bumped version to pre3
This commit is contained in:
parent
444ea2e79a
commit
0610764e86
2 changed files with 54 additions and 1 deletions
|
@ -1,3 +1,3 @@
|
|||
class Pry
|
||||
VERSION = "0.9.0pre2"
|
||||
VERSION = "0.9.0pre3"
|
||||
end
|
||||
|
|
|
@ -119,6 +119,59 @@ describe "Pry::CommandProcessor" do
|
|||
pos.should == command.name.length
|
||||
end
|
||||
|
||||
it 'should correctly match a regex command and interpolation should not break the regex' do
|
||||
regex_command_name = /blah(\d)/
|
||||
@pry.commands.command(regex_command_name) {}
|
||||
|
||||
sample_text = "blah5"
|
||||
a = "5"
|
||||
command, captures, pos = @command_processor.command_matched 'blah#{a}', binding
|
||||
|
||||
command.name.should == regex_command_name
|
||||
captures.should == ["5"]
|
||||
pos.should == sample_text.size
|
||||
end
|
||||
|
||||
it 'should NOT match a regex command that is interpolated when :interpolate => false' do
|
||||
regex_command_name = /blah(\d)/
|
||||
@pry.commands.command(regex_command_name, "", :interpolate => false) {}
|
||||
|
||||
sample_text = "blah5"
|
||||
a = "5"
|
||||
command, captures, pos = @command_processor.command_matched 'blah#{a}', binding
|
||||
|
||||
command.should == nil
|
||||
end
|
||||
|
||||
it 'should correctly match a regex command and interpolation should not break the regex where entire regex command is interpolated' do
|
||||
regex_command_name = /blah(\d)/
|
||||
@pry.commands.command(regex_command_name) {}
|
||||
|
||||
sample_text = "blah5"
|
||||
a = "bl"
|
||||
b = "ah"
|
||||
c = "5"
|
||||
|
||||
command, captures, pos = @command_processor.command_matched '#{a}#{b}#{c}', binding
|
||||
|
||||
command.name.should == regex_command_name
|
||||
captures.should == ["5"]
|
||||
pos.should == sample_text.size
|
||||
end
|
||||
|
||||
it 'should NOT match a regex command where entire regex command is interpolated and :interpolate => false' do
|
||||
regex_command_name = /blah(\d)/
|
||||
@pry.commands.command(regex_command_name, "", :interpolate => false) {}
|
||||
|
||||
sample_text = "blah5"
|
||||
a = "bl"
|
||||
b = "ah"
|
||||
c = "5"
|
||||
|
||||
command, captures, pos = @command_processor.command_matched '#{a}#{b}#{c}', binding
|
||||
command.should == nil
|
||||
end
|
||||
|
||||
it 'should NOT match a command whose name is interpolated when :interpolate => false' do
|
||||
@pry.commands.command("boast", "", :interpolate => false) {}
|
||||
a = "boa"
|
||||
|
|
Loading…
Reference in a new issue