2025-02-26 13:26:37 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2025-03-13 14:50:03 +00:00
|
|
|
require "services/formulae"
|
2025-02-26 13:26:37 +01:00
|
|
|
|
2025-03-13 14:50:03 +00:00
|
|
|
RSpec.describe Services::Formulae do
|
2025-02-26 13:26:37 +01:00
|
|
|
describe "#services_list" do
|
|
|
|
it "empty list without available formulae" do
|
|
|
|
allow(described_class).to receive(:available_services).and_return({})
|
|
|
|
expect(described_class.services_list).to eq([])
|
|
|
|
end
|
|
|
|
|
|
|
|
it "list with available formulae" do
|
2025-03-13 14:50:03 +00:00
|
|
|
formula = instance_double(Services::FormulaWrapper)
|
2025-02-26 13:26:37 +01:00
|
|
|
expected = [
|
|
|
|
{
|
|
|
|
file: Pathname.new("/Library/LaunchDaemons/file.plist"),
|
|
|
|
name: "formula",
|
|
|
|
status: :known,
|
|
|
|
user: "root",
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
expect(formula).to receive(:to_hash).and_return(expected[0])
|
|
|
|
allow(described_class).to receive(:available_services).and_return([formula])
|
|
|
|
expect(described_class.services_list).to eq(expected)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|