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

Don't show result of evaluating comments.

This commit is contained in:
Conrad Irwin 2012-10-20 22:54:58 -07:00
parent 64b3703a54
commit 46b6825301
2 changed files with 24 additions and 1 deletions

View file

@ -309,7 +309,9 @@ class Pry
end
end
@suppress_output = true if eval_string =~ /;\Z/ || eval_string.empty?
if eval_string =~ /;\Z/ || eval_string.empty? || eval_string =~ /\A *#.*\n\z/
@suppress_output = true
end
exec_hook :after_read, eval_string, self
eval_string

View file

@ -38,4 +38,25 @@ describe Pry do
mock_pry("class NastyClass; undef pretty_inspect; end", "NastyClass.new").should =~ /#<NastyClass:0x.*?>/
end
end
describe "output suppression" do
before do
@t = pry_tester
end
it "should normally output the result" do
mock_pry("1 + 2").should == "=> 3\n\n"
end
it "should not output anything if the input ends with a semicolon" do
mock_pry("1 + 2;").should == "\n"
end
it "should output something if the input ends with a comment" do
mock_pry("1 + 2 # basic addition").should == "=> 3\n\n"
end
it "should not output something if the input is only a comment" do
mock_pry("# basic addition").should == "\n"
end
end
end