fun_with_testing

A bunch of useful assertions, and a subclass of Test::Unit::TestCase for my gems to derive from.

Usage:

# This might go in test/helper.rb, for example
class GemTestCase < Test::Unit::TestCase
  include FunWith::Testing              # includes all custom assertions
  # include FunWith::Testing::Assertions::Basics        # alternately, just include tests piecemeal
  # include FunWith::Testing::Assertions::ActiveRecord  # alternately, just include tests piecemeal
  # include FunWith::Testing::Assertions::FunWithFiles  # alternately, just include tests piecemeal
end

Then in test/test_gem.rb:

class TestGem < GemTestCase
  def test_my_thing
    assert_zero( 0 )
    assert_not_zero( 1 )
    assert_has_method( 1, :to_s )
    # ... and so on down the line
  end
end

In the FunWith gems, gem tests use a subclass of FunWith::Testing::TestCase, a subclass of Test::Unit::TestCase with some helpful methods.

#_should() : ignores the inner block, instead prints a message warning that the test is being skipped
#_context() : ignores the inner block, instead prints a message warning that the set of tests is being skipped.

Contributing to fun_with_testing

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet.

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it.

  • Fork the project.

  • Start a feature/bugfix branch.

  • Commit and push until you are happy with your contribution.

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2014 Bryce Anderson. See LICENSE.txt for further details.