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

Update specs using yield matcher

This commit is contained in:
Christian Haase 2014-09-12 17:55:59 +02:00 committed by Ryan Fitzgerald
parent 5b12626a41
commit 72b486f43b
2 changed files with 29 additions and 31 deletions

View file

@ -48,11 +48,10 @@ describe Pry::CommandSet do
end end
it 'should pass arguments of the command to the block' do it 'should pass arguments of the command to the block' do
@set.command 'foo' do |*args| expect { |probe|
args.should == [1, 2, 3] @set.command('foo', &probe)
end @set.run_command(@ctx, 'foo', 1, 2, 3)
}.to yield_with_args(1, 2, 3)
@set.run_command @ctx, 'foo', 1, 2, 3
end end
it 'should use the first argument as context' do it 'should use the first argument as context' do

View file

@ -301,53 +301,52 @@ describe "Pry::Command" do
describe 'tokenize' do describe 'tokenize' do
it 'should interpolate string with #{} in them' do it 'should interpolate string with #{} in them' do
cmd = @set.command 'random-dent' do |*args| expect { |probe|
args.should == ["3", "8"] cmd = @set.command('random-dent', &probe)
end
foo = 5 foo = 5
cmd.new(:target => binding).process_line 'random-dent #{1 + 2} #{3 + foo}'
cmd.new(:target => binding).process_line 'random-dent #{1 + 2} #{3 + foo}' }.to yield_with_args('3', '8')
end end
it 'should not fail if interpolation is not needed and target is not set' do it 'should not fail if interpolation is not needed and target is not set' do
cmd = @set.command 'the-book' do |*args| expect { |probe|
args.should == ['--help'] cmd = @set.command('the-book', &probe)
end
cmd.new.process_line 'the-book --help' cmd.new.process_line 'the-book --help'
}.to yield_with_args('--help')
end end
it 'should not interpolate commands with :interpolate => false' do it 'should not interpolate commands with :interpolate => false' do
cmd = @set.command 'thor', 'norse god', :interpolate => false do |*args| expect { |probe|
args.should == ['%(#{foo})'] cmd = @set.command('thor', 'norse god', :interpolate => false, &probe)
end
cmd.new.process_line 'thor %(#{foo})' cmd.new.process_line 'thor %(#{foo})'
}.to yield_with_args('%(#{foo})')
end end
it 'should use shell-words to split strings' do it 'should use shell-words to split strings' do
cmd = @set.command 'eccentrica' do |*args| expect { |probe|
args.should == ['gallumbits', 'eroticon', '6'] cmd = @set.command('eccentrica', &probe)
end
cmd.new.process_line %(eccentrica "gallumbits" 'erot''icon' 6) cmd.new.process_line %(eccentrica "gallumbits" 'erot''icon' 6)
}.to yield_with_args('gallumbits', 'eroticon', '6')
end end
it 'should split on spaces if shellwords is not used' do it 'should split on spaces if shellwords is not used' do
cmd = @set.command 'bugblatter-beast', 'would eat its grandmother', :shellwords => false do |*args| expect { |probe|
args.should == ['"of', 'traal"'] cmd = @set.command('bugblatter-beast', 'would eat its grandmother', :shellwords => false, &probe)
end
cmd.new.process_line %(bugblatter-beast "of traal") cmd.new.process_line %(bugblatter-beast "of traal")
}.to yield_with_args('"of', 'traal"')
end end
it 'should add captures to arguments for regex commands' do it 'should add captures to arguments for regex commands' do
cmd = @set.command /perfectly (normal)( beast)?/i do |*args| expect { |probe|
args.should == ['Normal', ' Beast', '(honest!)'] cmd = @set.command(/perfectly (normal)( beast)?/i, &probe)
end
cmd.new.process_line %(Perfectly Normal Beast (honest!)) cmd.new.process_line %(Perfectly Normal Beast (honest!))
}.to yield_with_args('Normal', ' Beast', '(honest!)')
end end
end end