Sha256: 51ce14ebfc56587a8af686166a7c4993c611ddf77d1bc9cd1e1bea7451d42289

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

describe Earl::URL do

  it 'should be able to change the scheme' do
    url = Earl::URL.new 'http://foo.com'
    url.scheme = 'https'
    url.to_s.should eq( 'https://foo.com' )
  end
  it 'should be able to add a scheme' do
    url = Earl::URL.new 'foo.com'
    url.scheme = 'http'
    url.to_s.should eq( 'http://foo.com' )
  end
  it 'should be able to remove the scheme' do
    url = Earl::URL.new 'http://foo.com'
    url.scheme = nil
    url.to_s.should eq( 'foo.com' )
  end

  it 'should be able to change the subdomain' do
    url = Earl::URL.new 'foo.bar.com'
    url.subdomain = 'baz'
    url.to_s.should eq( 'baz.bar.com' )
  end
  it 'should be able to add a subdomain' do
    url = Earl::URL.new 'foo.com'
    url.subdomain = 'bar'
    url.to_s.should eq( 'bar.foo.com' )
  end
  it 'should be able to remove the subdomain' do
    url = Earl::URL.new 'foo.bar.com'
    url.subdomain = nil
    url.to_s.should eq( 'bar.com' )
  end

  it 'should be able to change the host' do
    url = Earl::URL.new 'www.foo.com'
    url.host = 'foo.edu'
    url.to_s.should eq( 'www.foo.edu' )
  end
  it 'should not be able to add a host' do
    expect { url = Earl::URL.new 'http://' }.to raise_error( Earl::InvalidURLError )
  end
  it 'should not be able to remove a host' do
    url = Earl::URL.new 'http://foo.com'
    expect { url.host = nil }.to raise_error( Earl::InvalidURLError )
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
earl-0.2.0 spec/earl/url_spec.rb