Sha256: e17beb30018f70bcca5cd0b9ce5cf73baabb8f77d34d56035de7aab254e4971e

Contents?: true

Size: 908 Bytes

Versions: 1

Compression:

Stored size: 908 Bytes

Contents

require "spec_helper"

RSpec.describe Eman::Generator do
  describe '#run' do
    context 'when type is service' do
      it 'should ask two questions' do
        generator = Eman::Generator.new('Service')
        allow($stdin).to receive(:gets) { 'Measure' }

        expect($stdin).to receive(:gets).twice
        generator.run
      end
    end

    context 'when type is not service' do
      it 'should ask one question' do
        generator = Eman::Generator.new('Controller')
        allow($stdin).to receive(:gets) { 'User' }

        expect($stdin).to receive(:gets).once
        generator.run
      end
    end
  end

  describe '#inputs' do
    it 'returns a flat array splited at spaces' do
      generator = Eman::Generator.new('Service')
      generator.resource = 'Alarm clock'
      generator.verb = 'reset'

      expect(generator.inputs).to eq ['Alarm', 'clock', 'reset']
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eman-0.0.3 spec/generator_spec.rb