mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
return false from #piping? when $stdout is not an IO.
This commit is contained in:
parent
9a350dbf6c
commit
c27fe9c04d
2 changed files with 13 additions and 3 deletions
|
@ -219,7 +219,8 @@ class Pry
|
|||
# # `piping?` returns `true`
|
||||
# % pry | tee log
|
||||
def piping?
|
||||
!($stdout.respond_to?(:tty?) and $stdout.tty?) && $stdin.tty? && !Pry::Helpers::BaseHelpers.windows?
|
||||
return false unless $stdout.respond_to?(:tty?)
|
||||
!$stdout.tty? && $stdin.tty? && !Pry::Helpers::BaseHelpers.windows?
|
||||
end
|
||||
|
||||
# @return [void]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
require_relative 'helper'
|
||||
|
||||
describe "The whole thing" do
|
||||
describe Pry::REPL do
|
||||
it "should let you run commands in the middle of multiline expressions" do
|
||||
ReplTester.start do
|
||||
input 'def a'
|
||||
|
@ -112,4 +111,14 @@ describe "The whole thing" do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#piping?" do
|
||||
it "returns false when $stdout is a non-IO object" do
|
||||
repl = described_class.new(Pry.new, {})
|
||||
old_stdout = $stdout
|
||||
$stdout = Class.new { def write(*) end }.new
|
||||
expect(repl.send(:piping?)).to eq(false)
|
||||
$stdout = old_stdout
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue