From a8911dbbd7940da0eb1a8722a7c06cae38089dfe Mon Sep 17 00:00:00 2001 From: Holger Just Date: Fri, 10 Jul 2020 20:14:42 +0200 Subject: [PATCH] Fix Rackstash::Utils.clock_time on newer Windows versions --- spec/rackstash/utils_spec.rb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/spec/rackstash/utils_spec.rb b/spec/rackstash/utils_spec.rb index 3a8b9a9..b87fbed 100644 --- a/spec/rackstash/utils_spec.rb +++ b/spec/rackstash/utils_spec.rb @@ -63,17 +63,6 @@ RSpec.describe Rackstash::Utils do expect(described_class.clock_time).to be < described_class.clock_time end - context 'on Windows' do - it 'fetches the GetTickCount64 function' do - expect(described_class::GetTickCount64).to be_a Fiddle::Function - end - - it 'returns a float' do - expect(described_class::GetTickCount64).to receive(:call).and_call_original - expect(described_class.clock_time).to be_a(Float) - end - end if Gem.win_platform? - context 'without a monotonic clock' do around do |example| clock_monotic = ::Process.send(:remove_const, :CLOCK_MONOTONIC) @@ -89,10 +78,21 @@ RSpec.describe Rackstash::Utils do $VERBOSE = verbose end - it 'returns a float' do - expect(::Time).to receive(:now).and_call_original - expect(described_class.clock_time).to be_a Float + if Gem.win_platform? + it 'fetches the GetTickCount64 function' do + expect(described_class::GetTickCount64).to be_a Fiddle::Function + end + + it 'returns a float' do + expect(described_class::GetTickCount64).to receive(:call).and_call_original + expect(described_class.clock_time).to be_a(Float) + end + else + it 'returns a float' do + expect(::Time).to receive(:now).and_call_original + expect(described_class.clock_time).to be_a Float + end end - end unless Gem.win_platform? + end end end