spec/em-systemcommand/pipe_spec.rb in em-systemcommand-0.0.5 vs spec/em-systemcommand/pipe_spec.rb in em-systemcommand-1.0.0

- old
+ new

@@ -3,11 +3,11 @@ describe 'Pipe' do context '#receive_data' do it 'should correctly do a carriage return in the output buffer' do EM.run do - EM::SystemCommand.new %q{ruby -e '$stdout.sync = true; print "12345\r"; puts "321"; print "123"; print "\r3210"; exit 0;'} do |on| + EM::SystemCommand.execute %q{ruby -e '$stdout.sync = true; print "12345\r"; puts "321"; print "123"; print "\r3210"; exit 0;'} do |on| on.success do |process| EM.stop_event_loop process.stdout.output.should == "32145\n3210" end end @@ -18,11 +18,11 @@ context '#data callback' do it 'should be called on data' do received = [] EM.run do - EM::SystemCommand.new %q{echo -n "123123";} do |on| + EM::SystemCommand.execute %q{echo -n "123123";} do |on| on.stdout.data do |data| received << data end on.success do @@ -34,11 +34,11 @@ end it 'should be called once even when there is a linebreak' do received = [] EM.run do - EM::SystemCommand.new %Q{echo "123\n456"} do |on| + EM::SystemCommand.execute %Q{echo "123\n456"} do |on| on.stdout.data do |data| received << data end on.success do @@ -53,11 +53,11 @@ context '#line callback' do it 'should be called on readline' do received = [] EM.run do - EM::SystemCommand.new 'echo "123"; echo "456"' do |on| + EM::SystemCommand.execute 'echo "123"; echo "456"' do |on| on.stdout.line do |data| received << data end on.success do @@ -69,11 +69,11 @@ end it 'should be called on carriage return' do received = [] EM.run do - EM::SystemCommand.new %q{ruby -e '$stdout.sync = true; print "123\r"; print "456\r"; exit 0;'} do |on| + EM::SystemCommand.execute %q{ruby -e '$stdout.sync = true; print "123\r"; print "456\r"; exit 0;'} do |on| on.stdout.line do |data| received << data end on.success do @@ -89,11 +89,11 @@ context '#update callback' do it 'should be called on receive data' do received = [] EM.run do - EM::SystemCommand.new %q{ruby -e '$stdout.sync = true; puts "123"; puts "456"; exit 0'} do |on| + EM::SystemCommand.execute %q{ruby -e '$stdout.sync = true; puts "123"; puts "456"; exit 0'} do |on| on.stdout.update do |data| received << data end on.success do @@ -105,11 +105,11 @@ end it 'should be called on carriage return'do received = [] EM.run do - EM::SystemCommand.new %q{ruby -e '$stdout.sync = true; print "123\r"; sleep 0.1; print "456\r"; exit 0;'} do |on| + EM::SystemCommand.execute %q{ruby -e '$stdout.sync = true; print "123\r"; sleep 0.1; print "456\r"; exit 0;'} do |on| on.stdout.update do |data| received << data end on.success do @@ -125,11 +125,11 @@ context '#match callback' do it 'should match in lines on receive_line' do received = [] EM.run do - EM::SystemCommand.new 'echo "-123-"; echo "-456-"' do |on| + EM::SystemCommand.execute 'echo "-123-"; echo "-456-"' do |on| on.stdout.match /-([0-9]+)-/, in: :line do |match, number| received << number end on.success do @@ -141,10 +141,10 @@ end it 'should match in output buffer on receive_update' do received = [] EM.run do - EM::SystemCommand.new %q{ruby -e '$stdout.sync = true; print "-123-\r"; sleep 0.1; print "-456-\r"; exit 0'} do |on| + EM::SystemCommand.execute %q{ruby -e '$stdout.sync = true; print "-123-\r"; sleep 0.1; print "-456-\r"; exit 0'} do |on| on.stdout.match /-([0-9]+)-/, in: :output do |match, number| received << number end on.success do