diff options
Diffstat (limited to 'spec/ruby/core/time/shared/now.rb')
| -rw-r--r-- | spec/ruby/core/time/shared/now.rb | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/spec/ruby/core/time/shared/now.rb b/spec/ruby/core/time/shared/now.rb index d8e5ac9d50..839cfdcd2a 100644 --- a/spec/ruby/core/time/shared/now.rb +++ b/spec/ruby/core/time/shared/now.rb @@ -2,8 +2,8 @@ require_relative '../fixtures/classes' describe :time_now, shared: true do it "creates a subclass instance if called on a subclass" do - TimeSpecs::SubTime.send(@method).should be_an_instance_of(TimeSpecs::SubTime) - TimeSpecs::MethodHolder.send(@method).should be_an_instance_of(Time) + TimeSpecs::SubTime.send(@method).should.instance_of?(TimeSpecs::SubTime) + TimeSpecs::MethodHolder.send(@method).should.instance_of?(Time) end it "sets the current time" do @@ -18,18 +18,16 @@ describe :time_now, shared: true do end end - guard_not -> { platform_is :windows and ruby_version_is ""..."2.5" } do - it "has at least microsecond precision" do - times = [] - 10_000.times do - times << Time.now.nsec - end - - # The clock should not be less accurate than expected (times should - # not all be a multiple of the next precision up, assuming precisions - # are multiples of ten.) - expected = 1_000 - times.select { |t| t % (expected * 10) == 0 }.size.should_not == times.size + it "has at least microsecond precision" do + # The clock should not be less accurate than expected (times should + # not all be a multiple of the next precision up, assuming precisions + # are multiples of ten.) + expected = 1_000 + t = 0 + 10_000.times.find do + t = Time.now.nsec + t % (expected * 10) != 0 end + (t % (expected * 10)).should != 0 end end |
