chronic_duration
chronic_duration copied to clipboard
NoMethodError with ChronicDuration.parse('1:1:1:1:1:1:1')
Running this:
require 'chronic_duration'
puts ChronicDuration.parse('1:1:1:1:1:1:1')
results in
NoMethodError: private method `gsub' called for nil:NilClass
cleanup at /install/path/gems/chronic_duration-0.10.6/lib/chronic_duration.rb:183
parse at /install/path/gems/chronic_duration-0.10.6/lib/chronic_duration.rb:42
<top> at chronic_test.rb:3
There is no such valid input - I think you wanted to write
ChronicDuration.parse('1:1:1:1:1:1.1')
Note the decimal place ... 1.1
rather than ... 1:1
Result is 34239661.1
The whole point is to take arbitrary user input and do with it what you can. If the user gives invalid input, you don't want the app to fall over. Raising NoMethodError
for any input is a bug.
Agreed. It should be returning nil
.