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

Changeset 5728

Show
Ignore:
Timestamp:
12/17/06 08:21:45 (2 years ago)
Author:
bitsweat
Message:

Deprecation: silence warnings when reporting test errors.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r5726 r5728  
    11*SVN* 
     2 
     3* Deprecation: silence warnings when reporting test errors.  [Jeremy Kemper] 
    24 
    35* Hash#slice(*keys) returns a new hash with only the given keys. #slice! replaces the hash with only the given keys. Works with HashWithIndifferentAccess also.  [Jeremy Kemper] 
  • trunk/activesupport/lib/active_support/deprecation.rb

    r5547 r5728  
    173173end 
    174174 
     175require 'test/unit' 
     176 
    175177module Test 
    176178  module Unit 
     
    178180      include ActiveSupport::Deprecation::Assertions 
    179181    end 
     182 
     183    class Error # :nodoc: 
     184      # Silence warnings when reporting test errors. 
     185      def message_with_silenced_deprecation 
     186        ActiveSupport::Deprecation.silence do 
     187          message_without_silenced_deprecation 
     188        end 
     189      end 
     190 
     191      alias_method_chain :message, :silenced_deprecation 
     192    end 
    180193  end 
    181194end 
  • trunk/activesupport/test/deprecation_test.rb

    r5356 r5728  
    129129    assert_deprecated(/you now need to do something extra for this one/) { @dtc.d } 
    130130  end 
     131 
     132  def test_assertion_failed_error_doesnt_spout_deprecation_warnings 
     133    error_class = Class.new(StandardError) do 
     134      def message 
     135        ActiveSupport::Deprecation.warn 'warning in error message' 
     136        super 
     137      end 
     138    end 
     139 
     140    raise error_class.new('hmm') 
     141 
     142  rescue => e 
     143    error = Test::Unit::Error.new('testing ur doodz', e) 
     144    assert_not_deprecated { error.message } 
     145    assert_nil @last_message 
     146  end 
    131147end