Skip to content

anoiaque/test_unit_extend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

Provide extensions to Test::Unit (and ActiveSupport::TestCase)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages