Sha256: 9309890a79e33dc1bbe56fa49e379cdafaf13d6125230e60848b0cfdd760b0bb

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

module Raph
  module Parser
    describe AssignmentParser do
      describe '#id' do
        it 'has correct form' do
          expect(subject.id).to eq :assignments
        end
      end

      describe '#parse' do
        it 'returns assignments only' do
          parsed = subject.parse(['-h', '-on=20', '--two=my-file'])
          expect(parsed).to include(:on => '20', :two => 'my-file')
        end

        it 'has no to return assignments here' do
          expect(subject.parse(['-h', 'file', '=', '123'])).to be_empty
          expect(subject.parse([])).to be_empty
        end
      end

      describe '#assignment?' do
        def ass?(option)
          subject.assignment? option
        end

        it 'is an assignment' do
          expect(ass? 'h=one').to be true
          expect(ass? '-ass=two').to be true
          expect(ass? '--ass=two').to be true
        end

        it 'is not as assignment' do
          expect(ass? '-h').to be false
          expect(ass? '-h=').to be false
          expect(ass? 'h=').to be false
          expect(ass? '=').to be false
          expect(ass? '-h=one=two').to be false
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
raph-0.0.3 spec/raph/parser/assinment_parser_spec.rb