Sha256: a66ead0ef5c39187bb30d789ae4d69bab4c3ce9ad46c19245673f2cbdf751cb1

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/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 git://github.com/martinemde/gitable.git if I pass in the url bar" do
    uri = "http://github.com/martinemde/gitable"
    gitable = Gitable::URI.heuristic_parse(uri)
    gitable.to_s.should == "git://github.com/martinemde/gitable.git"
  end

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

  it "handles URIs with the name of the project in the path twice" do
    uri = "http://gitorious.org/project/project"
    gitable = Gitable::URI.heuristic_parse(uri)
    gitable.to_s.should == "git://gitorious.org/project/project.git"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gitable-0.1.3 spec/heuristic_parse_spec.rb
gitable-0.1.2 spec/heuristic_parse_spec.rb
gitable-0.1.1 spec/heuristic_parse_spec.rb
gitable-0.1.0 spec/heuristic_parse_spec.rb
gitable-0.0.3 spec/heuristic_parse_spec.rb