File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ module Clock
1212 # @returns [String] The formatted duration.
1313 def self . formatted_duration ( duration )
1414 if duration < 60.0
15- return " #{ duration . round ( 2 ) } s"
15+ return format ( "%.2fs" , duration )
1616 end
1717
1818 duration /= 60.0
Original file line number Diff line number Diff line change 88describe Console ::Clock do
99 with ".formatted_duration" do
1010 it "can format seconds" do
11- expect ( subject . formatted_duration ( 0 ) ) . to be == "0s"
12- expect ( subject . formatted_duration ( 1 ) ) . to be == "1s"
13- expect ( subject . formatted_duration ( 2 ) ) . to be == "2s"
14- expect ( subject . formatted_duration ( 10 ) ) . to be == "10s"
15- expect ( subject . formatted_duration ( 59 ) ) . to be == "59s"
11+ expect ( subject . formatted_duration ( 0 ) ) . to be == "0.00s"
12+ expect ( subject . formatted_duration ( 0.5 ) ) . to be == "0.50s"
13+ expect ( subject . formatted_duration ( 0.667 ) ) . to be == "0.67s"
14+ expect ( subject . formatted_duration ( 1 ) ) . to be == "1.00s"
15+ expect ( subject . formatted_duration ( 2 ) ) . to be == "2.00s"
16+ expect ( subject . formatted_duration ( 10 ) ) . to be == "10.00s"
17+ expect ( subject . formatted_duration ( 59 ) ) . to be == "59.00s"
1618 end
1719
1820 it "can format minutes" do
Original file line number Diff line number Diff line change 6767 expect ( console_capture . last ) . to have_keys (
6868 severity : be == :info ,
6969 subject : be == "My Measurement" ,
70- arguments : have_attributes ( first : be =~ /100\/ 100 completed in .*?, 0.0s remaining\. / ) ,
70+ arguments : have_attributes ( first : be =~ /100\/ 100 completed in .*?, 0\. 00s remaining\. / ) ,
7171 event : have_keys (
7272 type : be == :progress ,
7373 current : be == 100 ,
You can’t perform that action at this time.
0 commit comments