Shopify / measured

Encapsulate measurements and their units in Ruby and Ruby on Rails.
MIT License
337 stars 28 forks source link

Clarify the bang-ness of to_unit_name #66

Closed thegedge closed 7 years ago

thegedge commented 7 years ago

Previously we had to_unit_name, but this method could raise, so it should have a bang suffix.

I've resolved this by having both to_unit_name and to_unit_name!, and using the raise-ing nature of to_unit_name! to simplify Measurable#initialize.

kmcphillips commented 7 years ago

Haha... @imran-iq I struggled so hard to create a system of units and names for things that don't actually exist.

thegedge commented 7 years ago

Added assert_raises_with_message to our test helper and updated the two tests. I'd actually like to add some new exception types to be more explicit (I'll cut an issue for that), in which case the message will become less relevant (but still no harm!)