brew/Library/Homebrew/test/rubocops/version_spec.rb

40 lines
1.1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require "rubocops/version"
RSpec.describe RuboCop::Cop::FormulaAudit::Version do
subject(:cop) { described_class.new }
2021-01-14 18:55:31 -08:00
context "when auditing version" do
it "reports an offense if `version` is an empty string" do
expect_offense(<<~RUBY)
class Foo < Formula
url 'https://brew.sh/foo-1.0.tgz'
version ""
^^^^^^^^^^ FormulaAudit/Version: Version is set to an empty string
end
RUBY
end
2021-01-14 18:55:31 -08:00
it "reports an offense if `version` has a leading 'v'" do
expect_offense(<<~RUBY)
class Foo < Formula
url 'https://brew.sh/foo-1.0.tgz'
version "v1.0"
^^^^^^^^^^^^^^ FormulaAudit/Version: Version v1.0 should not have a leading 'v'
end
RUBY
end
2021-01-14 18:55:31 -08:00
it "reports an offense if `version` ends with an underline and a number" do
expect_offense(<<~RUBY)
class Foo < Formula
url 'https://brew.sh/foo-1.0.tgz'
version "1_0"
^^^^^^^^^^^^^ FormulaAudit/Version: Version 1_0 should not end with an underline and a number
end
RUBY
end
end
end