Sha256: 2ace3d7e70530acb48179ebbc8cf38739a7854f5e125f61c2c81640be578ac0c
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
# encoding: UTF-8 require 'spec_helper' include Rosette::Core describe PrintingErrorReporter do class Collector attr_reader :messages def initialize @messages = [] end def write(message) @messages << message end end let(:error) do begin raise StandardError, 'jelly beans' rescue => e e end end let(:collector) { Collector.new } let(:reporter) { PrintingErrorReporter.new(collector) } let(:options) { { foo: 'bar' } } describe '#report_error' do it 'prints the error message' do reporter.report_error(error, options) expect(collector.messages.size).to eq(1) expect(collector.messages).to include("jelly beans\n") end context 'with a reporter that prints a stack trace' do let(:reporter) do PrintingErrorReporter.new( collector, print_stack_trace: true ) end it 'prints a stack trace along with the error message' do reporter.report_error(error, options) expect(collector.messages).to include("jelly beans\n") expect(collector.messages).to include(options.inspect) expect(collector.messages.size).to be > 1 trace_message = collector.messages.find do |message| message =~ /printing_error_reporter_spec.rb:[\d]+/ end expect(trace_message).to_not be_nil end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rosette-core-1.0.1 | spec/core/error_reporters/printing_error_reporter_spec.rb |