| 
									
										
										
										
											2025-02-26 13:26:37 +01:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-13 14:50:03 +00:00
										 |  |  | require "services/system" | 
					
						
							|  |  |  | require "services/system/systemctl" | 
					
						
							| 
									
										
										
										
											2025-02-26 13:26:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-14 04:35:30 +00:00
										 |  |  | RSpec.describe Homebrew::Services::System::Systemctl do | 
					
						
							| 
									
										
										
										
											2025-02-26 13:26:37 +01:00
										 |  |  |   describe ".scope" do | 
					
						
							|  |  |  |     it "outputs systemctl scope for user" do | 
					
						
							| 
									
										
										
										
											2025-03-14 04:35:30 +00:00
										 |  |  |       allow(Homebrew::Services::System).to receive(:root?).and_return(false) | 
					
						
							| 
									
										
										
										
											2025-02-26 13:26:37 +01:00
										 |  |  |       expect(described_class.scope).to eq("--user") | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "outputs systemctl scope for root" do | 
					
						
							| 
									
										
										
										
											2025-03-14 04:35:30 +00:00
										 |  |  |       allow(Homebrew::Services::System).to receive(:root?).and_return(true) | 
					
						
							| 
									
										
										
										
											2025-02-26 13:26:37 +01:00
										 |  |  |       expect(described_class.scope).to eq("--system") | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe ".executable" do | 
					
						
							|  |  |  |     it "outputs systemctl command location", :needs_linux do | 
					
						
							| 
									
										
										
										
											2025-03-13 17:36:46 +00:00
										 |  |  |       systemctl = Pathname("/bin/systemctl") | 
					
						
							|  |  |  |       expect(described_class).to receive(:which).and_return(systemctl) | 
					
						
							|  |  |  |       described_class.reset_executable! | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect(described_class.executable).to eq(systemctl) | 
					
						
							| 
									
										
										
										
											2025-02-26 13:26:37 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |