Sha256: d5fdc61f62ef010fdb9c3925e80cb1fa3985f28751e21234f79b2ea793022239
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
# encoding: UTF-8 require 'spec_helper' include Rosette::Core describe BufferedErrorReporter do let(:error) { StandardError.new('jelly beans') } let(:options) { { foo: 'bar' } } let(:reporter) { BufferedErrorReporter.new } describe '#report_error' do it 'should log each error' do reporter.report_error(error, options) expect(reporter.errors.size).to eq(1) reporter.errors.first.tap do |err| expect(err.keys).to eq([:error, :options]) expect(err[:error]).to eq(error) expect(err[:options]).to eq(options) end end end context 'with a reported error' do before(:each) do reporter.report_error(error, options) end describe '#reset' do it 'should clear the error list' do reporter.reset expect(reporter.errors).to be_empty end end describe '#errors_found?' do it 'returns true if errors have been reported, false otherwise' do expect(reporter.errors_found?).to be_truthy reporter.reset expect(reporter.errors_found?).to be_falsey end end describe '#each_error' do it 'yields each error if given a block' do reporter.each_error do |cur_error, opts| expect(cur_error).to eq(error) expect(opts).to eq(options) end end it 'returns an enumerator if not given a block' do reporter.each_error.tap do |enum| expect(enum).to be_a(Enumerator) expect(enum.to_a).to include([error, options]) end 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/buffered_error_reporter_spec.rb |