mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-16 03:41:41 +00:00
* Add time tracking to http status agent * Replace time tracking to monotonic * Add tests for time tracker
21 lines
612 B
Ruby
21 lines
612 B
Ruby
require 'rails_helper'
|
|
|
|
describe TimeTracker do
|
|
describe "#track" do
|
|
it "tracks execution time" do
|
|
tracked_result = TimeTracker.track { sleep(0.01) }
|
|
expect(tracked_result.elapsed_time).to satisfy {|v| v > 0.01 && v < 0.1}
|
|
end
|
|
|
|
it "returns the proc return value" do
|
|
tracked_result = TimeTracker.track { 42 }
|
|
expect(tracked_result.result).to eq(42)
|
|
end
|
|
|
|
it "returns an object that behaves like the proc result" do
|
|
tracked_result = TimeTracker.track { 42 }
|
|
expect(tracked_result.to_i).to eq(42)
|
|
expect(tracked_result + 1).to eq(43)
|
|
end
|
|
end
|
|
end
|