1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00
thoughtbot--shoulda-matchers/lib/shoulda/matchers/warn.rb
Elliot Winkler f67183ea59 Improve the word_wrap utility method
We use the word_wrap method right now to reformat warning messages so
that they fit within a 72-character space. We'd like to use this for
error messages too, but we want the word_wrap method to be smart when
reformatting bulleted or numbered lists, and also to ignore code blocks.
2015-10-08 21:30:41 -06:00

27 lines
636 B
Ruby

module Shoulda
module Matchers
TERMINAL_MAX_WIDTH = 72
# @private
def self.warn(message)
header = "Warning from shoulda-matchers:"
divider = "*" * TERMINAL_MAX_WIDTH
wrapped_message = word_wrap(message)
full_message = [
divider,
[header, wrapped_message.strip].join("\n\n"),
divider
].join("\n")
Kernel.warn(full_message)
end
# @private
def self.warn_about_deprecated_method(old_method, new_method)
warn <<EOT
#{old_method} is deprecated and will be removed in the next major
release. Please use #{new_method} instead.
EOT
end
end
end