Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 4595

Show
Ignore:
Timestamp:
07/08/06 18:14:49 (2 years ago)
Author:
bitsweat
Message:

r4487@asus: jeremy | 2006-04-29 12:21:39 -0700
Check whether @flash is defined? for warnings-safety.
r4488@asus: jeremy | 2006-04-29 12:23:15 -0700
Check whether @flash is defined? for warnings-safety. Obviates nil? check.
r4489@asus: jeremy | 2006-04-29 12:45:18 -0700
Check whether @session is defined? for warnings-safety.
r4490@asus: jeremy | 2006-04-29 12:50:41 -0700
Check whether @rendering_runtime is defined? for warnings-safety.
r4491@asus: jeremy | 2006-04-29 12:55:01 -0700
Check whether @_cycles is defined? for warnings-safety.
r4492@asus: jeremy | 2006-04-29 12:59:19 -0700
Check whether instance variables are defined? for warnings-safety.
r4493@asus: jeremy | 2006-04-29 13:14:09 -0700
Add nil @template to PrototypeHelperTest to suppress unitialized instance variable warning.
r4494@asus: jeremy | 2006-04-29 13:31:34 -0700
Check whether @auto_index defined? for warnings-safety.
r4495@asus: jeremy | 2006-04-29 13:32:24 -0700
Wrap content_columns redefinitions with silence_warnings.
r4496@asus: jeremy | 2006-04-29 13:35:28 -0700
Wrap more redefinitions with silence_warnings.
r4829@asus: jeremy | 2006-07-08 10:59:20 -0700
abstract unit, fix warnings
r4830@asus: jeremy | 2006-07-08 11:06:12 -0700
Use parens to silence warning.
r4831@asus: jeremy | 2006-07-08 11:06:48 -0700
Use parens to silence warning.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/benchmarking.rb

    r4312 r4595  
    6666        runtime = [Benchmark::measure{ perform_action_without_benchmark }.real, 0.0001].max 
    6767        log_message  = "Completed in #{sprintf("%.5f", runtime)} (#{(1 / runtime).floor} reqs/sec)" 
    68         log_message << rendering_runtime(runtime) if @rendering_runtime 
     68        log_message << rendering_runtime(runtime) if defined?(@rendering_runtime) 
    6969        log_message << active_record_runtime(runtime) if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? 
    7070        log_message << " | #{headers["Status"]}" 
  • trunk/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb

    r4524 r4595  
    7676        # Fix for Safari Ajax postings that always append \000 
    7777        content.chop! if content[-1] == 0 
    78         content.gsub! /&_=$/, '' 
     78        content.gsub!(/&_=$/, '') 
    7979        env_table['RAW_POST_DATA'] = content.freeze 
    8080      end 
  • trunk/actionpack/lib/action_controller/cgi_process.rb

    r4306 r4595  
    102102 
    103103    def session 
    104       unless @session 
     104      unless defined?(@session) 
    105105        if @session_options == false 
    106106          @session = Hash.new 
     
    120120 
    121121    def reset_session 
    122       @session.delete if CGI::Session === @session 
     122      @session.delete if defined?(@session) && @session.is_a?(CGI::Session) 
    123123      @session = new_session 
    124124    end 
  • trunk/actionpack/lib/action_controller/components.rb

    r4474 r4595  
    112112 
    113113        def flash_with_components(refresh = false) #:nodoc: 
    114           if @flash.nil? || refresh 
    115             @flash =  
    116               if @parent_controller 
     114          if !defined?(@flash) || refresh 
     115            @flash = 
     116              if defined?(@parent_controller) 
    117117                @parent_controller.flash 
    118118              else 
  • trunk/actionpack/lib/action_controller/flash.rb

    r4540 r4595  
    156156        # Note that if sessions are disabled only flash.now will work. 
    157157        def flash(refresh = false) #:doc: 
    158           if @flash.nil? || refresh 
    159             @flash =  
     158          if !defined?(@flash) || refresh 
     159            @flash = 
    160160              if @session.is_a?(Hash) 
    161161                # @session is a Hash, if sessions are disabled 
  • trunk/actionpack/lib/action_controller/test_process.rb

    r4433 r4595  
    338338        base.class_eval <<-EOV, __FILE__, __LINE__ 
    339339          def #{method}(action, parameters = nil, session = nil, flash = nil) 
    340             @request.env['REQUEST_METHOD'] = "#{method.upcase}" if @request 
     340            @request.env['REQUEST_METHOD'] = "#{method.upcase}" if defined?(@request) 
    341341            process(action, parameters, session, flash) 
    342342          end 
     
    349349      # Sanity check for required instance variables so we can give an 
    350350      # understandable error message. 
    351       %w(controller request response).each do |iv_name| 
    352         raise "@#{iv_name} is nil: make sure you set it in your test's setup method." if instance_variable_get("@#{iv_name}").nil? 
     351      %w(@controller @request @response).each do |iv_name| 
     352        if !instance_variables.include?(iv_name) || instance_variable_get(iv_name).nil? 
     353          raise "#{iv_name} is nil: make sure you set it in your test's setup method." 
     354        end 
    353355      end 
    354356 
  • trunk/actionpack/lib/action_view/helpers/form_helper.rb

    r4334 r4595  
    268268        options["checked"] = "checked" if checked 
    269269        pretty_tag_value    = tag_value.to_s.gsub(/\s/, "_").gsub(/\W/, "").downcase 
    270         options["id"]       = @auto_index ?              
     270        options["id"]       = defined?(@auto_index) ?              
    271271          "#{@object_name}_#{@auto_index}_#{@method_name}_#{pretty_tag_value}" : 
    272272          "#{@object_name}_#{@method_name}_#{pretty_tag_value}" 
     
    378378            options["id"]   ||= tag_id_with_index(options["index"]) 
    379379            options.delete("index") 
    380           elsif @auto_index 
     380          elsif defined?(@auto_index) 
    381381            options["name"] ||= tag_name_with_index(@auto_index) 
    382382            options["id"]   ||= tag_id_with_index(@auto_index) 
  • trunk/actionpack/lib/action_view/helpers/text_helper.rb

    r4446 r4595  
    278278      def reset_cycle(name = "default") 
    279279        cycle = get_cycle(name) 
    280         return if cycle.nil? 
    281         cycle.reset 
     280        cycle.reset unless cycle.nil? 
    282281      end 
    283282 
     
    306305        # uses an instance variable of ActionView::Base. 
    307306        def get_cycle(name) 
    308           @_cycles = Hash.new if @_cycles.nil? 
     307          @_cycles = Hash.new unless defined?(@_cycles) 
    309308          return @_cycles[name] 
    310309        end 
    311310         
    312311        def set_cycle(name, cycle_object) 
    313           @_cycles = Hash.new if @_cycles.nil? 
     312          @_cycles = Hash.new unless defined?(@_cycles) 
    314313          @_cycles[name] = cycle_object 
    315314        end 
  • trunk/actionpack/test/controller/helper_test.rb

    r2938 r4595  
    7878  def test_declare_missing_file_from_helper 
    7979    require 'broken_helper' 
    80     rescue LoadError => e 
    81       assert_nil /\bbroken_helper\b/.match(e.to_s)[1] 
     80  rescue LoadError => e 
     81    assert_nil(/\bbroken_helper\b/.match(e.to_s)[1]) 
    8282  end 
    8383 
  • trunk/actionpack/test/template/active_record_helper_test.rb

    r4592 r4595  
    5050    end 
    5151 
    52     def Post.content_columns() [ Column.new(:string, "title", "Title"), Column.new(:text, "body", "Body") ] end 
     52    silence_warnings do 
     53      def Post.content_columns() [ Column.new(:string, "title", "Title"), Column.new(:text, "body", "Body") ] end 
     54    end 
    5355 
    5456    @post.title       = "Hello World" 
     
    7779    end 
    7880 
    79     def User.content_columns() [ Column.new(:string, "email", "Email") ] end 
     81    silence_warnings do 
     82      def User.content_columns() [ Column.new(:string, "email", "Email") ] end 
     83    end 
    8084 
    8185    @user.email = "" 
     
    120124    ) 
    121125 
    122     class << @post 
    123       def new_record?() false end 
    124       def to_param() id end 
    125       def id() 1 end 
     126    silence_warnings do 
     127      class << @post 
     128        def new_record?() false end 
     129        def to_param() id end 
     130        def id() 1 end 
     131      end 
    126132    end 
     133 
    127134    assert_dom_equal( 
    128135      %(<form action="update/1" method="post"><input id="post_id" name="post[id]" type="hidden" value="1" /><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Update" /></form>), 
     
    132139   
    133140  def test_form_with_date 
    134     def Post.content_columns() [ Column.new(:date, "written_on", "Written on") ] end 
     141    silence_warnings do 
     142      def Post.content_columns() [ Column.new(:date, "written_on", "Written on") ] end 
     143    end 
    135144 
    136145    assert_dom_equal( 
     
    139148    ) 
    140149  end 
    141    
     150 
    142151  def test_form_with_datetime 
    143     def Post.content_columns() [ Column.new(:datetime, "written_on", "Written on") ] end 
     152    silence_warnings do 
     153      def Post.content_columns() [ Column.new(:datetime, "written_on", "Written on") ] end 
     154    end 
    144155    @post.written_on  = Time.gm(2004, 6, 15, 16, 30) 
    145156 
  • trunk/actionpack/test/template/prototype_helper_test.rb

    r4374 r4595  
    1414   
    1515  def setup 
     16    @template = nil 
    1617    @controller = Class.new do 
    1718      def url_for(options, *parameters_for_method_reference) 
  • trunk/activesupport/test/caching_tools_test.rb

    r4059 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__)+'/../lib/active_support/caching_tools' 
     1require File.dirname(__FILE__) + '/abstract_unit' 
    32 
    43class HashCachingTests < Test::Unit::TestCase 
    5    
    64  def cached(&proc) 
    7     return @cached if @cached 
    8      
     5    return @cached if defined?(@cached) 
     6 
    97    @cached_class = Class.new(&proc) 
    108    @cached_class.class_eval do 
     
    1412    @cached = @cached_class.new 
    1513  end 
    16    
     14 
    1715  def test_cache_access_should_call_method 
    1816    cached do 
     
    2119    assert_raises(RuntimeError) { cached.slow_method_cache[1] } 
    2220  end 
    23    
     21 
    2422  def test_cache_access_should_actually_cache 
    2523    cached do 
     
    3836    assert_equal 12, cached.slow_method_cache[11] 
    3937  end 
    40    
     38 
    4139  def test_cache_should_be_clearable 
    4240    cached do 
     
    4947    assert_equal 2, cached.slow_method_cache[:b] 
    5048    assert_equal 3, cached.slow_method_cache[:c] 
    51      
     49 
    5250    assert_equal 1, cached.slow_method_cache[:a] 
    5351    assert_equal 2, cached.slow_method_cache[:b] 
    5452    assert_equal 3, cached.slow_method_cache[:c] 
    55      
     53 
    5654    cached.slow_method_cache.clear 
    57      
     55 
    5856    assert_equal 4, cached.slow_method_cache[:a] 
    5957    assert_equal 5, cached.slow_method_cache[:b] 
    6058    assert_equal 6, cached.slow_method_cache[:c] 
    6159  end 
    62    
     60 
    6361  def test_deep_caches_should_work_too 
    6462    cached do 
     
    7169    assert_equal 7, cached.slow_method_cache[1][2][4] 
    7270    assert_equal 7, cached.slow_method_cache[4][2][1] 
    73      
     71 
    7472    assert_equal({ 
    7573      1 => {1 => {1 => 3}, 2 => {4 => 7}}, 
     
    7876    ) 
    7977  end 
    80    
    8178end 
  • trunk/activesupport/test/class_inheritable_attributes_test.rb

    r3493 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../lib/active_support/core_ext/class/inheritable_attributes' 
     1require File.dirname(__FILE__) + '/abstract_unit' 
    32 
    43class ClassInheritableAttributesTest < Test::Unit::TestCase 
  • trunk/activesupport/test/clean_logger_test.rb

    r3131 r4595  
    1 require 'test/unit' 
     1require File.dirname(__FILE__) + '/abstract_unit' 
    22require 'stringio' 
    3 require File.dirname(__FILE__) + '/../lib/active_support/clean_logger' 
    4 require File.dirname(__FILE__) + '/../lib/active_support/core_ext/kernel.rb' unless defined? silence_warnings 
    53 
    64class CleanLoggerTest < Test::Unit::TestCase 
  • trunk/activesupport/test/core_ext/array_ext_test.rb

    r4413 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    32 
    43class ArrayExtToParamTests < Test::Unit::TestCase 
     
    87    assert_equal 'hello/10', %w(hello 10).to_param 
    98  end 
    10    
     9 
    1110  def test_number_array 
    1211    assert_equal '10/20', [10, 20].to_param 
     
    2019    assert_equal "one and two", ['one', 'two'].to_sentence 
    2120    assert_equal "one, two, and three", ['one', 'two', 'three'].to_sentence 
    22      
     21 
    2322  end 
    24    
     23 
    2524  def test_to_sentence_with_connector 
    2625    assert_equal "one, two, and also three", ['one', 'two', 'three'].to_sentence(:connector => 'and also') 
    2726  end 
    28    
     27 
    2928  def test_to_sentence_with_skip_last_comma 
    3029    assert_equal "one, two, and three", ['one', 'two', 'three'].to_sentence(:skip_last_comma => false) 
     
    3433    assert_equal "one and two", ['one', 'two'].to_sentence 
    3534  end 
    36    
     35 
    3736  def test_one_element 
    3837    assert_equal "one", ['one'].to_sentence 
     
    4746      Class.new { def id() 3 end }.new 
    4847    ] 
    49      
     48 
    5049    assert_equal "null", [].to_s(:db) 
    5150    assert_equal "1,2,3", collection.to_s(:db) 
     
    8887    assert_equal [[]], [].split(0) 
    8988  end 
    90    
     89 
    9190  def test_split_with_argument 
    9291    assert_equal [[1, 2], [4, 5]],  [1, 2, 3, 4, 5].split(3) 
    9392    assert_equal [[1, 2, 3, 4, 5]], [1, 2, 3, 4, 5].split(0) 
    9493  end 
    95    
     94 
    9695  def test_split_with_block 
    9796    assert_equal [[1, 2], [4, 5], [7, 8], [10]], (1..10).to_a.split { |i| i % 3 == 0 } 
    9897  end 
    99    
     98 
    10099  def test_split_with_edge_values 
    101100    assert_equal [[], [2, 3, 4, 5]],  [1, 2, 3, 4, 5].split(1) 
     
    125124    assert_equal "<people><person>", xml.first(16) 
    126125  end 
    127    
     126 
    128127  def test_to_xml_with_options 
    129     xml = [  
     128    xml = [ 
    130129      { :name => "David", :street_address => "Paulina" }, { :name => "Jason", :street_address => "Evergreen" } 
    131130    ].to_xml(:skip_instruct => true, :skip_types => true, :indent => 0) 
     
    139138 
    140139  def test_to_xml_with_dasherize_false 
    141     xml = [  
     140    xml = [ 
    142141      { :name => "David", :street_address => "Paulina" }, { :name => "Jason", :street_address => "Evergreen" } 
    143142    ].to_xml(:skip_instruct => true, :skip_types => true, :indent => 0, :dasherize => false) 
     
    149148 
    150149  def test_to_xml_with_dasherize_true 
    151     xml = [  
     150    xml = [ 
    152151      { :name => "David", :street_address => "Paulina" }, { :name => "Jason", :street_address => "Evergreen" } 
    153152    ].to_xml(:skip_instruct => true, :skip_types => true, :indent => 0, :dasherize => true) 
  • trunk/activesupport/test/core_ext/blank_test.rb

    r3493 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/object' 
    3 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/blank' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    42 
    53class BlankTest < Test::Unit::TestCase 
  • trunk/activesupport/test/core_ext/cgi_ext_test.rb

    r1496 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/cgi' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    32 
    43class EscapeSkippingSlashesTest < Test::Unit::TestCase 
  • trunk/activesupport/test/core_ext/class_test.rb

    r3493 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/class' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    32 
    43class A 
  • trunk/activesupport/test/core_ext/date_ext_test.rb

    r738 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/date' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    32 
    43class DateExtCalculationsTest < Test::Unit::TestCase 
     
    76    assert_equal "February 21, 2005", Date.new(2005, 2, 21).to_s(:long) 
    87  end 
    9    
     8 
    109  def test_to_time 
    1110    assert_equal Time.local(2005, 2, 21), Date.new(2005, 2, 21).to_time 
    1211  end 
    13    
     12 
    1413  def test_to_date 
    1514    assert_equal Date.new(2005, 2, 21), Date.new(2005, 2, 21).to_date 
  • trunk/activesupport/test/core_ext/enumerable_test.rb

    r4495 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/symbol' 
    3 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/enumerable' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    42 
    53Payment = Struct.new(:price) 
     
    1311    klass = Class.new 
    1412    klass.send(:attr_accessor, :name) 
    15     objects = (1..50).inject([]) do |people,|  
     13    objects = (1..50).inject([]) do |people,| 
    1614      p = klass.new 
    1715      p.name = names.sort_by { rand }.first 
  • trunk/activesupport/test/core_ext/exception_test.rb

    r4158 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/exception' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    32 
    43class ExceptionExtTests < Test::Unit::TestCase 
    5    
     4 
    65  def get_exception(cls = RuntimeError, msg = nil, trace = nil) 
    76    begin raise cls, msg, (trace || caller) 
     
    109    end 
    1110  end 
    12    
     11 
    1312  def setup 
    1413    Exception::TraceSubstitutions.clear 
    1514  end 
    16    
     15 
    1716  def test_clean_backtrace 
    1817    Exception::TraceSubstitutions << [/\s*hidden.*/, ''] 
     
    2120    assert_equal ['bhal.rb', 'rawh hid den stuff is not here', 'almost all'], e.clean_backtrace 
    2221  end 
    23    
     22 
    2423  def test_app_backtrace 
    2524    Exception::TraceSubstitutions << [/\s*hidden.*/, ''] 
     
    2827    assert_equal ['bhal.rb', 'almost all'], e.application_backtrace 
    2928  end 
    30    
     29 
    3130  def test_app_backtrace_with_before 
    3231    Exception::TraceSubstitutions << [/\s*hidden.*/, ''] 
     
    4241    assert_equal ['vendor/file.rb some stuff', ' vendor/file.rb some stuff'], e.framework_backtrace 
    4342  end 
    44    
     43 
    4544  def test_backtrace_should_clean_paths 
    4645    Exception::TraceSubstitutions << [/\s*hidden.*/, ''] 
     
    4948    assert_equal ['bhal.rb', 'rawh hid den stuff is not here', 'almost all'], e.clean_backtrace 
    5049  end 
    51    
     50 
    5251  def test_clean_message_should_clean_paths 
    5352    Exception::TraceSubstitutions << [/\s*hidden.*/, ''] 
     
    5655    assert_equal "I dislike a/b/c", e.clean_message 
    5756  end 
    58    
     57 
    5958  def test_app_trace_should_be_empty_when_no_app_frames 
    6059    Exception::TraceSubstitutions << [/\s*hidden.*/, ''] 
  • trunk/activesupport/test/core_ext/hash_ext_test.rb

    r4555 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    32 
    43class HashExtTest < Test::Unit::TestCase 
  • trunk/activesupport/test/core_ext/integer_ext_test.rb

    r1863 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/integer' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    32 
    43class IntegerExtTest < Test::Unit::TestCase 
     
    65    assert [ -2, 0, 2, 4 ].all? { |i| i.even? } 
    76    assert ![ -1, 1, 3 ].all? { |i| i.even? } 
    8      
     7 
    98    assert 22953686867719691230002707821868552601124472329079.odd? 
    109    assert !22953686867719691230002707821868552601124472329079.even? 
     
    1817    assert 1000000000000000000000000000000000000000000000000000000001.odd? 
    1918  end 
    20    
     19 
    2120  def test_multiple_of 
    2221    [ -7, 0, 7, 14 ].each { |i| assert i.multiple_of?(7) } 
  • trunk/activesupport/test/core_ext/kernel_test.rb

    r4386 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/kernel' unless defined? silence_warnings 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    32 
    43class KernelTest < Test::Unit::TestCase 
  • trunk/activesupport/test/core_ext/load_error_tests.rb

    r985 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/load_error' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    32 
    43class TestMissingSourceFile < Test::Unit::TestCase 
  • trunk/activesupport/test/core_ext/module_test.rb

    r4429 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/class' 
    3 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/module' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    42 
    53module One 
     
    6866    assert_equal "Chicago", david.city 
    6967  end 
    70    
     68 
    7169  def test_delegation_down_hierarchy 
    7270    david = Someone.new("David", Somewhere.new("Paulina", "Chicago")) 
    7371    assert_equal "CHICAGO", david.upcase 
    7472  end 
    75    
     73 
    7674  def test_delegation_to_instance_variable 
    7775    david = Name.new("David", "Hansson") 
    7876    assert_equal "DAVID HANSSON", david.upcase 
    7977  end 
    80    
     78 
    8179  def test_missing_delegation_target 
    8280    assert_raises(ArgumentError) { eval($nowhere) } 
    8381    assert_raises(ArgumentError) { eval($noplace) } 
    8482  end 
    85    
     83 
    8684  def test_parent 
    8785    assert_equal Yz::Zy, Yz::Zy::Cd.parent 
     
    8987    assert_equal Object, Yz.parent 
    9088  end 
    91    
     89 
    9290  def test_parents 
    9391    assert_equal [Yz::Zy, Yz, Object], Yz::Zy::Cd.parents 
    9492    assert_equal [Yz, Object], Yz::Zy.parents 
    9593  end 
    96    
     94 
    9795  def test_as_load_path 
    9896    assert_equal 'yz/zy', Yz::Zy.as_load_path 
     
    157155    FooClassWithBarMethod.alias_method_chain :quux!, :baz 
    158156    assert @instance.respond_to?(:quux_with_baz!) 
    159      
     157 
    160158    assert_equal 'quux_with_baz!', @instance.quux! 
    161159    assert_equal 'quux', @instance.quux_without_baz! 
     
    167165    assert !@instance.respond_to?(:quux_with_baz!) 
    168166    assert !@instance.respond_to?(:quux_with_baz?) 
    169    
     167 
    170168    FooClassWithBarMethod.send(:include, BarMethodAliaser) 
    171169    FooClassWithBarMethod.alias_method_chain :quux!, :baz 
    172170    FooClassWithBarMethod.alias_method_chain :quux?, :baz 
    173    
     171 
    174172    assert @instance.respond_to?(:quux_with_baz!) 
    175173    assert @instance.respond_to?(:quux_with_baz?) 
  • trunk/activesupport/test/core_ext/numeric_ext_test.rb

    r2746 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/numeric' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    32 
    43class NumericExtTimeTest < Test::Unit::TestCase 
  • trunk/activesupport/test/core_ext/object_and_class_ext_test.rb

    r4049 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/object' 
    3 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/class' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    42 
    53class ClassA; end 
     
    4240    assert !defined?(ClassD) 
    4341  end 
    44    
     42 
    4543  def test_subclasses_of 
    4644    assert_equal [ClassJ], Object.subclasses_of(ClassI) 
     
    4846    assert_equal [], Object.subclasses_of(ClassI) 
    4947  end 
    50    
     48 
    5149  def test_subclasses_of_should_find_nested_classes 
    5250    assert Object.subclasses_of(ClassK).include?(Nested::ClassL) 
    5351  end 
    54    
     52 
    5553  def test_subclasses_of_should_not_return_removed_classes 
    5654    # First create the removed class 
     
    5957    Nested.const_set :ClassL, new_class 
    6058    assert_equal "Nested::ClassL", new_class.name # Sanity check 
    61      
     59 
    6260    subclasses = Object.subclasses_of(ClassK) 
    6361    assert subclasses.include?(new_class) 
     
    7674    suppress(LoadError, ArgumentError) { raise ArgumentError } 
    7775  end 
    78   
     76 
    7977  def test_extended_by 
    8078    foo = Foo.new 
     
    8381    assert ([Bar, Baz] - foo.extended_by).empty?, "Expected Bar, Baz in #{foo.extended_by.inspect}" 
    8482  end 
    85    
     83 
    8684  def test_extend_with_included_modules_from 
    8785    foo, object = Foo.new, Object.new 
    8886    assert !object.respond_to?(:bar) 
    8987    assert !object.respond_to?(:baz) 
    90      
     88 
    9189    object.extend_with_included_modules_from(foo) 
    9290    assert object.respond_to?(:bar) 
    9391    assert !object.respond_to?(:baz) 
    94      
     92 
    9593    foo.extend(Baz) 
    9694    object.extend_with_included_modules_from(foo) 
     
    114112    assert_equal %w(@bar @baz), @dest.instance_variables.sort 
    115113    %w(@bar @baz).each do |name| 
    116       assert_equal @source.instance_variable_get(name).object_id,  
     114      assert_equal @source.instance_variable_get(name).object_id, 
    117115                   @dest.instance_variable_get(name).object_id 
    118116    end 
    119117  end 
    120    
     118 
    121119  def test_copy_instance_variables_from_with_explicit_excludes 
    122120    @dest.copy_instance_variables_from(@source, ['@baz']) 
     
    124122    assert_equal 'bar', @dest.instance_variable_get('@bar') 
    125123  end 
    126    
     124 
    127125  def test_copy_instance_variables_automatically_excludes_protected_instance_variables 
    128126    @source.instance_variable_set(:@quux, 'quux') 
     
    132130      end 
    133131    end 
    134      
     132 
    135133    @dest.copy_instance_variables_from(@source) 
    136134    assert !@dest.instance_variables.include?('@bar') 
     
    138136    assert_equal 'baz', @dest.instance_variable_get('@baz') 
    139137  end 
    140    
     138 
    141139  def test_instance_values 
    142140    object = Object.new 
     
    145143    assert_equal({'a' => 1, 'b' => 2}, object.instance_values) 
    146144  end 
    147    
     145 
    148146  def test_instance_exec_passes_arguments_to_block 
    149147    block = Proc.new { |value| [self, value] } 
    150148    assert_equal %w(hello goodbye), 'hello'.instance_exec('goodbye', &block) 
    151149  end 
    152    
     150 
    153151end 
  • trunk/activesupport/test/core_ext/pathname_test.rb

    r4159 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/pathname' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    32 
    43class TestPathname < Test::Unit::TestCase 
    5    
    64  def test_clean_within 
    75    assert_equal "Hi", Pathname.clean_within("Hi") 
     
    97    assert_equal "Hello\nWorld", Pathname.clean_within("Hello/a/b/../..\na/b/../../World/c/..") 
    108  end 
    11    
    129end 
  • trunk/activesupport/test/core_ext/proc_test.rb

    r3469 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/proc' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    32 
    43class ProcTests < Test::Unit::TestCase 
  • trunk/activesupport/test/core_ext/range_ext_test.rb

    r2506 r4595  
    1 require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/date' 
    3 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/time' 
    4 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/range' 
     1require File.dirname(__FILE__) + '/../abstract_unit' 
    52 
    63class RangeTest < Test::Unit::TestCase 
  • trunk/activesupport/test/core_ext/string_ext_test.rb

    r3548 r4595  
    1 require 'test/unit' 
    21require 'date' 
    3 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/string' 
    4 require File.dirname(__FILE__) + '/../inflector_test' unless defined? InflectorTest 
     2require File.dirname(__FILE__) + '/../abstract_unit' 
    53 
    64class StringInflectionsTest < Test::Unit::TestCase 
     
    2927      assert_equal(underscore, camel.underscore) 
    3028    end 
    31      
     29 
    3230    assert_equal "html_tidy", "HTMLTidy".underscore 
    3331    assert_equal "html_tidy_generator", "HTMLTidyGenerator".underscore 
     
    5957    end 
    6058  end 
    61    
     59 
    6260  def test_string_to_time 
    6361    assert_equal Time.utc(2005, 2, 27, 23, 50), "2005-02-27 23:50".to_time 
     
    6563    assert_equal Date.new(2005, 2, 27), "2005-02-27".to_date 
    6664  end 
    67    
     65 
    6866  def test_access