Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/trunk/activesupport/test/whiny_nil_test.rb

Revision 8563, 0.8 kB (checked in by bitsweat, 9 months ago)

require abstract_unit directly since test is in load path

Line 
1 # Stub to enable testing without Active Record
2 module ActiveRecord
3   class Base
4     def save!
5     end
6   end
7 end
8
9 require 'abstract_unit'
10 require 'active_support/whiny_nil'
11
12 class WhinyNilTest < Test::Unit::TestCase
13   def test_unchanged
14     nil.method_thats_not_in_whiners
15   rescue NoMethodError => nme
16     assert_match(/nil.method_thats_not_in_whiners/, nme.message)
17   end
18
19   def test_active_record
20     nil.save!
21   rescue NoMethodError => nme
22     assert(!(nme.message =~ /nil:NilClass/))
23     assert_match(/nil\.save!/, nme.message)
24   end
25
26   def test_array
27     nil.each
28   rescue NoMethodError => nme
29     assert(!(nme.message =~ /nil:NilClass/))
30     assert_match(/nil\.each/, nme.message)
31   end
32
33   def test_id
34     nil.id
35   rescue RuntimeError => nme
36     assert(!(nme.message =~ /nil:NilClass/))
37   end
38 end
Note: See TracBrowser for help on using the browser.