Methods
M
S
T
Instance Public methods
message()
# File activesupport/test/deprecation_test.rb, line 173
def message
  ActiveSupport::Deprecation.warn 'warning in error message'
  super
end
setup()
# File activesupport/test/deprecation_test.rb, line 39
def setup
  # Track the last warning.
  @old_behavior = ActiveSupport::Deprecation.behavior
  @last_message = nil
  ActiveSupport::Deprecation.behavior = Proc.new { |message| @last_message = message }

  @dtc = Deprecatee.new
end
teardown()
# File activesupport/test/deprecation_test.rb, line 48
def teardown
  ActiveSupport::Deprecation.behavior = @old_behavior
end
test_assert_deprecated_matches_any_warning()
# File activesupport/test/deprecation_test.rb, line 118
def test_assert_deprecated_matches_any_warning
  assert_deprecated 'abc' do
    ActiveSupport::Deprecation.warn 'abc'
    ActiveSupport::Deprecation.warn 'def'
  end
rescue Test::Unit::AssertionFailedError
  flunk 'assert_deprecated should match any warning in block, not just the last one'
end
test_assert_deprecated_returns_result_of_block()
# File activesupport/test/deprecation_test.rb, line 131
def test_assert_deprecated_returns_result_of_block
  result = assert_deprecated('abc') do
    ActiveSupport::Deprecation.warn 'abc'
    123
  end
  assert_equal 123, result
end
test_assert_deprecated_warn_work_with_default_behavior()
# File activesupport/test/deprecation_test.rb, line 139
def test_assert_deprecated_warn_work_with_default_behavior
  ActiveSupport::Deprecation.instance_variable_set('@behavior' , nil)
  assert_deprecated('abc') do
    ActiveSupport::Deprecation.warn 'abc'
  end
end
test_assert_deprecation_without_match()
# File activesupport/test/deprecation_test.rb, line 112
def test_assert_deprecation_without_match
  assert_deprecated do
    @dtc.partially
  end
end
test_assert_not_deprecated_returns_result_of_block()
# File activesupport/test/deprecation_test.rb, line 127
def test_assert_not_deprecated_returns_result_of_block
  assert_equal 123, assert_not_deprecated { 123 }
end
test_assertion_failed_error_doesnt_spout_deprecation_warnings()
# File activesupport/test/deprecation_test.rb, line 171
def test_assertion_failed_error_doesnt_spout_deprecation_warnings
  error_class = Class.new(StandardError) do
    def message
      ActiveSupport::Deprecation.warn 'warning in error message'
      super
    end
  end

  raise error_class.new('hmm')

rescue => e
  error = Test::Unit::Error.new('testing ur doodz', e)
  assert_not_deprecated { error.message }
  assert_nil @last_message
end
test_deprecate_class_method()
# File activesupport/test/deprecation_test.rb, line 64
def test_deprecate_class_method
  assert_deprecated(/none is deprecated/) do
    assert_equal 1, @dtc.none
  end

  assert_deprecated(/one is deprecated/) do
    assert_equal 1, @dtc.one(1)
  end

  assert_deprecated(/multi is deprecated/) do
    assert_equal [1,2,3], @dtc.multi(1,2,3)
  end
end
test_deprecated_constant_proxy()
# File activesupport/test/deprecation_test.rb, line 107
def test_deprecated_constant_proxy
  assert_not_deprecated { Deprecatee::B::C }
  assert_deprecated('Deprecatee::A') { assert_equal Deprecatee::B::C, Deprecatee::A }
end
test_deprecated_instance_variable_proxy()
# File activesupport/test/deprecation_test.rb, line 96
def test_deprecated_instance_variable_proxy
  assert_not_deprecated { @dtc.request.size }

  assert_deprecated('@request.size') { assert_equal @dtc.request.size, @dtc.old_request.size }
  assert_deprecated('@request.to_s') { assert_equal @dtc.request.to_s, @dtc.old_request.to_s }
end
test_deprecated_instance_variable_proxy_shouldnt_warn_on_inspect()
# File activesupport/test/deprecation_test.rb, line 103
def test_deprecated_instance_variable_proxy_shouldnt_warn_on_inspect
  assert_not_deprecated { assert_equal @dtc.request.inspect, @dtc.old_request.inspect }
end
test_deprecation_with_alternate_method()
# File activesupport/test/deprecation_test.rb, line 162
def test_deprecation_with_alternate_method
  assert_deprecated(/use e instead/) { @dtc.c }
end
test_deprecation_with_explicit_message()
# File activesupport/test/deprecation_test.rb, line 166
def test_deprecation_with_explicit_message
  assert_deprecated(/you now need to do something extra for this one/) { @dtc.d }
end
test_deprecation_without_explanation()
# File activesupport/test/deprecation_test.rb, line 156
def test_deprecation_without_explanation
  assert_deprecated { @dtc.a }
  assert_deprecated { @dtc.b }
  assert_deprecated { @dtc.f = :foo }
end
test_inline_deprecation_warning()
# File activesupport/test/deprecation_test.rb, line 52
def test_inline_deprecation_warning
  assert_deprecated(/foo=nil/) do
    @dtc.partially
  end
end
test_nil_behavior_is_ignored()
# File activesupport/test/deprecation_test.rb, line 78
def test_nil_behavior_is_ignored
  ActiveSupport::Deprecation.behavior = nil
  assert_deprecated(/foo=nil/) { @dtc.partially }
end
test_several_behaviors()
# File activesupport/test/deprecation_test.rb, line 83
def test_several_behaviors
  @a, @b = nil, nil

  ActiveSupport::Deprecation.behavior = [
    Proc.new { |msg, callstack| @a = msg },
    Proc.new { |msg, callstack| @b = msg }
  ]

  @dtc.partially
  assert_match(/foo=nil/, @a)
  assert_match(/foo=nil/, @b)
end
test_silence()
# File activesupport/test/deprecation_test.rb, line 146
def test_silence
  ActiveSupport::Deprecation.silence do
    assert_not_deprecated { @dtc.partially }
  end

  ActiveSupport::Deprecation.silenced = true
  assert_not_deprecated { @dtc.partially }
  ActiveSupport::Deprecation.silenced = false
end
test_undeprecated()
# File activesupport/test/deprecation_test.rb, line 58
def test_undeprecated
  assert_not_deprecated do
    assert_equal 2, @dtc.not
  end
end