Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError with ChronicDuration.parse('1:1:1:1:1:1:1') #42

Open
clonezone opened this issue Nov 13, 2015 · 3 comments
Open

NoMethodError with ChronicDuration.parse('1:1:1:1:1:1:1') #42

clonezone opened this issue Nov 13, 2015 · 3 comments

Comments

@clonezone
Copy link

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
@timkrins
Copy link

timkrins commented Nov 6, 2017

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

@clonezone
Copy link
Author

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.

@timkrins
Copy link

timkrins commented Nov 7, 2017

Agreed. It should be returning nil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants