Sha256: 71d2d831955ecd6a244a1b4b0c822d03dcf37f21adb2181d929cc79a8c6bc90a

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'
require 'moblues/cli'

describe Moblues::CLI do
  subject { described_class }
  let(:perform) { subject.start([command] + options, debug: true) }

  context 'when command is invalid' do
    let(:command) { 'invalid' }
    let(:options) { [] }

    it 'fails' do
      expect { perform }.to raise_error
    end
  end

  context 'generate' do
    let(:command) { 'generate' }

    context 'when options missing' do
      let(:options) { [] }

      it 'fails' do
        expect { perform }.to raise_error
      end
    end

    context 'when options given' do
      let(:options) { %w{--model=model/path --human=human/path --machine=machine/path} }

      it 'uses Moblues and defaults to objc' do
        expect(Moblues).to receive(:generate).with('model/path', 'human/path', 'machine/path', :objc).once

        perform
      end

      context 'when using lang option' do
        let(:options) { %w{--model=model/path --human=human/path --machine=machine/path --lang=swift} }

        it 'uses Moblues' do
          expect(Moblues).to receive(:generate).with('model/path', 'human/path', 'machine/path', :swift).once

          perform
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
moblues-0.4.0 spec/lib/moblues/cli_spec.rb
moblues-0.3.0 spec/lib/moblues/cli_spec.rb
moblues-0.2.0 spec/lib/moblues/cli_spec.rb