Sha256: c4cc2f79e00ec1eedbcd67629d9e221d5afa4e4867ef158c2923205fe237488a

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe Gitable::URI, ".heuristic_parse" do
  it "returns a Gitable::URI" do
    uri = "http://github.com/martinemde/gitable"
    Gitable::URI.heuristic_parse(uri).should be_a_kind_of(Gitable::URI)
  end

  [
    "http://host.xz/path/to/repo.git/",
    "http://host.xz/path/to/repo.git",
    "ssh://user@host.xz/path/to/repo.git/",
    "ssh://user@host.xz:1234/path/to/repo.git/",
    "user@host.xz:path/to/repo.git",
    "user@host.xz:path/to/repo.git/",
    "git@github.com:martinemde/gitable.git",
  ].each do |uri|
    it "doesn't break the already valid URI: #{uri.inspect}" do
      Gitable::URI.heuristic_parse(uri).to_s.should == uri
    end
  end

  it "guesses https://github.com/martinemde/gitable.git if I pass in the url bar" do
    uri = "https://github.com/martinemde/gitable"
    gitable = Gitable::URI.heuristic_parse(uri)
    gitable.to_s.should == "https://github.com/martinemde/gitable.git"
  end

  it "isn't upset by trailing slashes" do
    uri = "https://github.com/martinemde/gitable/"
    gitable = Gitable::URI.heuristic_parse(uri)
    gitable.to_s.should == "https://github.com/martinemde/gitable.git/"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gitable-0.2.4 spec/heuristic_parse_spec.rb
gitable-0.2.3 spec/heuristic_parse_spec.rb
gitable-0.2.2 spec/heuristic_parse_spec.rb
gitable-0.2.1 spec/heuristic_parse_spec.rb
gitable-0.2.0 spec/heuristic_parse_spec.rb