Skip to content

Instantly share code, notes, and snippets.

@rudicode
Forked from kotp/minitest_assertions.rb
Created November 8, 2012 20:32
Show Gist options
  • Save rudicode/4041391 to your computer and use it in GitHub Desktop.
Save rudicode/4041391 to your computer and use it in GitHub Desktop.
MiniTest Assertions and Specs
#!/usr/bin/env ruby
# require 'test/unit'
require 'minitest/spec'
puts "== Spec Style"
columns = 3
column_count = 1
MiniTest::Spec.methods.sort.each do |method|
if method.to_s =~ /wont/ or method.to_s =~ /must/
print "#{method}".ljust(25)
if column_count == columns
print"\n"
column_count = 0
end
column_count += 1
end
end
puts "\n\n== Test Style"
column_count = 1
MiniTest::Assertions.instance_methods.sort.each do |method|
if method =~ /assert/ or method.to_s =~ /refute/
print "#{method}".ljust(25)
if column_count == columns
print"\n"
column_count = 0
end
column_count += 1
end
end
Output as of 08 NOV 2012
== 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment