From e75ab0a26f69a946ce8f7c87e70f3046abd2e31d Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Mon, 27 Feb 2023 17:07:59 -0500 Subject: [PATCH] json_spec: Clean up tests This renames `simple_content` to `content_simple`, which makes the `content_*` variable name convention more consistent (as is in the `Xml` strategy tests). --- .../test/livecheck/strategy/json_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/test/livecheck/strategy/json_spec.rb b/Library/Homebrew/test/livecheck/strategy/json_spec.rb index b20de8416e..cf911c0b1d 100644 --- a/Library/Homebrew/test/livecheck/strategy/json_spec.rb +++ b/Library/Homebrew/test/livecheck/strategy/json_spec.rb @@ -11,7 +11,6 @@ describe Homebrew::Livecheck::Strategy::Json do let(:regex) { /^v?(\d+(?:\.\d+)+)$/i } - let(:simple_content) { '{"version":"1.2.3"}' } let(:content) { <<~EOS { @@ -40,9 +39,10 @@ describe Homebrew::Livecheck::Strategy::Json do } EOS } + let(:content_simple) { '{"version":"1.2.3"}' } - let(:simple_content_matches) { ["1.2.3"] } let(:content_matches) { ["1.1.2", "1.1.1", "1.1.0", "1.0.3", "1.0.2", "1.0.1", "1.0.0"] } + let(:content_simple_matches) { ["1.2.3"] } let(:find_versions_return_hash) { { @@ -92,10 +92,10 @@ describe Homebrew::Livecheck::Strategy::Json do it "returns an array of version strings when given content and a block" do # Returning a string from block - expect(json.versions_from_content(simple_content) { |json| json["version"] }).to eq(simple_content_matches) - expect(json.versions_from_content(simple_content, regex) do |json| + expect(json.versions_from_content(content_simple) { |json| json["version"] }).to eq(content_simple_matches) + expect(json.versions_from_content(content_simple, regex) do |json| json["version"][regex, 1] - end).to eq(simple_content_matches) + end).to eq(content_simple_matches) # Returning an array of strings from block expect(json.versions_from_content(content, regex) do |json, regex| @@ -105,16 +105,16 @@ describe Homebrew::Livecheck::Strategy::Json do end it "allows a nil return from a block" do - expect(json.versions_from_content(content, regex) { next }).to eq([]) + expect(json.versions_from_content(content_simple, regex) { next }).to eq([]) end it "errors if a block uses two arguments but a regex is not given" do - expect { json.versions_from_content(simple_content) { |json, regex| json["version"][regex, 1] } } + expect { json.versions_from_content(content_simple) { |json, regex| json["version"][regex, 1] } } .to raise_error("Two arguments found in `strategy` block but no regex provided.") end it "errors on an invalid return type from a block" do - expect { json.versions_from_content(content, regex) { 123 } } + expect { json.versions_from_content(content_simple, regex) { 123 } } .to raise_error(TypeError, Homebrew::Livecheck::Strategy::INVALID_BLOCK_RETURN_VALUE_MSG) end end