Add spec

parent c7b4adfb
......@@ -370,12 +370,15 @@ module Pod
# Pipes all output inside given block to a pager.
#
# @yield Code block in which inputs to {#puts} and {#print} methods will be printed to the piper.
#
def with_pager
IO.popen((ENV['PAGER'] || 'less -R'), 'w') do |io|
Signal.trap('INT','IGNORE')
Signal.trap('INT', 'IGNORE')
UI.output_io = io
yield
end
UI.output_io = nil
end
private
......
......@@ -26,6 +26,18 @@ module Pod
# TODO
end
describe '#with_pager' do
it 'sets output_io' do
fd = IO.sysopen('/dev/null', 'w')
io = IO.new(fd)
IO.stubs(:popen).yields(io)
UI.with_pager do
UI.output_io.should == io
end
UI.output_io.should.be.nil
end
end
describe '#labeled' do
it 'prints nothing if value is nil' do
UI.labeled('label', nil)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment