Sha256: ec2f2545aff76f8e30e83418b5480e79402de7120a82b6fe7c4716c226799566

Contents?: true

Size: 1.93 KB

Versions: 18

Compression:

Stored size: 1.93 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))

describe "DataMapper::NamingConventions" do
  describe "Resource" do
    it "should coerce a string into the Underscored convention" do
      DataMapper::NamingConventions::Resource::Underscored.call('User').should == 'user'
      DataMapper::NamingConventions::Resource::Underscored.call('UserAccountSetting').should == 'user_account_setting'
    end

    it "should coerce a string into the UnderscoredAndPluralized convention" do
      DataMapper::NamingConventions::Resource::UnderscoredAndPluralized.call('User').should == 'users'
      DataMapper::NamingConventions::Resource::UnderscoredAndPluralized.call('UserAccountSetting').should == 'user_account_settings'
    end

    it "should coerce a string into the UnderscoredAndPluralized convention joining namespace with underscore" do
      DataMapper::NamingConventions::Resource::UnderscoredAndPluralized.call('Model::User').should == 'model_users'
      DataMapper::NamingConventions::Resource::UnderscoredAndPluralized.call('Model::UserAccountSetting').should == 'model_user_account_settings'
    end

    it "should coerce a string into the  UnderscoredAndPluralizedWithoutModule convention" do
      DataMapper::NamingConventions::Resource::UnderscoredAndPluralizedWithoutModule.call('Model::User').should == 'users'
      DataMapper::NamingConventions::Resource::UnderscoredAndPluralizedWithoutModule.call('Model::UserAccountSetting').should == 'user_account_settings'
    end

    it "should coerce a string into the Yaml convention" do
      DataMapper::NamingConventions::Resource::Yaml.call('UserSetting').should == 'user_settings.yaml'
      DataMapper::NamingConventions::Resource::Yaml.call('User').should == 'users.yaml'
    end
  end

  describe "Field" do
    it "should accept a property as input" do
      DataMapper::NamingConventions::Field::Underscored.call(Article.blog_id).should == 'blog_id'
    end
  end
end

Version data entries

18 entries across 18 versions & 5 rubygems

Version Path
datamapper-dm-core-0.9.11 spec/unit/naming_conventions_spec.rb
joevandyk-dm-core-0.9.6 spec/unit/naming_conventions_spec.rb
rpbertp13-dm-core-0.9.11.1 spec/unit/naming_conventions_spec.rb
rpbertp13-dm-core-0.9.11.2 spec/unit/naming_conventions_spec.rb
sam-dm-core-0.9.10 spec/unit/naming_conventions_spec.rb
sam-dm-core-0.9.11 spec/unit/naming_conventions_spec.rb
sam-dm-core-0.9.6 spec/unit/naming_conventions_spec.rb
sam-dm-core-0.9.7 spec/unit/naming_conventions_spec.rb
sam-dm-core-0.9.8 spec/unit/naming_conventions_spec.rb
sam-dm-core-0.9.9 spec/unit/naming_conventions_spec.rb
dm-core-0.9.10 spec/unit/naming_conventions_spec.rb
dm-core-0.9.11 spec/unit/naming_conventions_spec.rb
dm-core-0.9.4 spec/unit/naming_conventions_spec.rb
dm-core-0.9.5 spec/unit/naming_conventions_spec.rb
dm-core-0.9.6 spec/unit/naming_conventions_spec.rb
dm-core-0.9.7 spec/unit/naming_conventions_spec.rb
dm-core-0.9.8 spec/unit/naming_conventions_spec.rb
dm-core-0.9.9 spec/unit/naming_conventions_spec.rb