Sha256: 3f4affecd9fa924622ae3f83779e11caeac183e7395bf3986693cbd1342f142f
Contents?: true
Size: 1.37 KB
Versions: 18
Compression:
Stored size: 1.37 KB
Contents
# frozen_string_literal: true # encoding: utf-8 require 'spec_helper' describe Mongo::Server::RoundTripTimeAverager do let(:averager) { Mongo::Server::RoundTripTimeAverager.new } describe '#update_average_round_trip_time' do context 'no existing average rtt' do it 'updates average rtt' do averager.instance_variable_set('@last_round_trip_time', 5) averager.send(:update_average_round_trip_time) expect(averager.average_round_trip_time).to eq(5) end end context 'with existing average rtt' do it 'averages with existing average rtt' do averager.instance_variable_set('@last_round_trip_time', 5) averager.instance_variable_set('@average_round_trip_time', 10) averager.send(:update_average_round_trip_time) expect(averager.average_round_trip_time).to eq(9) end end end describe '#measure' do context 'block does not raise' do it 'updates average rtt' do expect(averager).to receive(:update_average_round_trip_time) averager.measure do end end end context 'block raises' do it 'does not update average rtt' do expect(averager).not_to receive(:update_average_round_trip_time) lambda do averager.measure do raise "Problem" end end.should raise_error(/Problem/) end end end end
Version data entries
18 entries across 18 versions & 1 rubygems