mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
other tests passing: commands
This commit is contained in:
parent
329f49afa1
commit
12758922e8
2 changed files with 37 additions and 11 deletions
43
test/test.rb
43
test/test.rb
|
@ -88,7 +88,7 @@ describe Pry do
|
||||||
|
|
||||||
describe "nesting" do
|
describe "nesting" do
|
||||||
it 'should nest properly' do
|
it 'should nest properly' do
|
||||||
Pry.input = InputTester.new("pry", "pry", "pry", "\"nest:\#\{Pry.nesting.level\}\"", "exit", "exit", "exit", "exit")
|
Pry.input = InputTester.new("pry", "pry", "pry", "\"nest:\#\{Pry.nesting.level\}\"", "exit_all")
|
||||||
|
|
||||||
str_output = StringIO.new
|
str_output = StringIO.new
|
||||||
Pry.output = Pry::Output.new(str_output)
|
Pry.output = Pry::Output.new(str_output)
|
||||||
|
@ -104,16 +104,40 @@ describe Pry do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# describe "commands" do
|
describe "commands" do
|
||||||
# before do
|
after do
|
||||||
# Pry.input = InputTester.new("exit")
|
Pry.reset_defaults
|
||||||
|
end
|
||||||
|
|
||||||
# Pry.output = OutputTester.new
|
it 'should run command1' do
|
||||||
# end
|
pry_tester = Pry.new
|
||||||
|
pry_tester.commands = CommandTester.new
|
||||||
|
pry_tester.input = InputTester.new("command1", "exit_all")
|
||||||
|
pry_tester.commands = CommandTester.new
|
||||||
|
|
||||||
|
str_output = StringIO.new
|
||||||
|
pry_tester.output = Pry::Output.new(str_output)
|
||||||
|
|
||||||
|
pry_tester.rep
|
||||||
|
|
||||||
|
str_output.string.should =~ /command1/
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should run command2' do
|
||||||
|
pry_tester = Pry.new
|
||||||
|
pry_tester.commands = CommandTester.new
|
||||||
|
pry_tester.repl
|
||||||
|
pry_tester.input = InputTester.new("command2 horsey", "exit_all")
|
||||||
|
pry_tester.commands = CommandTester.new
|
||||||
|
|
||||||
|
str_output = StringIO.new
|
||||||
|
pry_tester.output = Pry::Output.new(str_output)
|
||||||
|
|
||||||
|
pry_tester.rep
|
||||||
|
|
||||||
|
str_output.string.should =~ /horsey/
|
||||||
|
end
|
||||||
|
|
||||||
# after do
|
|
||||||
# Pry.reset_defaults
|
|
||||||
# end
|
|
||||||
|
|
||||||
# commands = {
|
# commands = {
|
||||||
# "!" => "refresh",
|
# "!" => "refresh",
|
||||||
|
@ -184,3 +208,4 @@ describe Pry do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -21,10 +21,11 @@ end
|
||||||
class CommandTester
|
class CommandTester
|
||||||
def commands
|
def commands
|
||||||
@commands ||= {
|
@commands ||= {
|
||||||
"command1" => proc { |opts| opts[:output].puts "command1" },
|
"command1" => proc { |opts| opts[:output].puts "command1"; opts[:val].clear },
|
||||||
/command2\s*(.+)/ => proc do |opts|
|
/command2\s*(.*)/ => proc do |opts|
|
||||||
arg = opts[:captures].first
|
arg = opts[:captures].first
|
||||||
opts[:output].puts arg
|
opts[:output].puts arg
|
||||||
|
opts[:val].clear
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue