spec/streamingly/serde_iterable_spec.rb in streamingly-0.2.6 vs spec/streamingly/serde_iterable_spec.rb in streamingly-0.2.7
- old
+ new
@@ -1,7 +1,13 @@
require 'spec_helper'
+class TestErrorHandler
+ def on_error(error, context)
+ nil
+ end
+end
+
describe Streamingly::SerDeIterable do
let(:iterable) { [1] }
let(:error) { StandardError.new('error') }
before do
@@ -15,10 +21,10 @@
expect { subject.each }.to raise_error(StandardError)
end
end
describe 'given custom error handler' do
- let(:error_handler) { double(:error_handler, respond_to?: true) }
+ let(:error_handler) { TestErrorHandler.new }
subject { described_class.new(iterable, error_handler) }
it 'calls on_error method of provided handler' do
expect(error_handler).to receive(:on_error).with(error, line: 1)
expect { subject.each }.to_not raise_error