Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 194d5ba76d
Fetching contributors…

Cannot retrieve contributors at this time

60 lines (50 sloc) 1.622 kb
require "spec_helper"
require "rbconfig"
describe ITunes::Store::Transporter::Shell do
it "yields stdout and stderr as they become available" do
ruby = File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"])
temp = Tempfile.new ""
# sleep else poll() (select) can favor the 1st FD in the read array, causing the
# test to fail on some platforms
temp.write(<<-CODE)
$stdout.puts "OUT 1"
$stdout.flush
sleep 1
$stderr.puts "ERR 1"
$stderr.flush
sleep 1
$stdout.puts "OUT 2"
$stdout.flush
sleep 1
$stderr.puts "ERR 2"
CODE
temp.flush
output = []
expect = [ [ :stdout, "OUT 1" ],
[ :stderr, "ERR 1" ],
[ :stdout, "OUT 2" ],
[ :stderr, "ERR 2" ] ]
described_class.new(ruby).exec([temp.path]) do |line, stream|
output << [ stream, line.chomp! ]
end
output.should == expect
end
describe "#exec" do
it "requires a block" do
lambda { described_class.new.exec([]) }.should raise_exception(ArgumentError, "block required")
end
end
context "when on Windows" do
before(:all) { ENV["PROGRAMFILES"] = "C:\\" }
it "selects the Windows executable" do
described_class.stub(:windows? => true)
described_class.new.path.should match /#{described_class::WINDOWS_EXE}\Z/
end
end
context "when on anything but Windows" do
it "selects the right executable" do
described_class.stub(:windows? => false)
described_class.new.path.should match /#{described_class::EXE_NAME}\Z/
end
end
end
Jump to Line
Something went wrong with that request. Please try again.