Fixed failing spec plus fixed bug when calling system commands through back-ticks #56

Merged
merged 2 commits into from Nov 30, 2012
View
2 lib/ci/reporter/test_suite.rb
@@ -29,7 +29,7 @@ def capture(io, &assign)
@delegate_io = io
@captured_io = StringIO.new
@assign_block = assign
- @assign_block.call self
+ @assign_block.call @captured_io
end
# Finalize the capture and reset to the original IO object.
View
7 spec/ci/reporter/output_capture_spec.rb
@@ -54,4 +54,11 @@
@suite.stdout.should == "B"
@suite.stderr.should == "B"
end
+
+ it "should not barf when commands are executed with back-ticks" do
+ @suite.start
+ `echo "B"`
+ @suite.finish
+ end
+
end
View
5 spec/ci/reporter/report_manager_spec.rb
@@ -40,10 +40,11 @@
it "should shorten extremely long report filenames" do
reporter = CI::Reporter::ReportManager.new("spec")
suite = mock("test suite")
- suite.should_receive(:name).and_return("some test suite name that goes on and on and on and on and on and on and does not look like it will end any time soon and just when you think it is almost over it just continues to go on and on and on and on and on until it is almost over but wait there is more and then el fin")
+ very_long_name = "some test suite name that goes on and on and on and on and on and on and does not look like it will end any time soon and just when you think it is almost over it just continues to go on and on and on and on and on until it is almost over but wait there is more and then el fin"
+ suite.should_receive(:name).and_return(very_long_name)
suite.should_receive(:to_xml).and_return("<xml></xml>")
reporter.write_report(suite)
- filename = "#{REPORTS_DIR}/SPEC-some-test-suite-name-that-goes-on-and-on-and-on-and-on-and-on-and-on-and-does-not-look-like-it-will-end-any-time-soon-and-just-when-you-think-it-is-almost-over-it-just-continues-t.xml"
+ filename = "#{REPORTS_DIR}/SPEC-#{very_long_name}"[0..CI::Reporter::ReportManager::MAX_FILENAME_SIZE].gsub(/\s/, '-') + ".xml"
File.exist?(filename).should be_true
File.open(filename) {|f| f.read.should == "<xml></xml>"}
end