require 'spec_helper' describe Earl::URL do describe '#scheme' do context 'when provided' do subject { Earl::URL.new 'http://www.foo.com' } its( :scheme ){ should eq( 'http' ) } its( :scheme? ){ should be_true } it 'should be settable' do subject.scheme = 'https' subject.scheme.should eq( 'https' ) end end context 'when not provided' do subject { Earl::URL.new 'www.foo.com' } its( :scheme ){ should eq( nil ) } its( :scheme? ){ should be_false } it 'should be settable' do subject.scheme = 'https' subject.scheme.should eq( 'https' ) end end end describe '#domain' do pending end describe '#subdomain' do context 'when provided' do subject { Earl::URL.new 'http://www.foo.com' } its( :subdomain ){ should eq( 'www' ) } its( :subdomain? ){ should be_true } it 'should be settable' do subject.subdomain = 'secure' subject.subdomain.should eq( 'secure' ) end end context 'when not provided' do subject { Earl::URL.new 'foo.com' } its( :subdomain ){ should eq( nil ) } its( :subdomain? ){ should be_false } it 'should be settable' do subject.subdomain = 'secure' subject.subdomain.should eq( 'secure' ) end end end describe '#host' do context 'when provided' do subject { Earl::URL.new 'http://www.foo.com' } its( :host ){ should eq( 'foo.com' ) } its( :host? ){ should be_true } it 'should be settable' do subject.host = 'bar.com' subject.host.should eq( 'bar.com' ) end end context 'when not provided' do it 'should raise an error' do expect { Earl::URL.new 'http://' }.to raise_error( URI::InvalidURIError ) end end end describe '#path' do pending end end