I have an options hash and a method to update it - but the options hash could change and if it does I want my tests to fail. What's a good way to write this?
raise RuntimeError, msg unless options.keys.include?(
:external_uid,
:display_name,
:country_code
)
If options.keys
doesn't include exactly those three items, an error should be raised.
solution that i almost used (thanks bjhaid):
def ensure_correct_options!(options)
msg = "Only 'external_uid', 'display_name' and 'country_code' can be "
msg += "updated. Given attributes: #{options.keys.inspect}"
raise RuntimeError, msg unless options.keys == [
:external_uid,
:display_name,
:country_code
]
end