Sha256: f757ef82dd4c3416e3c565310d7c4812b9278fc13f51ae5b1345514112aa0aff

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 KB

Contents

require File.dirname(__FILE__) + "/../../spec_helper.rb"
require 'rexml/document'

describe "Output capture" do
  before(:each) do
    @suite = CI::Reporter::TestSuite.new "test"
  end

  it "should save stdout and stderr messages written during the test run" do
    @suite.start
    puts "Hello"
    $stderr.print "Hi"
    @suite.finish
    @suite.stdout.should == "Hello\n"
    @suite.stderr.should == "Hi"
  end

  it "should include system-out and system-err elements in the xml output" do
    @suite.start
    puts "Hello"
    $stderr.print "Hi"
    @suite.finish

    root = REXML::Document.new(@suite.to_xml).root
    root.elements.to_a('//system-out').length.should == 1
    root.elements.to_a('//system-err').length.should == 1
    root.elements.to_a('//system-out').first.texts.first.to_s.strip.should == "Hello"
    root.elements.to_a('//system-err').first.texts.first.to_s.strip.should == "Hi"
  end

  it "should return $stdout and $stderr to original value after finish" do
    out, err = $stdout, $stderr
    @suite.start
    $stdout.object_id.should_not == out.object_id
    $stderr.object_id.should_not == err.object_id
    @suite.finish
    $stdout.object_id.should == out.object_id
    $stderr.object_id.should == err.object_id
  end

  it "should capture only during run of owner test suite" do
    $stdout.print "A"
    $stderr.print "A"
    @suite.start
    $stdout.print "B"
    $stderr.print "B"
    @suite.finish
    $stdout.print "C"
    $stderr.print "C"
    @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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ci_reporter-2.0.0.alpha2 spec/ci/reporter/output_capture_spec.rb
ci_reporter-2.0.0.alpha1 spec/ci/reporter/output_capture_spec.rb