Skip to content

Commit

Permalink
Split URL test into separate it rules
Browse files Browse the repository at this point in the history
  • Loading branch information
abitrolly committed Dec 5, 2023
1 parent 4800706 commit 1c8c3db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions Library/Homebrew/formula_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def self.name_from_url(url)

def parse_url
@name = FormulaCreator.name_from_url(@url) if @name.blank?
odebug "name_from_url: #{@name}"
@version = Version.detect(@url) if @version.nil?

case @url
Expand Down
14 changes: 13 additions & 1 deletion Library/Homebrew/test/formula_creator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@
require "formula_creator"

describe Homebrew::FormulaCreator do
it "parses names from URL correctly" do
it "gets name from GitHub archive URL" do
t = described_class.name_from_url("https://github.com/abitrolly/lapce/archive/v0.3.0.tar.gz")
expect(t).to eq("lapce")
end

it "gets name from gitweb URL" do
t = described_class.name_from_url("http://www.codesrc.com/gitweb/index.cgi?p=libzipper.git;a=summary")
expect(t).to eq("libzipper")
end

it "gets name from GitHub repo URL" do
t = described_class.name_from_url("https://github.com/abitrolly/lapce.git")
expect(t).to eq("lapce")
end

it "gets name from GitHub download URL" do
t = described_class.name_from_url("https://github.com/stella-emu/stella/releases/download/6.7/stella-6.7-src.tar.xz")
expect(t).to eq("stella")
end

it "gets name from generic tarball URL" do
t = described_class.name_from_url("http://digit-labs.org/files/tools/synscan/releases/synscan-5.02.tar.gz")
expect(t).to eq("synscan")
end
Expand Down

0 comments on commit 1c8c3db

Please sign in to comment.