module Kernel

Add private method into Kernel for custom matchers

Private Instance Methods

custom_matcher(name) { |obj, *args| ... } click to toggle source
# File lib/bacon/custom_matchers_messages.rb, line 25
def custom_matcher(name, &_block)
        description = name.to_s.tr('_', ' ')
        define_method name do |*args|
                lambda do |obj|
                        result = yield(obj, *args)
                        return result if result == true

                        "#{obj.inspect} doesn't #{description}" \
                                " #{(result || args).map(&:inspect).join(', ')}"
                end
        end
end