class Test::Unit::TestCase

Public Class Methods

disallow_helpers! click to toggle source

Used to disallow helper methods in test specifications.

Test::Unit::TestCase.disallow_helper!

A test specification can override this behavior by passing the helper name (as a symbol) in the :allow options.

unit_tests :allow => [:create_something, :destroy_something] do
  test "verify something" do                                   
    ...
  end                   

  def create_something
    ...
  end                          

  def destroy_something
    ...
  end                                                     
end
   # File lib/test_case_extension.rb
50 def self.disallow_helpers!
51   @disallow_helpers = true
52 end
disallow_setup! click to toggle source

Used to disallow setup methods in test specifications.

Test::Unit::TestCase.disallow_setup!

A test specification can override this behavior by passing :setup in the :allow options.

unit_tests :allow => :setup do
  def setup
    ...
  end        

  test "verify something" do                                   
    ...
  end                                                     
end
   # File lib/test_case_extension.rb
21 def self.disallow_setup!
22   @disallow_setup = true
23 end
test(name, &block) click to toggle source

Used to define a test and assign it a descriptive name.

unit_tests do
  test "verify something" do                                   
    ...
  end                                                     
end
   # File lib/test_case_extension.rb
67 def self.test(name, &block)
68   test_name = "test_#{name.gsub(/[\s]/,'_')}".to_sym
69   raise "#{test_name} is already defined in #{self}" if self.instance_methods.include? test_name.to_s
70   define_method test_name do
71     instance_eval &block
72   end
73 end