thoughtbot / cocaine

A small library for doing (command) lines.
https://robots.thoughtbot.com
Other
785 stars 55 forks source link

Handle expected outcodes as a range #91

Closed cih closed 6 years ago

cih commented 8 years ago

This change allows expected_outcodes to be passed as a Range. Previously this would fail as join was called when formatting the output message returning an undefined method error.

NoMethodError: undefined method 'join' for 0..1:Range

jyurek commented 6 years ago

Whoo, this is old. Sorry about that.

As to the functionality, I'd prefer to not handle return codes this way. I believe that if you want a particular value, you should specify that value. The same way you that an unspecified rescue is bad (or, worse, rescue Exception), I don't want failing commands to accidentally be allowed. Users should be mindful of what error conditions are acceptable.