diff options
| author | Gautham Goli | 2017-07-14 21:11:53 +0530 |
|---|---|---|
| committer | Gautham Goli | 2017-07-14 21:43:16 +0530 |
| commit | f3923f23efd8632e6cbf68e510843b3d44cdfa3d (patch) | |
| tree | d5d770b1fba59ae654012fca67fd318a3b0c93ca /Library/Homebrew/test | |
| parent | 20db5470e3325d3a64e16c785c22c25581e03b52 (diff) | |
| download | brew-f3923f23efd8632e6cbf68e510843b3d44cdfa3d.tar.bz2 | |
audit: Port audit_options strict rules to rubocop and add tests
Diffstat (limited to 'Library/Homebrew/test')
| -rw-r--r-- | Library/Homebrew/test/rubocops/options_cop_spec.rb | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/Library/Homebrew/test/rubocops/options_cop_spec.rb b/Library/Homebrew/test/rubocops/options_cop_spec.rb index 0ed3a9741..161f2a87a 100644 --- a/Library/Homebrew/test/rubocops/options_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/options_cop_spec.rb @@ -29,3 +29,77 @@ describe RuboCop::Cop::FormulaAudit::Options do end end end + +describe RuboCop::Cop::FormulaAuditStrict::Options do + subject(:cop) { described_class.new } + + context "When auditing options strictly" do + it "with universal" do + source = <<-EOS.undent + class Foo < Formula + url 'http://example.com/foo-1.0.tgz' + option :universal + end + EOS + + expected_offenses = [{ message: described_class::DEPRECATION_MSG, + severity: :convention, + line: 3, + column: 2, + source: source }] + + inspect_source(cop, source) + + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) + end + end + + it "with deprecated options" do + source = <<-EOS.undent + class Foo < Formula + url 'http://example.com/foo-1.0.tgz' + option :cxx11 + option "examples", "with-examples" + end + EOS + + MSG_1 = "Options should begin with with/without."\ + " Migrate '--examples' with `deprecated_option`.".freeze + expected_offenses = [{ message: MSG_1, + severity: :convention, + line: 4, + column: 2, + source: source }] + + inspect_source(cop, source) + + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) + end + end + + it "with misc deprecated options" do + source = <<-EOS.undent + class Foo < Formula + url 'http://example.com/foo-1.0.tgz' + option "without-check" + end + EOS + + MSG_2 = "Use '--without-test' instead of '--without-check'."\ + " Migrate '--without-check' with `deprecated_option`.".freeze + expected_offenses = [{ message: MSG_2, + severity: :convention, + line: 3, + column: 2, + source: source }] + + inspect_source(cop, source) + + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) + end + end + end +end |
