Skip to content

Commit

Permalink
Update time format to return fractional seconds (#155)
Browse files Browse the repository at this point in the history
* Update time format to return fractional seconds

Previously, the time would return seconds as integer values. This update returns milliseconds, too.

```ruby
time = 3.141
sprintf('%0.000f', time)
# => "3"

sprintf('%.3f', time)
# => "3.141"
```

* fix specs
  • Loading branch information
stevendaniels authored and pbyrne committed Mar 26, 2019
1 parent 21ae47e commit 550405e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/ok_computer/check.rb
Expand Up @@ -34,7 +34,7 @@ def check
# Returns a String
def to_text
passfail = success? ? "passed" : "failed"
I18n.t("okcomputer.check.#{passfail}", registrant_name: registrant_name, message: message, time: "#{time ? sprintf('%0.000f', time) : '?'}s")
I18n.t("okcomputer.check.#{passfail}", registrant_name: registrant_name, message: message, time: "#{time ? sprintf('%.3f', time) : '?'}s")
end

# Public: The JSON output of performing the check
Expand Down
2 changes: 1 addition & 1 deletion spec/ok_computer/check_spec.rb
Expand Up @@ -64,7 +64,7 @@ module OkComputer

context "#to_text" do
it "combines the registrant_name, success, message, and execution time" do
expect(subject.to_text).to eq("#{subject.registrant_name}: PASSED #{subject.message} (5s)")
expect(subject.to_text).to eq("#{subject.registrant_name}: PASSED #{subject.message} (5.000s)")
end
end

Expand Down

0 comments on commit 550405e

Please sign in to comment.