2006-07-08 14:14:49 -04:00
|
|
|
# Stub to enable testing without Active Record
|
2005-06-20 07:15:46 -04:00
|
|
|
module ActiveRecord
|
|
|
|
class Base
|
|
|
|
def save!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2006-07-08 14:14:49 -04:00
|
|
|
require File.dirname(__FILE__) + '/abstract_unit'
|
|
|
|
require 'active_support/whiny_nil'
|
2005-06-20 07:15:46 -04:00
|
|
|
|
|
|
|
class WhinyNilTest < Test::Unit::TestCase
|
|
|
|
def test_unchanged
|
2005-06-25 07:15:38 -04:00
|
|
|
nil.method_thats_not_in_whiners
|
|
|
|
rescue NoMethodError => nme
|
2005-10-14 22:24:05 -04:00
|
|
|
assert_match(/nil.method_thats_not_in_whiners/, nme.message)
|
2005-06-20 07:15:46 -04:00
|
|
|
end
|
2006-07-08 14:14:49 -04:00
|
|
|
|
2005-06-20 07:15:46 -04:00
|
|
|
def test_active_record
|
2005-06-25 07:15:38 -04:00
|
|
|
nil.save!
|
|
|
|
rescue NoMethodError => nme
|
|
|
|
assert(!(nme.message =~ /nil:NilClass/))
|
2005-10-14 22:24:05 -04:00
|
|
|
assert_match(/nil\.save!/, nme.message)
|
2005-06-20 07:15:46 -04:00
|
|
|
end
|
2006-07-08 14:14:49 -04:00
|
|
|
|
2005-06-20 07:15:46 -04:00
|
|
|
def test_array
|
2005-06-25 07:15:38 -04:00
|
|
|
nil.each
|
|
|
|
rescue NoMethodError => nme
|
|
|
|
assert(!(nme.message =~ /nil:NilClass/))
|
2005-10-14 22:24:05 -04:00
|
|
|
assert_match(/nil\.each/, nme.message)
|
2005-06-25 07:15:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_id
|
|
|
|
nil.id
|
|
|
|
rescue RuntimeError => nme
|
|
|
|
assert(!(nme.message =~ /nil:NilClass/))
|
2005-06-20 07:15:46 -04:00
|
|
|
end
|
2005-06-25 07:15:38 -04:00
|
|
|
end
|