Sha256: a6e6b6df08ba2693ff372d052e320c3a7466c09c506df95911631d2132dbf9d0

Contents?: true

Size: 615 Bytes

Versions: 3

Compression:

Stored size: 615 Bytes

Contents

require 'spec_helper'

describe OptParseValidator::OptCredentials do

  subject(:opt) { described_class.new(['-l', '--login USERNAME:PASSWORD']) }

  describe '#validate' do
    context 'when incorrect format' do
      it 'raises an error' do
        expect { opt.validate('wrong') }
          .to raise_error 'Incorrect credentials format, username:password expected'
      end
    end

    context 'when valid format' do
      it 'returns a hash with :username and :password' do
        expect(opt.validate('admin:P@ssw:rd'))
          .to eq(username: 'admin', password: 'P@ssw:rd')
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
opt_parse_validator-0.0.4 spec/lib/opt_parse_validator/opts/credentials_spec.rb
opt_parse_validator-0.0.3 spec/lib/opt_parse_validator/opts/credentials_spec.rb
opt_parse_validator-0.0.2 spec/lib/opt_parse_validator/opts/credentials_spec.rb