From efabd4b5c2beadecf3282dbe730b1b6f779571e0 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Tue, 15 Aug 2017 00:42:56 +0530 Subject: Add tests for MACOS version consts usage --- Library/Homebrew/test/rubocops/lines_cop_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/rubocops/lines_cop_spec.rb b/Library/Homebrew/test/rubocops/lines_cop_spec.rb index 44f22df62..b069148f9 100644 --- a/Library/Homebrew/test/rubocops/lines_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/lines_cop_spec.rb @@ -1189,6 +1189,30 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end + it "with MACOS_VERSION const" do + source = <<-EOS.undent + class Foo < Formula + desc "foo" + url 'http://example.com/foo-1.0.tgz' + test do + version = MACOS_VERSION + end + end + EOS + + expected_offenses = [{ message: "Use MacOS.version instead of MACOS_VERSION", + severity: :convention, + line: 5, + column: 14, + source: source }] + + inspect_source(cop, source) + + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) + end + end + end def expect_offense(expected, actual) expect(actual.message).to eq(expected[:message]) -- cgit v1.2.3