Sha256: 565ff6e26a1a844ae8d4c9c088a00114ee4838a34a3e63e438601b3e689d0d67
Contents?: true
Size: 1.48 KB
Versions: 10
Compression:
Stored size: 1.48 KB
Contents
require 'spec_helper' module BerkeleyLibrary module Util module URIs describe Validator do describe :uri_or_nil do it 'returns a URI unchanged' do uri = URI.parse('http://example.org/') expect(Validator.uri_or_nil(uri)).to be(uri) end it 'converts a string to a URI' do url = 'http://example.org/' expect(Validator.uri_or_nil(url)).to eq(URI.parse(url)) end it 'returns nil for nil' do expect(Validator.uri_or_nil(nil)).to be_nil end it 'raises an error for invalid URL strings' do bad_url = 'not a uri' expect { Validator.uri_or_nil(bad_url) }.to raise_error(URI::InvalidURIError) end end describe :url_str_or_nil do it 'returns a URL string for a URI' do uri = URI.parse('http://example.org/') expect(Validator.url_str_or_nil(uri)).to eq(uri.to_s) end it 'returns a URL string' do url = 'http://example.org/' expect(Validator.url_str_or_nil(url)).to eq(url) end it 'returns nil for nil' do expect(Validator.url_str_or_nil(nil)).to be_nil end it 'raises an error for invalid URL strings' do bad_url = 'not a uri' expect { Validator.url_str_or_nil(bad_url) }.to raise_error(URI::InvalidURIError) end end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems