Permalink
Browse files

Added tests for whiny nil #1476 [court3nay/marcel]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1507 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent f16e0ec commit a995f42be0f9a14705d188c46c1db995baa01cf1 @dhh dhh committed Jun 25, 2005
Showing with 20 additions and 23 deletions.
  1. +1 −2 activesupport/lib/active_support/whiny_nil.rb
  2. +19 −21 activesupport/test/whiny_nil_test.rb
@@ -6,9 +6,8 @@
# by the framework users will see a message explaining what type of object
# was expected.
-
class NilClass
- WHINERS = [ ActiveRecord::Base, Array ]
+ WHINERS = [ ::ActiveRecord::Base, ::Array ]
@@method_class_map = Hash.new
@@ -1,40 +1,38 @@
require 'test/unit'
-
-## mock to enable testing without activerecord
+# mock to enable testing without activerecord
module ActiveRecord
class Base
def save!
end
end
end
-require 'active_support/whiny_nil'
-
-
+require File.dirname(__FILE__) + '/../lib/active_support/inflector'
+require File.dirname(__FILE__) + '/../lib/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
+ nil.method_thats_not_in_whiners
+ rescue NoMethodError => nme
+ assert_match(/nil:NilClass/, nme.message)
end
def test_active_record
- begin
- nil.save!
- rescue NoMethodError => nme
- assert(!(nme.message =~ /nil:NilClass/))
- end
+ nil.save!
+ rescue NoMethodError => nme
+ assert(!(nme.message =~ /nil:NilClass/))
end
def test_array
- begin
- nil.each
- rescue NoMethodError => nme
- assert(!(nme.message =~ /nil:NilClass/))
- end
+ nil.each
+ rescue NoMethodError => nme
+ assert(!(nme.message =~ /nil:NilClass/))
+ end
+
+ def test_id
+ nil.id
+ rescue RuntimeError => nme
+ assert(!(nme.message =~ /nil:NilClass/))
end
-end
+end

0 comments on commit a995f42

Please sign in to comment.