aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/naming_test.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-07-21 13:00:56 +0200
committerJosé Valim <jose.valim@gmail.com>2010-07-21 13:00:56 +0200
commit53310614d7ef279e3b2d5b02e4468e3e3f25e0cd (patch)
tree73c16b6738875b865d473a19f762238382645cb3 /activemodel/test/cases/naming_test.rb
parent508fba9e070e09f0a321f2dd7acf7938967468f7 (diff)
downloadrails-53310614d7ef279e3b2d5b02e4468e3e3f25e0cd.tar.gz
rails-53310614d7ef279e3b2d5b02e4468e3e3f25e0cd.tar.bz2
rails-53310614d7ef279e3b2d5b02e4468e3e3f25e0cd.zip
Reuse already existing classes for ActiveModel tests.
Diffstat (limited to 'activemodel/test/cases/naming_test.rb')
-rw-r--r--activemodel/test/cases/naming_test.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/activemodel/test/cases/naming_test.rb b/activemodel/test/cases/naming_test.rb
index dc39b84ed8..5a8bff378a 100644
--- a/activemodel/test/cases/naming_test.rb
+++ b/activemodel/test/cases/naming_test.rb
@@ -1,4 +1,6 @@
require 'cases/helper'
+require 'models/contact'
+require 'models/sheep'
require 'models/track_back'
class NamingTest < ActiveModel::TestCase
@@ -26,3 +28,40 @@ class NamingTest < ActiveModel::TestCase
assert_equal 'post/track_backs/track_back', @model_name.partial_path
end
end
+
+class NamingHelpersTest < Test::Unit::TestCase
+ def setup
+ @klass = Contact
+ @record = @klass.new
+ @singular = 'contact'
+ @plural = 'contacts'
+ @uncountable = Sheep
+ end
+
+ def test_singular
+ assert_equal @singular, singular(@record)
+ end
+
+ def test_singular_for_class
+ assert_equal @singular, singular(@klass)
+ end
+
+ def test_plural
+ assert_equal @plural, plural(@record)
+ end
+
+ def test_plural_for_class
+ assert_equal @plural, plural(@klass)
+ end
+
+ def test_uncountable
+ assert uncountable?(@uncountable), "Expected 'sheep' to be uncoutable"
+ assert !uncountable?(@klass), "Expected 'contact' to be countable"
+ end
+
+ private
+ def method_missing(method, *args)
+ ActiveModel::Naming.send(method, *args)
+ end
+end
+