kotp
3/23/2012 - 12:39 AM

MiniTest Assertions and Specs

MiniTest Assertions and Specs

== Spec Style
must_be                  must_be_close_to         must_be_empty            
must_be_instance_of      must_be_kind_of          must_be_nil              
must_be_same_as          must_be_silent           must_be_within_delta     
must_be_within_epsilon   must_equal               must_include             
must_match               must_output              must_raise               
must_respond_to          must_send                must_throw               
wont_be                  wont_be_close_to         wont_be_empty            
wont_be_instance_of      wont_be_kind_of          wont_be_nil              
wont_be_same_as          wont_be_within_delta     wont_be_within_epsilon   
wont_equal               wont_include             wont_match               
wont_respond_to          

== Test Style
_assertions              _assertions=             
assert                   assert_block             assert_empty             
assert_equal             assert_in_delta          assert_in_epsilon        
assert_includes          assert_instance_of       assert_kind_of           
assert_match             assert_nil               assert_operator          
assert_output            assert_raises            assert_respond_to        
assert_same              assert_send              assert_silent            
assert_throws            refute                   refute_empty             
refute_equal             refute_in_delta          refute_in_epsilon        
refute_includes          refute_instance_of       refute_kind_of           
refute_match             refute_nil               refute_operator          
refute_respond_to        refute_same

#!/usr/bin/env ruby
# require 'test/unit'
require 'minitest/spec'

Columns= 3
def column_check
  if @column_count == Columns
    puts  
    @column_count = 0
  end
  @column_count += 1
end

def columnize(array, regx_1, regx_2)
  @column_count = 1
  array.sort.each do |element|
    if element =~ regx_1 or element=~ regx_2
      print "#{element}".ljust(25)
      column_check
    end
  end
end
  
puts "== Spec Style"
columnize(MiniTest::Spec.instance_methods, /must/, /wont/)
puts "\n\n== Test Style"
columnize(MiniTest::Assertions.instance_methods, /assert/, /refute/)
puts