Sha256: 5d293c4eadebeb89a1b9b4e7c4d51b712fc0a0717d5ab0294e1d51776bf3455f

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require 'pathname'
require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'

describe DataMapper::Types::URI do

  before(:each) do
    @uri_str = "http://example.com/path/to/resource/"
    @uri = Addressable::URI.parse(@uri_str)
  end

  describe ".dump" do
    it "should return the URI as a String" do
      DataMapper::Types::URI.dump(@uri, :property).should == @uri_str
    end

    it "should return nil if the String is nil" do
      DataMapper::Types::URI.dump(nil, :property).should be_nil
    end

    it "should return an empty URI if the String is empty" do
      DataMapper::Types::URI.dump("", :property).should == ""
    end
  end

  describe ".load" do
    it "should return the URI as Addressable" do
      DataMapper::Types::URI.load(@uri_str, :property).should == @uri
    end

    it "should return nil if given nil" do
      DataMapper::Types::URI.load(nil, :property).should be_nil
    end

    it "should return an empty URI if given an empty String" do
      DataMapper::Types::URI.load("", :property).should == Addressable::URI.parse("")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-types-0.9.2 spec/unit/uri_spec.rb