# Copyright (C) 2011-2012 RightScale, Inc, All Rights Reserved Worldwide. # # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use, # reproduction, modification, or disclosure of this program is # strictly prohibited. Any use of this program by an authorized # licensee is strictly subject to the terms and conditions, # including confidentiality obligations, set forth in the applicable # License Agreement between RightScale.com, Inc. and # the licensee require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) describe RightConf::BaseReporter do before(:each) do @written = nil @reporter = RightConf::BaseReporter.new flexmock(@reporter).should_receive(:write).and_return { |t| @written = t } end it 'should report standard messages' do @reporter.report('42') @written.should == @reporter.send(:format_message, '42') @reporter.report_message('43') @written.should == @reporter.send(:format_message, '43') end it 'should report new sections' do @reporter.report_section('42') @written.should == @reporter.send(:format_section, '42') end it 'should report errors' do @reporter.report_error('42') @written.should == @reporter.send(:format_error, '42') end it 'should report checks' do @reporter.report_check('42') @written.should == @reporter.send(:format_check, '42') end it 'should report success' do @reporter.report_success @written.should == @reporter.send(:format_success) @written = nil @reporter.report_result(true) @written.should == @reporter.send(:format_success) end it 'should report failures' do @reporter.report_failure @written.should == @reporter.send(:format_failure) @written = nil @reporter.report_result(false) @written.should == @reporter.send(:format_failure) end it 'should report fatal' do exception = nil begin @reporter.report_fatal('42') rescue Exception => e exception = e end @written.should == @reporter.send(:format_fatal, '42') exception.should_not be_nil exception.class.should == SystemExit exception.message.should == 'exit' end it 'should raise NoMethodError when using a wrong report method' do exception = nil begin @reporter.report_something_that_does_no_exist rescue Exception => e exception = e end exception.should_not be_nil exception.class.should == NoMethodError end end