Sha256: 3cacd13f039558f903efb9aec23b4155743744299318bf79316fc234e3eb3945

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'
require 'ore/naming'

describe Naming do
  subject do
    obj = Object.new
    obj.extend Ore::Naming
    obj
  end

  describe "underscore" do
    it "should underscore CamelCase names" do
      subject.underscore('FooBar').should == 'foo_bar'
    end

    it "should not add leading underscores to Capitalized names" do
      subject.underscore('Foo').should == 'foo'
    end

    it "should not add tailing underscores to CamelCase names" do
      subject.underscore('FooX').should == 'foox'
    end

    it "should not add underscores when they already exist" do
      subject.underscore('Foo_Bar').should == 'foo_bar'
    end
  end

  it "should guess the module names from a project name" do
    subject.modules_of('foo-bar').should == ['Foo', 'Bar']
  end

  it "should recognize common acronyms in project names" do
    subject.modules_of('ffi-bar').should == ['FFI', 'Bar']
  end

  it "should guess the namespace from a project name" do
    subject.namespace_of('foo-bar').should == 'Foo::Bar'
  end

  it "should guess the namespace directories from a project name" do
    subject.namespace_dirs_of('foo-bar').should == ['foo', 'bar']
  end

  it "should guess the namespace directory from a project name" do
    subject.namespace_path_of('foo-bar').should == 'foo/bar'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ore-0.2.0 spec/naming_spec.rb
ore-0.1.4 spec/naming_spec.rb
ore-0.1.3 spec/naming_spec.rb
ore-0.1.2 spec/naming_spec.rb