spec/buildbox/buildbox/command_spec.rb in buildbox-0.0.2 vs spec/buildbox/buildbox/command_spec.rb in buildbox-0.0.3
- old
+ new
@@ -37,11 +37,11 @@
result.output.should =~ /(syntax|parse) error/i
end
it "can collect output in chunks" do
chunked_output = ''
- result = command.run('echo hello world') do |chunk|
+ result = command.run('echo hello world') do |result, chunk|
chunked_output += chunk
end
result.should be_success
result.output.should == 'hello world'
@@ -50,24 +50,26 @@
it "can collect chunks at paticular intervals" do
command = Buildbox::Command.new(nil, 0.1)
chunked_output = ''
- result = command.run('sleep 0.5; echo hello world') do |chunk|
+ result = command.run('sleep 0.5; echo hello world') do |result, chunk|
chunked_output += chunk
end
result.should be_success
result.output.should == 'hello world'
chunked_output.should == "hello world\r\n"
end
+ it 'passes a result object to the block'
+
it "can collect chunks from within a thread" do
chunked_output = ''
result = nil
worker_thread = Thread.new do
- result = command.run('echo before sleep; sleep 1; echo after sleep') do |chunk|
+ result = command.run('echo before sleep; sleep 1; echo after sleep') do |result, chunk|
chunked_output += chunk
end
end
worker_thread.run
@@ -101,10 +103,10 @@
second_result.output.should =~ /doesntexist.rb:.+not found/
end
it "captures color'd output" do
chunked_output = ''
- result = command.run("rspec #{FIXTURES_PATH.join('rspec', 'test_spec.rb')} --color") do |chunk|
+ result = command.run("rspec #{FIXTURES_PATH.join('rspec', 'test_spec.rb')} --color") do |result, chunk|
chunked_output += chunk
end
result.should be_success
result.output.should include("32m")