1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activesupport/test/whiny_nil_test.rb
David Heinemeier Hansson 9113aa2744 Forgot to actually add the whiny nil
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1455 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-06-20 11:15:46 +00:00

40 lines
No EOL
666 B
Ruby

require 'test/unit'
## mock to enable testing without activerecord
module ActiveRecord
class Base
def save!
end
end
end
require 'active_support/whiny_nil'
class WhinyNilTest < Test::Unit::TestCase
def test_unchanged
begin
nil.method_thats_not_in_whiners
rescue NoMethodError => nme
assert_match(/nil:NilClass/, nme.message)
end
end
def test_active_record
begin
nil.save!
rescue NoMethodError => nme
assert(!(nme.message =~ /nil:NilClass/))
end
end
def test_array
begin
nil.each
rescue NoMethodError => nme
assert(!(nme.message =~ /nil:NilClass/))
end
end
end