Commit 7214021cd2d4d512ea6f0450483f943a5424c24d
1 parent
4ecfeb62
Exists in
master
and in
28 other branches
Making tests more understandable :)
(ActionItem2033)
Showing
1 changed file
with
23 additions
and
2 deletions
Show diff stats
test/unit/application_helper_test.rb
| @@ -18,6 +18,18 @@ class ApplicationHelperTest < Test::Unit::TestCase | @@ -18,6 +18,18 @@ class ApplicationHelperTest < Test::Unit::TestCase | ||
| 18 | 18 | ||
| 19 | File.expects(:exists?).with(p1+"test/_integer.rhtml").returns(true) | 19 | File.expects(:exists?).with(p1+"test/_integer.rhtml").returns(true) |
| 20 | 20 | ||
| 21 | + assert_equal 'integer', partial_for_class(Integer) | ||
| 22 | + end | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + should 'calculate correctly partial for models recursively' do | ||
| 26 | + p1 = 'path1/' | ||
| 27 | + p2 = 'path2/' | ||
| 28 | + @controller = mock() | ||
| 29 | + @controller.stubs(:view_paths).returns([p1,p2]) | ||
| 30 | + | ||
| 31 | + self.stubs(:params).returns({:controller => 'test'}) | ||
| 32 | + | ||
| 21 | File.expects(:exists?).with(p1+"test/_float.rhtml").returns(false) | 33 | File.expects(:exists?).with(p1+"test/_float.rhtml").returns(false) |
| 22 | File.expects(:exists?).with(p1+"test/_float.html.erb").returns(false) | 34 | File.expects(:exists?).with(p1+"test/_float.html.erb").returns(false) |
| 23 | File.expects(:exists?).with(p2+"test/_float.rhtml").returns(false) | 35 | File.expects(:exists?).with(p2+"test/_float.rhtml").returns(false) |
| @@ -28,13 +40,22 @@ class ApplicationHelperTest < Test::Unit::TestCase | @@ -28,13 +40,22 @@ class ApplicationHelperTest < Test::Unit::TestCase | ||
| 28 | File.expects(:exists?).with(p1+"test/_numeric.html.erb").returns(false) | 40 | File.expects(:exists?).with(p1+"test/_numeric.html.erb").returns(false) |
| 29 | File.expects(:exists?).with(p2+"test/_numeric.rhtml").returns(true) | 41 | File.expects(:exists?).with(p2+"test/_numeric.rhtml").returns(true) |
| 30 | 42 | ||
| 43 | + assert_equal 'numeric', partial_for_class(Float) | ||
| 44 | + end | ||
| 45 | + | ||
| 46 | + should 'raise error when partial is missing' do | ||
| 47 | + p1 = 'path1/' | ||
| 48 | + p2 = 'path2/' | ||
| 49 | + @controller = mock() | ||
| 50 | + @controller.stubs(:view_paths).returns([p1,p2]) | ||
| 51 | + | ||
| 52 | + self.stubs(:params).returns({:controller => 'test'}) | ||
| 53 | + | ||
| 31 | File.expects(:exists?).with(p1+"test/_object.rhtml").returns(false) | 54 | File.expects(:exists?).with(p1+"test/_object.rhtml").returns(false) |
| 32 | File.expects(:exists?).with(p1+"test/_object.html.erb").returns(false) | 55 | File.expects(:exists?).with(p1+"test/_object.html.erb").returns(false) |
| 33 | File.expects(:exists?).with(p2+"test/_object.rhtml").returns(false) | 56 | File.expects(:exists?).with(p2+"test/_object.rhtml").returns(false) |
| 34 | File.expects(:exists?).with(p2+"test/_object.html.erb").returns(false) | 57 | File.expects(:exists?).with(p2+"test/_object.html.erb").returns(false) |
| 35 | 58 | ||
| 36 | - assert_equal 'integer', partial_for_class(Integer) | ||
| 37 | - assert_equal 'numeric', partial_for_class(Float) | ||
| 38 | assert_raises ArgumentError do | 59 | assert_raises ArgumentError do |
| 39 | partial_for_class(Object) | 60 | partial_for_class(Object) |
| 40 | end | 61 | end |