Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Provide extensions to Test::Unit (and ActiveSupport::TestCase)
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
MIT-LICENCE
README.rdoc
test_unit_extend.gemspec

README.rdoc

Overview

Add extension to Test::Unit and ActiveSupport::TestCase

#before_test : do something before lauching a test. As with Rspec

#should_have_callbacks : shoulda doesn't have macro to test presence of callbacks, here is one.

before_test

class  .... < Test::Unit::TestCase

  before_test :test_me, :setup_for_test_me

  def test_me
    assert_equal "Cup of tea please", @var # OK
  end

  private

  def setup_for_test_me
    @var = "Cup of tea please"
  end

end

should_have_callbacks

If your model has callback :my_callback on before_create, just check it in your test by :

class  .... < ActiveSupport::TestCase
  should_have_callbacks :before_create, :my_callback
end

You can also pass an array :

should_have_callbacks :before_create, [:my_callback_1, :my_callback_2]

Install

gem install test_unit_extend

Dependencies

If you use ActiveSupport::TestCase, it doesn't work with ActiveSupport 3 (In Development)

Something went wrong with that request. Please try again.