Failing test for mishandling contents of livecheck blocks in on_*

- The Cask `little-snitch4` in `Homebrew/homebrew-cask-versions` was
  failing and it took me a while to figure out _how_. Add a test for
  easier further debugging (and to prevent breakage once the bug is
  fixed).

```
❯ brew tests --only=rubocops/cask/no_overrides
Randomized with seed 29917
1 process for 1 spec, ~ 1 spec per process
F

Failures:

  1) RuboCop::Cop::Cask::NoOverrides when there are livecheck blocks within `on_*` blocks, ignore their contents does not report any offenses
     Failure/Error: DEFAULT_FAILURE_NOTIFIER = lambda { |failure, _opts| raise failure }
       expected `[#<RuboCop::Cop::Offense:0x000000012de636c8 @severity=#<RuboCop::Cop::Severity:0x000000012de636a0 @name=:convention>, @location=#<Parser::Source::Range (string) 244...273>, @message="Do not use a top-level `url` stanza as the default. Add it to an `on_{system}` block instead.\nUse `:or_older` or `:or_newer` to specify a range of macOS versions.\n", @cop_name="Cask/NoOverrides", @status=:unsupported, @corrector=nil>].empty?` to be truthy, got false
     Shared Example Group: "does not report any offenses" called from ./test/rubocops/cask/no_overrides_spec.rb:77
     # ./test/rubocops/cask/shared_examples/cask_cop.rb:24:in `expect_no_offenses'
     # ./test/rubocops/cask/shared_examples/cask_cop.rb:7:in `block (2 levels) in <module:CaskCop>'

Took 2 seconds
Tests Failed
```
This commit is contained in:
Issy Long 2023-03-22 21:41:28 +00:00
parent b82c5f1d36
commit 991e5f2f9c
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

View File

@ -61,10 +61,10 @@ describe RuboCop::Cop::Cask::NoOverrides do
on_intel do on_intel do
livecheck do livecheck do
url 'https://brew.sh/foo' # Livecheck should be allowed since it's a different "kind" of URL. url 'https://brew.sh/foo' # Livecheck should be allowed since it's a different "kind" of URL.
strategy :sparkle
end end
version '1.2.3' version '1.2.3'
end end
on_arm do on_arm do
version '2.3.4' version '2.3.4'
end end