Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Concurrent.monotonic_time accept an optional unit parameter
This is a direct transposition of MRI's `clock_gettime` unit option.
- Loading branch information
Showing
2 changed files
with
70 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module Concurrent | ||
|
||
RSpec.describe :monotonic_time do | ||
context 'behavior' do | ||
|
||
it 'returns seconds as float' do | ||
expect(Concurrent.monotonic_time).to be_a(Float) | ||
end | ||
|
||
%i(float_second float_millisecond float_microsecond).each do |unit| | ||
it "returns a Float when unit = #{unit.inspect}" do | ||
expect(Concurrent.monotonic_time(unit)).to be_a(Float) | ||
end | ||
end | ||
|
||
%i(second millisecond microsecond nanosecond).each do |unit| | ||
it "returns an Integer when unit = #{unit.inspect}" do | ||
expect(Concurrent.monotonic_time(unit)).to be_an(Integer) | ||
end | ||
end | ||
|
||
it 'raises ArgumentError on unknown units' do | ||
expect { | ||
Concurrent.monotonic_time(:foo) | ||
}.to raise_error(ArgumentError) | ||
end | ||
|
||
end | ||
end | ||
end |