Sha256: 7d39ae92ca32064ee18db83e1ff1bd558c37f5b8670ba363190278d0c2cc679f
Contents?: true
Size: 936 Bytes
Versions: 5
Compression:
Stored size: 936 Bytes
Contents
require 'spec_helper' module Resync RSpec.shared_examples 'a URI field' do # TODO: Find a better way to express this def new_instance(**args) required_args = (defined? required_arguments) ? required_arguments : {} required_args.delete(:uri) args = required_args.merge(args) described_class.new(**args) end it 'accepts a URI' do uri = URI('http://example.org/') instance = new_instance(uri: uri) expect(instance.uri).to eq(uri) end it 'accepts a string URI' do uri = 'http://example.org/' instance = new_instance(uri: uri) expect(instance.uri).to eq(URI(uri)) end it 'rejects an invalid URI' do invalid_url = 'I am not a valid URI' expect { new_instance(uri: invalid_url) }.to raise_error(URI::InvalidURIError) end it 'requires a URI' do expect { new_instance }.to raise_error(ArgumentError) end end end
Version data entries
5 entries across 5 versions & 1 rubygems