Sha256: a74b128769ec4c4a1d4588d820c24fa29b15ec7e44918b49bdcf18be23c02c51

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

require "spec_helper"

RSpec.describe Eman::NameFormatter do

  describe '#initialize' do
    context 'when type is controller' do
      it 'pluralizes the resource' do
        formatter = Eman::NameFormatter.new('Alarm clock', 'Operating', 'Controller')
        expect(formatter.resource).to eq 'Alarm clocks'
      end
    end

    context 'when type is not controller' do
      it 'does not pluralize the resource' do
        formatter = Eman::NameFormatter.new('Alarm clock', 'Operating', 'Service')
        expect(formatter.resource).to eq 'Alarm clock'
      end
    end
  end

  describe '#camel_case!' do
    it 'outsputs a camel cased name' do
      formatter = Eman::NameFormatter.new('cheese', 'grinding', 'Service')
      outcome = formatter.camel_case!

      expect(outcome).to eq 'CheeseGrindingService'
    end

    context 'when type is model' do
      it 'does not append the type at the end' do
        formatter = Eman::NameFormatter.new('Shopping', 'Cart', 'Model')
        outcome = formatter.camel_case!

        expect(outcome).to eq 'ShoppingCart'
      end
    end
  end

  describe '#snake_case!' do
    it 'outputs a snake cased name' do
      formatter = Eman::NameFormatter.new('guitar', 'smashing', 'Service')
      outcome = formatter.snake_case!

      expect(outcome).to eq 'guitar_smashing_service'
    end

    context 'when type is model' do
      it 'does not append the type at the end' do
        formatter = Eman::NameFormatter.new('Shopping', 'Cart', 'Model')
        outcome = formatter.snake_case!

        expect(outcome).to eq 'shopping_cart'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eman-0.0.2 spec/name_formatter_spec.rb