spec/lib/protobuf/rpc/stat_spec.rb in protobuffy-3.6.0 vs spec/lib/protobuf/rpc/stat_spec.rb in protobuffy-4.0.0

- old
+ new

@@ -1,15 +1,13 @@ require 'spec_helper' require 'timecop' require 'active_support/core_ext/numeric/time' -describe ::Protobuf::Rpc::Stat do +RSpec.describe ::Protobuf::Rpc::Stat do before(:all) do - unless defined?(BarService) - class BarService < ::Struct.new(:method_name); end - end + BarService = ::Struct.new(:method_name) unless defined?(BarService) end describe 'server mode' do it 'describes a server response to a client' do ::Timecop.freeze(10.minutes.ago) do @@ -19,22 +17,22 @@ stats.request_size = 43 stats.response_size = 1302 ::Timecop.freeze(1.62.seconds.from_now) do stats.stop - stats.to_s.should eq "[SRV] - myserver1 - #{stats.trace_id} - BarService#find_bars - 43B/1302B - 1.62s - #{::Time.now.iso8601}" + expect(stats.to_s).to eq "[SRV] - myserver1 - #{stats.trace_id} - BarService#find_bars - 43B/1302B - 1.62s - #{::Time.now.iso8601}" end end end context 'when request is still running' do it 'omits response size, duration, and timestamp' do stats = ::Protobuf::Rpc::Stat.new(:SERVER) stats.client = 'myserver1' stats.dispatcher = double('dispatcher', :service => BarService.new(:find_bars)) stats.request_size = 43 - stats.to_s.should eq "[SRV] - myserver1 - #{stats.trace_id} - BarService#find_bars - 43B/-" + expect(stats.to_s).to eq "[SRV] - myserver1 - #{stats.trace_id} - BarService#find_bars - 43B/-" end end end describe 'client mode' do @@ -47,11 +45,11 @@ stats.request_size = 37 stats.response_size = 12345 ::Timecop.freeze(0.832.seconds.from_now) do stats.stop - stats.to_s.should eq "[CLT] - myserver1.myhost.com:30000 - #{stats.trace_id} - Foo::BarService#find_bars - 37B/12345B - 0.832s - #{::Time.now.iso8601}" + expect(stats.to_s).to eq "[CLT] - myserver1.myhost.com:30000 - #{stats.trace_id} - Foo::BarService#find_bars - 37B/12345B - 0.832s - #{::Time.now.iso8601}" end end end @@ -60,11 +58,11 @@ stats = ::Protobuf::Rpc::Stat.new(:CLIENT) stats.server = ['30000', 'myserver1.myhost.com'] stats.service = 'Foo::BarService' stats.method_name = 'find_bars' stats.request_size = 37 - stats.to_s.should eq "[CLT] - myserver1.myhost.com:30000 - #{stats.trace_id} - Foo::BarService#find_bars - 37B/-" + expect(stats.to_s).to eq "[CLT] - myserver1.myhost.com:30000 - #{stats.trace_id} - Foo::BarService#find_bars - 37B/-" end end end describe "statsd_base_path" do @@ -99,10 +97,10 @@ subject(:stop) { stats.stop } context "when statsd_client hasn't been set" do it "should not raise" do - expect{ stop }.not_to raise_error + expect { stop }.not_to raise_error end end context "when statsd_client has been set" do let(:statsd_client) { double("Statsd::Client") }