Sha256: ee084f8f765f472588227d47116cf83281cfd74d1bd1b550f623995ebd1e20c1

Contents?: true

Size: 1.48 KB

Versions: 13

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

require './spec/fixtures/bookmark'

try_spec do
  describe DataMapper::Property::URI do
    before do
      @uri_str = 'http://example.com/path/to/resource/'
      @uri     = Addressable::URI.parse(@uri_str)

      @property = DataMapper::TypesFixtures::Bookmark.properties[:uri]
    end

    describe '.dump' do
      it 'returns the URI as a String' do
        @property.dump(@uri).should == @uri_str
      end

      describe 'when given nil' do
        it 'returns nil' do
          @property.dump(nil).should be_nil
        end
      end

      describe 'when given an empty string' do
        it 'returns an empty URI' do
          @property.dump('').should == ''
        end
      end
    end

    describe '.load' do
      it 'returns the URI as Addressable' do
        @property.load(@uri_str).should == @uri
      end

      describe 'when given nil' do
        it 'returns nil' do
          @property.load(nil).should be_nil
        end
      end

      describe 'if given an empty String' do
        it 'returns an empty URI' do
          @property.load('').should == Addressable::URI.parse('')
        end
      end
    end

    describe '.typecast' do
      describe 'given instance of Addressable::URI' do
        it 'does nothing' do
          @property.typecast(@uri).should == @uri
        end
      end

      describe 'when given a string' do
        it 'delegates to .load' do
          @property.typecast(@uri_str).should == @uri
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
ardm-types-1.2.3 spec/unit/uri_spec.rb
ardm-types-1.2.2 spec/unit/uri_spec.rb
dm-types-1.2.2 spec/unit/uri_spec.rb
dm-types-1.2.1 spec/unit/uri_spec.rb
dm-types-1.2.0 spec/unit/uri_spec.rb
dm-types-1.2.0.rc2 spec/unit/uri_spec.rb
dm-types-1.2.0.rc1 spec/unit/uri_spec.rb
dm-types-1.1.0 spec/unit/uri_spec.rb
dm-types-1.1.0.rc3 spec/unit/uri_spec.rb
dm-types-1.1.0.rc2 spec/unit/uri_spec.rb
dm-types-1.1.0.rc1 spec/unit/uri_spec.rb
dm-types-1.0.2 spec/unit/uri_spec.rb
dm-types-1.0.1 spec/unit/uri_spec.rb