Sha256: 72e7fe5c0e787d82d0932537bd359c8d214120305290dcba9a4e53d7fe5e32a4

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

require "spec_helper"

RSpec.describe Eman::Formatter do

  describe '#camel_case!' do
    it 'outsputs a camel cased name' do
      generator = Eman::Generator.new('Service')
      generator.resource = 'Cheese Cake'
      generator.verb = 'Grinding'
      formatter = Eman::Formatter.new(generator)
      outcome = formatter.camel_case!

      expect(outcome).to eq 'CheeseCakeGrindingService'
    end

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

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

  describe '#snake_case!' do
    it 'outputs a snake cased name' do
      generator = Eman::Generator.new('Service')
      generator.resource = 'Cheese Cake'
      generator.verb = 'Grinding'
      formatter = Eman::Formatter.new(generator)
      outcome = formatter.snake_case!

      expect(outcome).to eq 'cheese_cake_grinding_service'
    end

    context 'when type is model' do
      it 'does not append the type at the end' do
        generator = Eman::Generator.new('Model')
        generator.resource = 'Shopping Cart'
        formatter = Eman::Formatter.new(generator)
        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.3 spec/formatter_spec.rb