blob: a3bedd7c142f2102a03451a642dfb4ebf45d1b53 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
require 'test/unit'
# mock to enable testing without activerecord
module ActiveRecord
class Base
def save!
end
end
end
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
nil.method_thats_not_in_whiners
rescue NoMethodError => nme
assert_match(/nil:NilClass/, nme.message)
end
def test_active_record
nil.save!
rescue NoMethodError => nme
assert(!(nme.message =~ /nil:NilClass/))
end
def test_array
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
|