Technical
Test Helpers

To get exceptions with messages

You can either add that to test_helper.rb


  private
  def assert_exception(exception, message=nil, &block)
    begin
      yield
    rescue exception => @e
      assert_equal message,@e.message
      assert_equal exception,@e.class
    end
    assert_raises(exception){yield} if @e.blank?
  end

So I could do the following


 assert_exception(RuntimeError,'SYSTEM ERROR')do   

    auth.request_data_by_get('entitlementds',
                         'EntitledFeatures',
                         false,
                         {:username => 'blah.blah.shi@db.com'})

 end 

How to get helper_test plugin working with Rails 1.2.3

Its a very nasty hack, not sort of programming like but rather “touched by dark hands of sysadmin” but I needed to be working. So, I guess I want to apologize to the creators of the helper_test plugin, for not being as elegant as they are.

  1. Add helper_testcase BEFORE require ‘test_help’ my header looks like that
    
    ENV["RAILS_ENV"] = "test" 
    require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
    require File.expand_path(File.dirname(__FILE__) + '/helper_testcase')
    require 'test_help'
    
  2. Change Parent class in helper_testcase
    
    class StubController < ActionController::Base #ApplicationController
    
  3. Uncomented super in the setup of helper_testcase.rb, cause otherwise was getting SystemStackError: stack level too deep
    
     ....
     include ActionView::Helpers::AssetTagHelper
     include ActionView::Helpers::PrototypeHelper
    
      def setup
        #super
    

Everything worked like a charm. Thanks again Geoffrey, you made my life so much easier.