From 8997cccddf46401557a5a87b9d047985385c31ea Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Tue, 4 Feb 2025 18:48:00 -0500 Subject: [PATCH] Livecheck: Expand test coverage This brings line coverage for the `Livecheck` DSL back to 100%, as we had evidently overlooked part of the `#strategy` method. --- Library/Homebrew/test/livecheck_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Library/Homebrew/test/livecheck_spec.rb b/Library/Homebrew/test/livecheck_spec.rb index 5b75c24ca6..d213d227d6 100644 --- a/Library/Homebrew/test/livecheck_spec.rb +++ b/Library/Homebrew/test/livecheck_spec.rb @@ -99,13 +99,23 @@ RSpec.describe Livecheck do end describe "#strategy" do + block = proc { |page, regex| page.scan(regex).map { |match| match[0].tr("_", ".") } } + it "returns nil if not set" do expect(livecheck_f.strategy).to be_nil + expect(livecheck_f.strategy_block).to be_nil end it "returns the Symbol if set" do livecheck_f.strategy(:page_match) expect(livecheck_f.strategy).to eq(:page_match) + expect(livecheck_f.strategy_block).to be_nil + end + + it "sets `strategy_block` when provided" do + livecheck_f.strategy(:page_match, &block) + expect(livecheck_f.strategy).to eq(:page_match) + expect(livecheck_f.strategy_block).to eq(block) end end