From 7214021cd2d4d512ea6f0450483f943a5424c24d Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Tue, 9 Aug 2011 19:04:04 -0300 Subject: [PATCH] Making tests more understandable :) --- test/unit/application_helper_test.rb | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index a4e2038..bb5fd85 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -18,6 +18,18 @@ class ApplicationHelperTest < Test::Unit::TestCase File.expects(:exists?).with(p1+"test/_integer.rhtml").returns(true) + assert_equal 'integer', partial_for_class(Integer) + end + + + should 'calculate correctly partial for models recursively' do + p1 = 'path1/' + p2 = 'path2/' + @controller = mock() + @controller.stubs(:view_paths).returns([p1,p2]) + + self.stubs(:params).returns({:controller => 'test'}) + File.expects(:exists?).with(p1+"test/_float.rhtml").returns(false) File.expects(:exists?).with(p1+"test/_float.html.erb").returns(false) File.expects(:exists?).with(p2+"test/_float.rhtml").returns(false) @@ -28,13 +40,22 @@ class ApplicationHelperTest < Test::Unit::TestCase File.expects(:exists?).with(p1+"test/_numeric.html.erb").returns(false) File.expects(:exists?).with(p2+"test/_numeric.rhtml").returns(true) + assert_equal 'numeric', partial_for_class(Float) + end + + should 'raise error when partial is missing' do + p1 = 'path1/' + p2 = 'path2/' + @controller = mock() + @controller.stubs(:view_paths).returns([p1,p2]) + + self.stubs(:params).returns({:controller => 'test'}) + File.expects(:exists?).with(p1+"test/_object.rhtml").returns(false) File.expects(:exists?).with(p1+"test/_object.html.erb").returns(false) File.expects(:exists?).with(p2+"test/_object.rhtml").returns(false) File.expects(:exists?).with(p2+"test/_object.html.erb").returns(false) - assert_equal 'integer', partial_for_class(Integer) - assert_equal 'numeric', partial_for_class(Float) assert_raises ArgumentError do partial_for_class(Object) end -- libgit2 0.21.2