Skip to content

Commit

Permalink
issue #510: use subject in monotonic_time_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinDKelley committed Dec 31, 2020
1 parent e2a20e2 commit 0afcab3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions spec/lib/listen/monotonic_time_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
RSpec.describe Listen::MonotonicTime do
context 'module methods' do
describe '.now' do
subject { described_class.now }
let(:tick_count) { 0.123 }

context 'when CLOCK_MONOTONIC defined' do
before do
stub_const('Process::CLOCK_MONOTONIC', 10)
end

it 'returns the CLOCK_MONOTONIC tick count' do
expect(Process).to receive(:clock_gettime).with(Process::CLOCK_MONOTONIC).and_return(tick_count)
expect(described_class.now).to eq(tick_count)
expect(subject).to eq(tick_count)
end
end

Expand All @@ -25,7 +27,7 @@

it 'returns the floating point Time.now' do
expect(Process).to receive(:clock_gettime).with(Process::CLOCK_MONOTONIC_RAW).and_return(tick_count)
expect(described_class.now).to eq(tick_count)
expect(subject).to eq(tick_count)
end
end

Expand All @@ -40,7 +42,7 @@
it 'returns the floating point Time.now' do
expect(Time).to receive(:now).and_return(now)
expect(now).to receive(:to_f).and_return(tick_count)
expect(described_class.now).to eq(tick_count)
expect(subject).to eq(tick_count)
end
end
end
Expand Down

0 comments on commit 0afcab3

Please sign in to comment.