class NamingHelpersTest

Public Instance Methods

setup() click to toggle source
# File activemodel/test/cases/naming_test.rb, line 200
def setup
  @klass  = Contact
  @record = @klass.new
  @singular = "contact"
  @plural = "contacts"
  @uncountable = Sheep
  @singular_route_key = "contact"
  @route_key = "contacts"
  @param_key = "contact"
end
test_param_key() click to toggle source
# File activemodel/test/cases/naming_test.rb, line 241
def test_param_key
  assert_equal @param_key, param_key(@record)
end
test_param_key_for_class() click to toggle source
# File activemodel/test/cases/naming_test.rb, line 245
def test_param_key_for_class
  assert_equal @param_key, param_key(@klass)
end
test_plural() click to toggle source
# File activemodel/test/cases/naming_test.rb, line 223
def test_plural
  assert_equal @plural, plural(@record)
end
test_plural_for_class() click to toggle source
# File activemodel/test/cases/naming_test.rb, line 227
def test_plural_for_class
  assert_equal @plural, plural(@klass)
end
test_route_key() click to toggle source
# File activemodel/test/cases/naming_test.rb, line 231
def test_route_key
  assert_equal @route_key, route_key(@record)
  assert_equal @singular_route_key, singular_route_key(@record)
end
test_route_key_for_class() click to toggle source
# File activemodel/test/cases/naming_test.rb, line 236
def test_route_key_for_class
  assert_equal @route_key, route_key(@klass)
  assert_equal @singular_route_key, singular_route_key(@klass)
end
test_singular() click to toggle source
# File activemodel/test/cases/naming_test.rb, line 215
def test_singular
  assert_equal @singular, singular(@record)
end
test_singular_for_class() click to toggle source
# File activemodel/test/cases/naming_test.rb, line 219
def test_singular_for_class
  assert_equal @singular, singular(@klass)
end
test_to_model_called_on_record() click to toggle source
# File activemodel/test/cases/naming_test.rb, line 211
def test_to_model_called_on_record
  assert_equal "post_named_track_backs", plural(Post::TrackBack.new)
end
test_uncountable() click to toggle source
# File activemodel/test/cases/naming_test.rb, line 249
def test_uncountable
  assert uncountable?(@uncountable), "Expected 'sheep' to be uncountable"
  assert !uncountable?(@klass), "Expected 'contact' to be countable"
end
test_uncountable_route_key() click to toggle source
# File activemodel/test/cases/naming_test.rb, line 254
def test_uncountable_route_key
  assert_equal "sheep", singular_route_key(@uncountable)
  assert_equal "sheep_index", route_key(@uncountable)
end

Private Instance Methods

method_missing(method, *args) click to toggle source
# File activemodel/test/cases/naming_test.rb, line 260
def method_missing(method, *args)
  ActiveModel::Naming.send(method, *args)
end