Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • minitest/spec.rb

Class/Module Index [+]

Quicksearch

Module

Public Instance Methods

infect_an_assertion(meth, new_name, dont_flip = false) click to toggle source
 
               # File minitest/spec.rb, line 12
def infect_an_assertion meth, new_name, dont_flip = false
  # warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
  self.class_eval <<-EOM
    def #{new_name} *args, &block
      return MiniTest::Spec.current.#{meth}(*args, &self) if
        Proc === self
      return MiniTest::Spec.current.#{meth}(args.first, self) if
        args.size == 1 unless #{!!dont_flip}
      return MiniTest::Spec.current.#{meth}(self, *args)
    end
  EOM
end
            
infect_with_assertions(pos_prefix, neg_prefix, skip_re, dont_flip_re = /\c0/, map = {}) click to toggle source
 
               # File minitest/spec.rb, line 25
def infect_with_assertions(pos_prefix, neg_prefix,
                           skip_re,
                           dont_flip_re = /\c0/,
                           map = {})
  MiniTest::Assertions.public_instance_methods(false).each do |meth|
    meth = meth.to_s

    new_name = case meth
               when /^assert/ then
                 meth.sub(/^assert/, pos_prefix.to_s)
               when /^refute/ then
                 meth.sub(/^refute/, neg_prefix.to_s)
               end
    next unless new_name
    next if new_name =~ skip_re

    regexp, replacement = map.find { |re, _| new_name =~ re }
    new_name.sub! regexp, replacement if replacement

    infect_an_assertion meth, new_name, new_name =~ dont_flip_re
  end
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus