Sha256: 7b3bac7bc91268cebfd6446615a0bbddb0179fbc040ffaa03247b85b64d15fb2

Contents?: true

Size: 1.66 KB

Versions: 14

Compression:

Stored size: 1.66 KB

Contents

# (c) Copyright 2006-2007 Nick Sieger <nicksieger@gmail.com>
# See the file LICENSE.txt included with the distribution for
# software license details.

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.cdatas.first.to_s.should == "Hello\n"
    root.elements.to_a('//system-err').first.cdatas.first.to_s.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
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
GICodeWarrior-ci_reporter-1.6.1 spec/ci/reporter/output_capture_spec.rb
GICodeWarrior-ci_reporter-1.6.2 spec/ci/reporter/output_capture_spec.rb
schubert-ci_reporter-1.6.2 spec/ci/reporter/output_capture_spec.rb
schubert-ci_reporter-1.6.1 spec/ci/reporter/output_capture_spec.rb
ci_reporter-1.3.5 spec/ci/reporter/output_capture_spec.rb
ci_reporter-1.4 spec/ci/reporter/output_capture_spec.rb
ci_reporter-1.5 spec/ci/reporter/output_capture_spec.rb
ci_reporter-1.5.2 spec/ci/reporter/output_capture_spec.rb
ci_reporter-1.5.3 spec/ci/reporter/output_capture_spec.rb
ci_reporter-1.6.0 spec/ci/reporter/output_capture_spec.rb
ci_reporter-1.5.1 spec/ci/reporter/output_capture_spec.rb
ci_reporter-1.3.2 spec/ci/reporter/output_capture_spec.rb
ci_reporter-1.3.3 spec/ci/reporter/output_capture_spec.rb
ci_reporter-1.3.4 spec/ci/reporter/output_capture_spec.rb