Sha256: 481892d3d02e4fbc2c8a30643b01a2ebfe29bd1397a0644e4b0a1eb6018bad76

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

require "spec_helper"
require "microformats2/absolute_uri"

describe Microformats2::AbsoluteUri do
  describe "#absolutize" do
    subject { Microformats2::AbsoluteUri.new(base, relative).absolutize }
    let(:base) { nil }

    context "when relative is nil" do
      let(:relative) { nil }
      it { should be_nil }
    end

    context "when relative is an empty string" do
      let(:relative) { "" }
      it { should be_nil }
    end

    context "when relative is a valid absolute URI" do
      let(:relative) { "http://google.com" }
      it { should eq("http://google.com/") }
    end

    context "when relative is a valid non-absolute URI" do
      let(:relative) { "bar/qux" }

      context "and base is present but not absolute" do
        let(:base) { "foo" }
        it { should eq("bar/qux") }
      end

      context "and base is present and absolute" do
        let(:base) { "http://google.com" }
        it { should eq("http://google.com/bar/qux") }
      end

      context "and base is not present" do
        let(:base) { nil }
        it { should eq("bar/qux") }
      end
    end

    context "when relative is an invalid URI" do
      let(:relative) { "git@github.com:indieweb/microformats2-ruby.git" }
      it { should eq("git@github.com:indieweb/microformats2-ruby.git") }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
microformats2-2.9.0 spec/lib/microformats2/absolute_uri_spec.rb
microformats2-2.1.0 spec/lib/microformats2/absolute_uri_spec.rb
microformats2-2.0.3 spec/lib/microformats2/absolute_uri_spec.rb
microformats2-2.0.2 spec/lib/microformats2/absolute_uri_spec.rb