Skip to content

Commit

Permalink
test Search.search_descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
rrotter committed Jul 1, 2024
1 parent 4f6771c commit e10e1f6
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Library/Homebrew/test/search_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require "search"
require "descriptions"
require "cmd/desc"

RSpec.describe Homebrew::Search do
describe "#query_regexp" do
Expand Down Expand Up @@ -57,4 +59,32 @@
end
end
end

describe "#search_descriptions" do
let(:args) { Homebrew::Cmd::Desc.new(["min_arg_placeholder"]).args }

context "with api" do
let(:api_formulae) do
{ "testball" => { "desc" => "Some test" } }
end

let(:api_casks) do
{ "testball" => { "desc" => "Some test", "name" => ["Test Ball"] } }
end

before do
allow(Homebrew::API::Formula).to receive(:all_formulae).and_return(api_formulae)
allow(Homebrew::API::Cask).to receive(:all_casks).and_return(api_casks)
end

it "successfully searches descriptions" do
expect { described_class.search_descriptions(described_class.query_regexp("ball"), args) }
.to output(/testball: \(Test Ball\) Some test/).to_stdout
.and not_to_output(/testball: Some test/).to_stdout

expect { described_class.search_descriptions(described_class.query_regexp("some"), args) }
.to output(/testball: Some test/).to_stdout
end
end
end
end

0 comments on commit e10e1f6

Please sign in to comment.