diff --git a/lib/gitable/scp_uri.rb b/lib/gitable/scp_uri.rb index 8b71136..65bd2a9 100644 --- a/lib/gitable/scp_uri.rb +++ b/lib/gitable/scp_uri.rb @@ -1,24 +1,24 @@ -require 'addressable/uri' -require 'gitable/uri' +# frozen_string_literal: true + +require "addressable/uri" +require "gitable/uri" module Gitable class ScpURI < Gitable::URI - ## # Deprecated: This serves no purpose. You might as well just parse the URI. def self.scp?(uri) - $stderr.puts "DEPRECATED: Gitable::ScpURI.scp?. You're better off parsing the URI and checking #scp?." + warn "DEPRECATED: Gitable::ScpURI.scp?. You're better off parsing the URI and checking #scp?." Gitable::URI.parse(uri).scp? end ## # Deprecated: This serves no purpose. Just use Gitable::URI.parse. def self.parse(uri) - $stderr.puts "DEPRECATED: Gitable::ScpURI.parse just runs Gitable::URI.parse. Please use this directly." + warn "DEPRECATED: Gitable::ScpURI.parse just runs Gitable::URI.parse. Please use this directly." Gitable::URI.parse(uri) end - # Keep URIs like this as they were input: # # git@github.com:martinemde/gitable.git @@ -31,7 +31,7 @@ def self.parse(uri) # @return [String] The same path passed in. def path=(new_path) super - if new_path[0] != '/' # addressable adds a / but scp-style uris are altered by this behavior + if new_path[0] != "/" # addressable adds a / but scp-style uris are altered by this behavior @path = path.delete_prefix("/") @normalized_path = nil validate @@ -47,13 +47,13 @@ def path=(new_path) def to_s @uri_string ||= "#{normalized_authority}:#{normalized_path}".force_encoding(Encoding::UTF_8) end - alias to_str to_s + alias_method :to_str, :to_s # Return the actual scheme even though we don't show it # # @return [String] always 'ssh' for scp style URIs def inferred_scheme - 'ssh' + "ssh" end # Scp style URIs are always ssh @@ -95,7 +95,7 @@ def validate end def invalid!(reason) - raise InvalidURIError, "#{reason}: '#{to_s}'" + raise InvalidURIError, "#{reason}: '#{self}'" end end end diff --git a/lib/gitable/uri.rb b/lib/gitable/uri.rb index 9f25595..bcc6e23 100644 --- a/lib/gitable/uri.rb +++ b/lib/gitable/uri.rb @@ -1,9 +1,11 @@ -require 'addressable/uri' +# frozen_string_literal: true + +require "addressable/uri" module Gitable class URI < Addressable::URI - SCP_REGEXP = %r|^([^:/?#]+):([^:?#]*)$| - URIREGEX = %r|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$| + SCP_REGEXP = %r{^([^:/?#]+):([^:?#]*)$} + URIREGEX = %r{^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$} ## # Parse a git repository URI into a URI object. @@ -25,7 +27,7 @@ def self.parse(uri) # convert it to a string, then parse the string. # We do the check this way because we don't want to accidentally # cause a missing constant exception to be thrown. - if uri.class.name =~ /^URI\b/ + if /^URI\b/.match?(uri.class.name) uri = uri.to_s end @@ -38,15 +40,15 @@ def self.parse(uri) # This Regexp supplied as an example in RFC 3986, and it works great. fragments = uri.scan(URIREGEX)[0] - scheme = fragments[1] + scheme = fragments[1] authority = fragments[3] - path = fragments[4] - query = fragments[6] - fragment = fragments[8] + path = fragments[4] + query = fragments[6] + fragment = fragments[8] host = nil if authority - host = authority.gsub(/^([^\[\]]*)@/, '').gsub(/:([^:@\[\]]*?)$/, '') + host = authority.gsub(/^([^\[\]]*)@/, "").gsub(/:([^:@\[\]]*?)$/, "") else authority = scheme end @@ -126,7 +128,7 @@ def bitbucket? end def host_match?(host) - normalized_host && normalized_host.include?(host) + normalized_host&.include?(host) end # Create a web link uri for repositories that follow the github pattern. @@ -137,9 +139,9 @@ def host_match?(host) # # @param [String] Scheme of the web uri (smart defaults) # @return [Addressable::URI] https://#{host}/#{path_without_git_extension} - def to_web_uri(uri_scheme='https') + def to_web_uri(uri_scheme = "https") return nil if normalized_host.to_s.empty? - Addressable::URI.new(:scheme => uri_scheme, :host => normalized_host, :port => normalized_port, :path => normalized_path.sub(%r#\.git/?$#, '')) + Addressable::URI.new(scheme: uri_scheme, host: normalized_host, port: normalized_port, path: normalized_path.sub(%r{\.git/?$}, "")) end # Tries to guess the project name of the repository. @@ -162,17 +164,17 @@ def org_project # # @return [Boolean] Is the URI local def local? - inferred_scheme == 'file' + inferred_scheme == "file" end # Scheme inferred by the URI (URIs without hosts or schemes are assumed to be 'file') # # @return [Boolean] Is the URI local def inferred_scheme - if normalized_scheme == 'file' - 'file' + if normalized_scheme == "file" + "file" elsif (normalized_scheme.nil? || normalized_scheme.empty?) && (normalized_host.nil? || normalized_host.empty?) - 'file' + "file" else normalized_scheme end @@ -226,7 +228,7 @@ def equivalent?(other_uri) else # if the path is absolute, we can assume it's the same for all users (so the user doesn't have to match). normalized_path.delete_suffix("/") == other.normalized_path.delete_suffix("/") && - (path[0] == '/' || normalized_user == other.normalized_user) + (path[0] == "/" || normalized_user == other.normalized_user) end end @@ -234,7 +236,7 @@ def equivalent?(other_uri) # # @return [String] I'll get you next time Gadget, NEXT TIME! def inspect - "#<#{self.class.to_s} #{to_s}>" + "#<#{self.class} #{self}>" end # Set an extension name, replacing one if it exists. @@ -247,9 +249,8 @@ def inspect # @param [String] New extension name # @return [String] extname result def extname=(new_ext) - return nil if basename.to_s.empty? - self.basename = "#{basename.sub(%r#\.git/?$#, '')}.#{new_ext.sub(/^\.+/,'')}" - extname + return if basename.to_s.empty? + self.basename = "#{basename.sub(%r{\.git/?$}, "")}.#{new_ext.sub(/^\.+/, "")}" end # Set the '.git' extension name, replacing one if it exists. @@ -265,7 +266,7 @@ def set_git_extname # Addressable does basename wrong when there's no basename. # It returns "/" for something like "http://host.com/" def basename - super == "/" ? "" : super + (super == "/") ? "" : super end # Set the basename, replacing it if it exists. @@ -279,11 +280,11 @@ def basename=(new_basename) else rpath = normalized_path.reverse # replace the last occurrence of the basename with basename.ext - self.path = rpath.sub(%r|#{Regexp.escape(base.reverse)}|, new_basename.reverse).reverse + self.path = rpath.sub(%r{#{Regexp.escape(base.reverse)}}, new_basename.reverse).reverse end basename end end end -require 'gitable/scp_uri' +require "gitable/scp_uri" diff --git a/spec/describe_uri.rb b/spec/describe_uri.rb index de2fec4..775214d 100644 --- a/spec/describe_uri.rb +++ b/spec/describe_uri.rb @@ -21,8 +21,12 @@ def it_sets(parts) end end - def method_missing(*args, &block) - @example_group.send(*args, &block) + def method_missing(...) + @example_group.send(...) + end + + def respond_to_missing?(...) + @example_group.respond_to_missing?(...) end end end diff --git a/spec/gitable_spec.rb b/spec/gitable_spec.rb index 40370d3..7f50a4a 100644 --- a/spec/gitable_spec.rb +++ b/spec/gitable_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" describe Gitable::URI do describe_uri "git://github.com/martinemde/gitable" do @@ -116,7 +116,7 @@ "http://", # nothing but scheme "blah:", # pretty much nothing "user@:path.git", # no host - "user@host:", # no path + "user@host:" # no path ].each do |uri| context uri.inspect do it "raises an Gitable::URI::InvalidURIError" do @@ -130,7 +130,7 @@ end it "is not equivalent to a bad uri" do - expect(Gitable::URI.parse('git://github.com/martinemde/gitable.git')).to_not be_equivalent(uri) + expect(Gitable::URI.parse("git://github.com/martinemde/gitable.git")).to_not be_equivalent(uri) end end end @@ -138,725 +138,725 @@ context "scp uris" do it "raises without path" do expect { - Gitable::ScpURI.new(:user => 'git', :host => 'github.com') + Gitable::ScpURI.new(user: "git", host: "github.com") }.to raise_error(Gitable::URI::InvalidURIError) end it "raises without host" do expect { - Gitable::ScpURI.new(:user => 'git', :path => 'path') + Gitable::ScpURI.new(user: "git", path: "path") }.to raise_error(Gitable::URI::InvalidURIError) end it "raises with any scheme" do expect { - Gitable::ScpURI.new(:scheme => 'ssh', :host => 'github.com', :path => 'path') + Gitable::ScpURI.new(scheme: "ssh", host: "github.com", path: "path") }.to raise_error(Gitable::URI::InvalidURIError) end it "raises with any port" do expect { - Gitable::ScpURI.new(:port => 88, :host => 'github.com', :path => 'path') + Gitable::ScpURI.new(port: 88, host: "github.com", path: "path") }.to raise_error(Gitable::URI::InvalidURIError) end end end expected = { - :user => nil, - :password => nil, - :host => "host.xz", - :port => nil, - :path => "/path/to/repo.git/", - :basename => "repo.git", - :query => nil, - :fragment => nil, - :project_name => "repo", - :local? => false, - :ssh? => false, - :authenticated? => false, - :interactive_authenticated? => false, - :to_web_uri => Addressable::URI.parse("https://host.xz/path/to/repo"), + user: nil, + password: nil, + host: "host.xz", + port: nil, + path: "/path/to/repo.git/", + basename: "repo.git", + query: nil, + fragment: nil, + project_name: "repo", + local?: false, + ssh?: false, + authenticated?: false, + interactive_authenticated?: false, + to_web_uri: Addressable::URI.parse("https://host.xz/path/to/repo") } describe_uri "rsync://host.xz/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "rsync", - :project_name => "repo" + scheme: "rsync", + project_name: "repo" }) end describe_uri "rsync://host.xz/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "rsync", + scheme: "rsync" }) end describe_uri "http://host.xz/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "http", + scheme: "http" }) end describe_uri "http://host.xz:8888/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "http", - :port => 8888, - :to_web_uri => Addressable::URI.parse("https://host.xz:8888/path/to/repo") + scheme: "http", + port: 8888, + to_web_uri: Addressable::URI.parse("https://host.xz:8888/path/to/repo") }) end describe_uri "http://12.34.56.78:8888/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "http", - :host => "12.34.56.78", - :port => 8888, - :to_web_uri => Addressable::URI.parse("https://12.34.56.78:8888/path/to/repo") + scheme: "http", + host: "12.34.56.78", + port: 8888, + to_web_uri: Addressable::URI.parse("https://12.34.56.78:8888/path/to/repo") }) end describe_uri "https://host.xz/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "https", + scheme: "https" }) end describe_uri "https://user@host.xz/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "https", - :user => "user", - :interactive_authenticated? => true, - :authenticated? => true, + scheme: "https", + user: "user", + interactive_authenticated?: true, + authenticated?: true }) end describe_uri "https://host.xz:8888/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "https", - :port => 8888, - :to_web_uri => Addressable::URI.parse("https://host.xz:8888/path/to/repo") + scheme: "https", + port: 8888, + to_web_uri: Addressable::URI.parse("https://host.xz:8888/path/to/repo") }) end describe_uri "git+ssh://host.xz/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "git+ssh", - :ssh? => true, - :authenticated? => true, + scheme: "git+ssh", + ssh?: true, + authenticated?: true }) end describe_uri "git://host.xz/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "git", + scheme: "git" }) end describe_uri "git://host.xz:8888/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "git", - :port => 8888, - :to_web_uri => Addressable::URI.parse("https://host.xz:8888/path/to/repo") + scheme: "git", + port: 8888, + to_web_uri: Addressable::URI.parse("https://host.xz:8888/path/to/repo") }) end describe_uri "git://host.xz/~user/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "git", - :path => "/~user/path/to/repo.git/", - :to_web_uri => Addressable::URI.parse("https://host.xz/~user/path/to/repo") + scheme: "git", + path: "/~user/path/to/repo.git/", + to_web_uri: Addressable::URI.parse("https://host.xz/~user/path/to/repo") }) end describe_uri "git://host.xz:8888/~user/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "git", - :path => "/~user/path/to/repo.git/", - :port => 8888, - :to_web_uri => Addressable::URI.parse("https://host.xz:8888/~user/path/to/repo") + scheme: "git", + path: "/~user/path/to/repo.git/", + port: 8888, + to_web_uri: Addressable::URI.parse("https://host.xz:8888/~user/path/to/repo") }) end describe_uri "ssh://host.xz/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "ssh", - :ssh? => true, - :authenticated? => true, + scheme: "ssh", + ssh?: true, + authenticated?: true }) end describe_uri "ssh://user@host.xz/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "ssh", - :user => "user", - :ssh? => true, - :authenticated? => true, + scheme: "ssh", + user: "user", + ssh?: true, + authenticated?: true }) end describe_uri "ssh://host.xz/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "ssh", - :ssh? => true, - :authenticated? => true, + scheme: "ssh", + ssh?: true, + authenticated?: true }) end describe_uri "ssh://host.xz:8888/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "ssh", - :port => 8888, - :ssh? => true, - :authenticated? => true, - :to_web_uri => Addressable::URI.parse("https://host.xz:8888/path/to/repo") + scheme: "ssh", + port: 8888, + ssh?: true, + authenticated?: true, + to_web_uri: Addressable::URI.parse("https://host.xz:8888/path/to/repo") }) end describe_uri "ssh://user@host.xz/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :user => "user", - :scheme => "ssh", - :ssh? => true, - :authenticated? => true, + user: "user", + scheme: "ssh", + ssh?: true, + authenticated?: true }) end describe_uri "ssh://user@host.xz:8888/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "ssh", - :user => "user", - :port => 8888, - :ssh? => true, - :authenticated? => true, - :to_web_uri => Addressable::URI.parse("https://host.xz:8888/path/to/repo") + scheme: "ssh", + user: "user", + port: 8888, + ssh?: true, + authenticated?: true, + to_web_uri: Addressable::URI.parse("https://host.xz:8888/path/to/repo") }) end describe_uri "ssh://host.xz/~user/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "ssh", - :user => nil, - :path => "/~user/path/to/repo.git/", - :ssh? => true, - :authenticated? => true, - :to_web_uri => Addressable::URI.parse("https://host.xz/~user/path/to/repo") + scheme: "ssh", + user: nil, + path: "/~user/path/to/repo.git/", + ssh?: true, + authenticated?: true, + to_web_uri: Addressable::URI.parse("https://host.xz/~user/path/to/repo") }) end describe_uri "ssh://user@host.xz/~user/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "ssh", - :user => "user", - :path => "/~user/path/to/repo.git/", - :ssh? => true, - :authenticated? => true, - :to_web_uri => Addressable::URI.parse("https://host.xz/~user/path/to/repo") + scheme: "ssh", + user: "user", + path: "/~user/path/to/repo.git/", + ssh?: true, + authenticated?: true, + to_web_uri: Addressable::URI.parse("https://host.xz/~user/path/to/repo") }) end describe_uri "ssh://host.xz/~/path/to/repo.git" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "ssh", - :path => "/~/path/to/repo.git", - :ssh? => true, - :authenticated? => true, - :to_web_uri => Addressable::URI.parse("https://host.xz/~/path/to/repo") + scheme: "ssh", + path: "/~/path/to/repo.git", + ssh?: true, + authenticated?: true, + to_web_uri: Addressable::URI.parse("https://host.xz/~/path/to/repo") }) end describe_uri "ssh://user@host.xz/~/path/to/repo.git" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => "ssh", - :user => "user", - :path => "/~/path/to/repo.git", - :ssh? => true, - :authenticated? => true, - :to_web_uri => Addressable::URI.parse("https://host.xz/~/path/to/repo") + scheme: "ssh", + user: "user", + path: "/~/path/to/repo.git", + ssh?: true, + authenticated?: true, + to_web_uri: Addressable::URI.parse("https://host.xz/~/path/to/repo") }) end describe_uri "host.xz:/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => nil, - :inferred_scheme => 'ssh', - :user => nil, - :path => "/path/to/repo.git/", - :ssh? => true, - :authenticated? => true, + scheme: nil, + inferred_scheme: "ssh", + user: nil, + path: "/path/to/repo.git/", + ssh?: true, + authenticated?: true }) end describe_uri "user@host.xz:/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } - it { expect(subject).to be_equivalent('ssh://user@host.xz/path/to/repo.git') } - it { expect(subject).to be_equivalent('user@host.xz:/path/to/repo.git') } - it { expect(subject).to_not be_equivalent('user@host.xz:path/to/repo.git') } # not absolute - it { expect(subject).to_not be_equivalent('/path/to/repo.git') } - it { expect(subject).to_not be_equivalent('host.xz:path/to/repo.git') } + it { expect(subject.to_s).to eq(@uri) } + it { expect(subject).to be_equivalent("ssh://user@host.xz/path/to/repo.git") } + it { expect(subject).to be_equivalent("user@host.xz:/path/to/repo.git") } + it { expect(subject).to_not be_equivalent("user@host.xz:path/to/repo.git") } # not absolute + it { expect(subject).to_not be_equivalent("/path/to/repo.git") } + it { expect(subject).to_not be_equivalent("host.xz:path/to/repo.git") } it_sets expected.merge({ - :scheme => nil, - :inferred_scheme => 'ssh', - :user => "user", - :path => "/path/to/repo.git/", - :ssh? => true, - :authenticated? => true, + scheme: nil, + inferred_scheme: "ssh", + user: "user", + path: "/path/to/repo.git/", + ssh?: true, + authenticated?: true }) end describe_uri "host.xz:~user/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => nil, - :inferred_scheme => 'ssh', - :user => nil, - :path => "~user/path/to/repo.git/", - :ssh? => true, - :authenticated? => true, - :to_web_uri => Addressable::URI.parse("https://host.xz/~user/path/to/repo") + scheme: nil, + inferred_scheme: "ssh", + user: nil, + path: "~user/path/to/repo.git/", + ssh?: true, + authenticated?: true, + to_web_uri: Addressable::URI.parse("https://host.xz/~user/path/to/repo") }) end describe_uri "user@host.xz:~user/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => nil, - :inferred_scheme => 'ssh', - :user => "user", - :path => "~user/path/to/repo.git/", - :ssh? => true, - :authenticated? => true, - :to_web_uri => Addressable::URI.parse("https://host.xz/~user/path/to/repo") + scheme: nil, + inferred_scheme: "ssh", + user: "user", + path: "~user/path/to/repo.git/", + ssh?: true, + authenticated?: true, + to_web_uri: Addressable::URI.parse("https://host.xz/~user/path/to/repo") }) end describe_uri "host.xz:path/to/repo.git" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } + it { expect(subject.to_s).to eq(@uri) } it_sets expected.merge({ - :scheme => nil, - :inferred_scheme => 'ssh', - :user => nil, - :path => "path/to/repo.git", - :ssh? => true, - :authenticated? => true, + scheme: nil, + inferred_scheme: "ssh", + user: nil, + path: "path/to/repo.git", + ssh?: true, + authenticated?: true }) end describe_uri "user@host.xz:path/to/repo.git" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } - it { expect(subject).to_not be_equivalent('ssh://user@host.xz/path/to/repo.git') } # not absolute - it { expect(subject).to_not be_equivalent('path/to/repo.git') } - it { expect(subject).to_not be_equivalent('host.xz:path/to/repo.git') } - it { expect(subject).to_not be_equivalent('user@host.xz:/path/to/repo.git') } + it { expect(subject.to_s).to eq(@uri) } + it { expect(subject).to_not be_equivalent("ssh://user@host.xz/path/to/repo.git") } # not absolute + it { expect(subject).to_not be_equivalent("path/to/repo.git") } + it { expect(subject).to_not be_equivalent("host.xz:path/to/repo.git") } + it { expect(subject).to_not be_equivalent("user@host.xz:/path/to/repo.git") } it_sets expected.merge({ - :scheme => nil, - :inferred_scheme => "ssh", - :user => "user", - :path => "path/to/repo.git", - :ssh? => true, - :authenticated? => true, + scheme: nil, + inferred_scheme: "ssh", + user: "user", + path: "path/to/repo.git", + ssh?: true, + authenticated?: true }) end describe_uri "/path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } - it { expect(subject.inspect).to match(%r|^#$|) } + it { expect(subject.to_s).to eq(@uri) } + it { expect(subject.inspect).to match(%r{^#$}) } it { expect(subject).to be_equivalent(@uri) } - it { expect(subject).to be_equivalent('/path/to/repo.git') } - it { expect(subject).to be_equivalent('file:///path/to/repo.git') } - it { expect(subject).to be_equivalent('file:///path/to/repo.git/') } - it { expect(subject).to_not be_equivalent('/path/to/repo/.git') } - it { expect(subject).to_not be_equivalent('file:///not/path/repo.git') } + it { expect(subject).to be_equivalent("/path/to/repo.git") } + it { expect(subject).to be_equivalent("file:///path/to/repo.git") } + it { expect(subject).to be_equivalent("file:///path/to/repo.git/") } + it { expect(subject).to_not be_equivalent("/path/to/repo/.git") } + it { expect(subject).to_not be_equivalent("file:///not/path/repo.git") } it_sets expected.merge({ - :scheme => nil, - :inferred_scheme => "file", - :host => nil, - :path => "/path/to/repo.git/", - :local? => true, - :to_web_uri => nil, + scheme: nil, + inferred_scheme: "file", + host: nil, + path: "/path/to/repo.git/", + local?: true, + to_web_uri: nil }) end describe_uri "file:///path/to/repo.git/" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } - it { expect(subject.inspect).to match(%r|^#$|) } + it { expect(subject.to_s).to eq(@uri) } + it { expect(subject.inspect).to match(%r{^#$}) } it { expect(subject).to be_equivalent(@uri) } - it { expect(subject).to be_equivalent('/path/to/repo.git') } - it { expect(subject).to be_equivalent('file:///path/to/repo.git') } - it { expect(subject).to be_equivalent('/path/to/repo.git/') } - it { expect(subject).to_not be_equivalent('/path/to/repo/.git') } - it { expect(subject).to_not be_equivalent('file:///not/path/repo.git') } + it { expect(subject).to be_equivalent("/path/to/repo.git") } + it { expect(subject).to be_equivalent("file:///path/to/repo.git") } + it { expect(subject).to be_equivalent("/path/to/repo.git/") } + it { expect(subject).to_not be_equivalent("/path/to/repo/.git") } + it { expect(subject).to_not be_equivalent("file:///not/path/repo.git") } it_sets expected.merge({ - :scheme => "file", - :inferred_scheme => "file", - :host => "", - :path => "/path/to/repo.git/", - :local? => true, - :to_web_uri => nil, + scheme: "file", + inferred_scheme: "file", + host: "", + path: "/path/to/repo.git/", + local?: true, + to_web_uri: nil }) end describe_uri "ssh://git@github.com/martinemde/gitable.git" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } - it { expect(subject.inspect).to match(%r|^#$|) } + it { expect(subject.to_s).to eq(@uri) } + it { expect(subject.inspect).to match(%r{^#$}) } it { expect(subject).to be_equivalent(@uri) } - it { expect(subject).to be_equivalent('git://github.com/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@github.com:martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@github.com:/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('https://martinemde@github.com/martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@github.com:martinemde/not_gitable.git') } + it { expect(subject).to be_equivalent("git://github.com/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@github.com:martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@github.com:/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("https://martinemde@github.com/martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@othergit.com:martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@github.com:martinemde/not_gitable.git") } it_sets({ - :scheme => "ssh", - :user => "git", - :password => nil, - :host => "github.com", - :port => nil, - :path => "/martinemde/gitable.git", - :fragment => nil, - :basename => "gitable.git", - :ssh? => true, - :scp? => false, - :authenticated? => true, - :interactive_authenticated? => false, - :github? => true, - :gitlab? => false, - :bitbucket? => false, - :to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"), + scheme: "ssh", + user: "git", + password: nil, + host: "github.com", + port: nil, + path: "/martinemde/gitable.git", + fragment: nil, + basename: "gitable.git", + ssh?: true, + scp?: false, + authenticated?: true, + interactive_authenticated?: false, + github?: true, + gitlab?: false, + bitbucket?: false, + to_web_uri: Addressable::URI.parse("https://github.com/martinemde/gitable") }) end describe_uri "https://github.com/martinemde/gitable.git" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } - it { expect(subject.inspect).to match(%r|^#$|) } + it { expect(subject.to_s).to eq(@uri) } + it { expect(subject.inspect).to match(%r{^#$}) } it { expect(subject).to be_equivalent(@uri) } - it { expect(subject).to be_equivalent('ssh://git@github.com/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git://github.com/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@github.com:martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@github.com:/martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@github.com:martinemde/not_gitable.git') } + it { expect(subject).to be_equivalent("ssh://git@github.com/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git://github.com/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@github.com:martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@github.com:/martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@othergit.com:martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@github.com:martinemde/not_gitable.git") } it_sets({ - :scheme => "https", - :user => nil, - :password => nil, - :host => "github.com", - :port => nil, - :path => "/martinemde/gitable.git", - :fragment => nil, - :basename => "gitable.git", - :ssh? => false, - :scp? => false, - :github? => true, - :gitlab? => false, - :bitbucket? => false, - :to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"), + scheme: "https", + user: nil, + password: nil, + host: "github.com", + port: nil, + path: "/martinemde/gitable.git", + fragment: nil, + basename: "gitable.git", + ssh?: false, + scp?: false, + github?: true, + gitlab?: false, + bitbucket?: false, + to_web_uri: Addressable::URI.parse("https://github.com/martinemde/gitable") }) end describe_uri "https://martinemde@github.com/martinemde/gitable.git" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } - it { expect(subject.inspect).to match(%r|^#$|) } + it { expect(subject.to_s).to eq(@uri) } + it { expect(subject.inspect).to match(%r{^#$}) } it { expect(subject).to be_equivalent(@uri) } - it { expect(subject).to be_equivalent('ssh://git@github.com/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git://github.com/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@github.com:martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@github.com:/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('https://github.com/martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@github.com:martinemde/not_gitable.git') } + it { expect(subject).to be_equivalent("ssh://git@github.com/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git://github.com/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@github.com:martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@github.com:/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("https://github.com/martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@othergit.com:martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@github.com:martinemde/not_gitable.git") } it_sets({ - :scheme => "https", - :user => "martinemde", - :password => nil, - :host => "github.com", - :port => nil, - :path => "/martinemde/gitable.git", - :fragment => nil, - :basename => "gitable.git", - :ssh? => false, - :scp? => false, - :github? => true, - :gitlab? => false, - :bitbucket? => false, - :authenticated? => true, - :interactive_authenticated? => true, - :to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"), + scheme: "https", + user: "martinemde", + password: nil, + host: "github.com", + port: nil, + path: "/martinemde/gitable.git", + fragment: nil, + basename: "gitable.git", + ssh?: false, + scp?: false, + github?: true, + gitlab?: false, + bitbucket?: false, + authenticated?: true, + interactive_authenticated?: true, + to_web_uri: Addressable::URI.parse("https://github.com/martinemde/gitable") }) end describe_uri "git://github.com/martinemde/gitable.git" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } - it { expect(subject.inspect).to match(%r|^#$|) } + it { expect(subject.to_s).to eq(@uri) } + it { expect(subject.inspect).to match(%r{^#$}) } it { expect(subject).to be_equivalent(@uri) } - it { expect(subject).to be_equivalent('ssh://git@github.com/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@github.com:martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@github.com:/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('https://martinemde@github.com/martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@github.com:martinemde/not_gitable.git') } + it { expect(subject).to be_equivalent("ssh://git@github.com/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@github.com:martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@github.com:/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("https://martinemde@github.com/martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@othergit.com:martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@github.com:martinemde/not_gitable.git") } it_sets({ - :scheme => "git", - :user => nil, - :password => nil, - :host => "github.com", - :port => nil, - :path => "/martinemde/gitable.git", - :fragment => nil, - :basename => "gitable.git", - :ssh? => false, - :scp? => false, - :github? => true, - :gitlab? => false, - :bitbucket? => false, - :authenticated? => false, - :interactive_authenticated? => false, - :to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"), + scheme: "git", + user: nil, + password: nil, + host: "github.com", + port: nil, + path: "/martinemde/gitable.git", + fragment: nil, + basename: "gitable.git", + ssh?: false, + scp?: false, + github?: true, + gitlab?: false, + bitbucket?: false, + authenticated?: false, + interactive_authenticated?: false, + to_web_uri: Addressable::URI.parse("https://github.com/martinemde/gitable") }) end describe_uri "git@github.com:martinemde/gitable.git" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } - it { expect(subject.inspect).to match(%r|^#$|) } + it { expect(subject.to_s).to eq(@uri) } + it { expect(subject.inspect).to match(%r{^#$}) } it { expect(subject).to be_equivalent(@uri) } - it { expect(subject).to be_equivalent('ssh://git@github.com/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git://github.com/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('https://martinemde@github.com/martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@github.com:martinemde/not_gitable.git') } + it { expect(subject).to be_equivalent("ssh://git@github.com/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git://github.com/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("https://martinemde@github.com/martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@othergit.com:martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@github.com:martinemde/not_gitable.git") } it_sets({ - :scheme => nil, - :inferred_scheme => 'ssh', - :user => "git", - :password => nil, - :host => "github.com", - :port => nil, - :path => "martinemde/gitable.git", - :fragment => nil, - :basename => "gitable.git", - :project_name => "gitable", - :ssh? => true, - :scp? => true, - :authenticated? => true, - :interactive_authenticated? => false, - :github? => true, - :gitlab? => false, - :bitbucket? => false, - :to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"), + scheme: nil, + inferred_scheme: "ssh", + user: "git", + password: nil, + host: "github.com", + port: nil, + path: "martinemde/gitable.git", + fragment: nil, + basename: "gitable.git", + project_name: "gitable", + ssh?: true, + scp?: true, + authenticated?: true, + interactive_authenticated?: false, + github?: true, + gitlab?: false, + bitbucket?: false, + to_web_uri: Addressable::URI.parse("https://github.com/martinemde/gitable") }) end describe_uri "ssh://git@bitbucket.org/martinemde/gitable.git" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } - it { expect(subject.inspect).to match(%r|^#$|) } + it { expect(subject.to_s).to eq(@uri) } + it { expect(subject.inspect).to match(%r{^#$}) } it { expect(subject).to be_equivalent(@uri) } - it { expect(subject).to be_equivalent('git://bitbucket.org/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@bitbucket.org:martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@bitbucket.org:/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('https://martinemde@bitbucket.org/martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@bitbucket.org:martinemde/not_gitable.git') } + it { expect(subject).to be_equivalent("git://bitbucket.org/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@bitbucket.org:martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@bitbucket.org:/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("https://martinemde@bitbucket.org/martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@othergit.com:martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@bitbucket.org:martinemde/not_gitable.git") } it_sets({ - :scheme => "ssh", - :user => "git", - :password => nil, - :host => "bitbucket.org", - :port => nil, - :path => "/martinemde/gitable.git", - :fragment => nil, - :basename => "gitable.git", - :ssh? => true, - :scp? => false, - :authenticated? => true, - :interactive_authenticated? => false, - :github? => false, - :gitlab? => false, - :bitbucket? => true, - :to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"), + scheme: "ssh", + user: "git", + password: nil, + host: "bitbucket.org", + port: nil, + path: "/martinemde/gitable.git", + fragment: nil, + basename: "gitable.git", + ssh?: true, + scp?: false, + authenticated?: true, + interactive_authenticated?: false, + github?: false, + gitlab?: false, + bitbucket?: true, + to_web_uri: Addressable::URI.parse("https://bitbucket.org/martinemde/gitable") }) end describe_uri "https://bitbucket.org/martinemde/gitable.git" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } - it { expect(subject.inspect).to match(%r|^#$|) } + it { expect(subject.to_s).to eq(@uri) } + it { expect(subject.inspect).to match(%r{^#$}) } it { expect(subject).to be_equivalent(@uri) } - it { expect(subject).to be_equivalent('ssh://git@bitbucket.org/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git://bitbucket.org/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@bitbucket.org:martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@bitbucket.org:/martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@bitbucket.org:martinemde/not_gitable.git') } + it { expect(subject).to be_equivalent("ssh://git@bitbucket.org/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git://bitbucket.org/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@bitbucket.org:martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@bitbucket.org:/martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@othergit.com:martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@bitbucket.org:martinemde/not_gitable.git") } it_sets({ - :scheme => "https", - :user => nil, - :password => nil, - :host => "bitbucket.org", - :port => nil, - :path => "/martinemde/gitable.git", - :fragment => nil, - :basename => "gitable.git", - :ssh? => false, - :scp? => false, - :github? => false, - :gitlab? => false, - :bitbucket? => true, - :to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"), + scheme: "https", + user: nil, + password: nil, + host: "bitbucket.org", + port: nil, + path: "/martinemde/gitable.git", + fragment: nil, + basename: "gitable.git", + ssh?: false, + scp?: false, + github?: false, + gitlab?: false, + bitbucket?: true, + to_web_uri: Addressable::URI.parse("https://bitbucket.org/martinemde/gitable") }) end describe_uri "https://martinemde@bitbucket.org/martinemde/gitable.git" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } - it { expect(subject.inspect).to match(%r|^#$|) } + it { expect(subject.to_s).to eq(@uri) } + it { expect(subject.inspect).to match(%r{^#$}) } it { expect(subject).to be_equivalent(@uri) } - it { expect(subject).to be_equivalent('ssh://git@bitbucket.org/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git://bitbucket.org/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@bitbucket.org:martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@bitbucket.org:/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('https://bitbucket.org/martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@bitbucket.org:martinemde/not_gitable.git') } + it { expect(subject).to be_equivalent("ssh://git@bitbucket.org/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git://bitbucket.org/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@bitbucket.org:martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@bitbucket.org:/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("https://bitbucket.org/martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@othergit.com:martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@bitbucket.org:martinemde/not_gitable.git") } it_sets({ - :scheme => "https", - :user => "martinemde", - :password => nil, - :host => "bitbucket.org", - :port => nil, - :path => "/martinemde/gitable.git", - :fragment => nil, - :basename => "gitable.git", - :ssh? => false, - :scp? => false, - :github? => false, - :gitlab? => false, - :bitbucket? => true, - :authenticated? => true, - :interactive_authenticated? => true, - :to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"), + scheme: "https", + user: "martinemde", + password: nil, + host: "bitbucket.org", + port: nil, + path: "/martinemde/gitable.git", + fragment: nil, + basename: "gitable.git", + ssh?: false, + scp?: false, + github?: false, + gitlab?: false, + bitbucket?: true, + authenticated?: true, + interactive_authenticated?: true, + to_web_uri: Addressable::URI.parse("https://bitbucket.org/martinemde/gitable") }) end describe_uri "git://bitbucket.org/martinemde/gitable.git" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } - it { expect(subject.inspect).to match(%r|^#$|) } + it { expect(subject.to_s).to eq(@uri) } + it { expect(subject.inspect).to match(%r{^#$}) } it { expect(subject).to be_equivalent(@uri) } - it { expect(subject).to be_equivalent('ssh://git@bitbucket.org/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@bitbucket.org:martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git@bitbucket.org:/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('https://martinemde@bitbucket.org/martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@bitbucket.org:martinemde/not_gitable.git') } + it { expect(subject).to be_equivalent("ssh://git@bitbucket.org/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@bitbucket.org:martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git@bitbucket.org:/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("https://martinemde@bitbucket.org/martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@othergit.com:martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@bitbucket.org:martinemde/not_gitable.git") } it_sets({ - :scheme => "git", - :user => nil, - :password => nil, - :host => "bitbucket.org", - :port => nil, - :path => "/martinemde/gitable.git", - :fragment => nil, - :basename => "gitable.git", - :ssh? => false, - :scp? => false, - :github? => false, - :gitlab? => false, - :bitbucket? => true, - :authenticated? => false, - :interactive_authenticated? => false, - :to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"), + scheme: "git", + user: nil, + password: nil, + host: "bitbucket.org", + port: nil, + path: "/martinemde/gitable.git", + fragment: nil, + basename: "gitable.git", + ssh?: false, + scp?: false, + github?: false, + gitlab?: false, + bitbucket?: true, + authenticated?: false, + interactive_authenticated?: false, + to_web_uri: Addressable::URI.parse("https://bitbucket.org/martinemde/gitable") }) end describe_uri "git@bitbucket.org:martinemde/gitable.git" do it { expect(subject.to_s).to eq(@uri) } - it { expect("#{subject}").to eq(@uri) } - it { expect(subject.inspect).to match(%r|^#$|) } + it { expect(subject.to_s).to eq(@uri) } + it { expect(subject.inspect).to match(%r{^#$}) } it { expect(subject).to be_equivalent(@uri) } - it { expect(subject).to be_equivalent('ssh://git@bitbucket.org/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('git://bitbucket.org/martinemde/gitable.git') } - it { expect(subject).to be_equivalent('https://martinemde@bitbucket.org/martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') } - it { expect(subject).to_not be_equivalent('git@bitbucket.org:martinemde/not_gitable.git') } + it { expect(subject).to be_equivalent("ssh://git@bitbucket.org/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("git://bitbucket.org/martinemde/gitable.git") } + it { expect(subject).to be_equivalent("https://martinemde@bitbucket.org/martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@othergit.com:martinemde/gitable.git") } + it { expect(subject).to_not be_equivalent("git@bitbucket.org:martinemde/not_gitable.git") } it_sets({ - :scheme => nil, - :inferred_scheme => 'ssh', - :user => "git", - :password => nil, - :host => "bitbucket.org", - :port => nil, - :path => "martinemde/gitable.git", - :fragment => nil, - :basename => "gitable.git", - :project_name => "gitable", - :ssh? => true, - :scp? => true, - :authenticated? => true, - :interactive_authenticated? => false, - :github? => false, - :gitlab? => false, - :bitbucket? => true, - :to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"), + scheme: nil, + inferred_scheme: "ssh", + user: "git", + password: nil, + host: "bitbucket.org", + port: nil, + path: "martinemde/gitable.git", + fragment: nil, + basename: "gitable.git", + project_name: "gitable", + ssh?: true, + scp?: true, + authenticated?: true, + interactive_authenticated?: false, + github?: false, + gitlab?: false, + bitbucket?: true, + to_web_uri: Addressable::URI.parse("https://bitbucket.org/martinemde/gitable") }) end end diff --git a/spec/heuristic_parse_spec.rb b/spec/heuristic_parse_spec.rb index e388225..33c5634 100644 --- a/spec/heuristic_parse_spec.rb +++ b/spec/heuristic_parse_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" describe Gitable::URI, ".heuristic_parse" do it "returns a Gitable::URI" do @@ -13,7 +13,7 @@ "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", + "git@github.com:martinemde/gitable.git" ].each do |uri| it "doesn't break the already valid URI: #{uri.inspect}" do expect(Gitable::URI.heuristic_parse(uri).to_s).to eq(uri) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e68dcd7..d7d9719 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,18 +1,18 @@ unless defined? Bundler - require 'rubygems' - require 'bundler' + require "rubygems" + require "bundler" end -if ENV['COVERAGE'] - require 'simplecov' +if ENV["COVERAGE"] + require "simplecov" SimpleCov.start end $LOAD_PATH.unshift(File.dirname(__FILE__)) -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) -require 'gitable' -require 'rspec' -require 'describe_uri' +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib")) +require "gitable" +require "rspec" +require "describe_uri" RSpec.configure do |config| config.extend DescribeURI