Sha256: 5a696a580a48a2ffa81d198ae906a942c7cc1b0789b6f093e2eedd5c8c60c9c3

Contents?: true

Size: 666 Bytes

Versions: 5

Compression:

Stored size: 666 Bytes

Contents

require 'spec_helper'

describe OptParseValidator::OptURL do
  subject(:opt) { described_class.new(['-u', '--url URL']) }

  describe '#validate' do
    context 'when the url is empty' do
      it 'raises an error' do
        expect { opt.validate('') }.to raise_error(Addressable::URI::InvalidURIError)
      end
    end

    context 'when the protocol is not allowed' do
      it 'raises an error' do
        expect { opt.validate('ftp://ftp.domain.com') }
          .to raise_error(Addressable::URI::InvalidURIError)
      end
    end

    it 'returns the url' do
      url = 'https://duckduckgo.com/'

      expect(opt.validate(url)).to eq url
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opt_parse_validator-0.0.9 spec/lib/opt_parse_validator/opts/url_spec.rb
opt_parse_validator-0.0.8 spec/lib/opt_parse_validator/opts/url_spec.rb
opt_parse_validator-0.0.7 spec/lib/opt_parse_validator/opts/url_spec.rb
opt_parse_validator-0.0.6 spec/lib/opt_parse_validator/opts/url_spec.rb
opt_parse_validator-0.0.5 spec/lib/opt_parse_validator/opts/url_spec.rb