Skip to content

Instantly share code, notes, and snippets.

@vmoravec
Last active August 29, 2015 14:00
Show Gist options
  • Save vmoravec/11394484 to your computer and use it in GitHub Desktop.
Save vmoravec/11394484 to your computer and use it in GitHub Desktop.
Test for stop and restart
context "Restart a service on the installation system" do
it "restarts a service with a specialized inst-sys helper if available" do
File.stub(:exist?).with('/bin/service_start').and_return(true)
service = SystemdService.find("sshd")
SCR.stub(:Execute).and_return({'stderr'=>'', 'stdout'=>'', 'exit'=>0})
expect(service).not_to receive(:command) # SystemdUnit#command
expect(service).to receive(:stop)
expect(service).to recieve(:start)
expect(service.restart).to be_true
end
it "stops a service with a specialized inst-sys helper" do
File.stub(:exist?).with('/bin/service_start').and_return(true)
service = SystemdService.find("sshd")
SCR.stub(:Execute).and_return({'stderr'=>'', 'stdout'=>'', 'exit'=>0})
expect(service).not_to receive(:command) # SystemdUnit#command
expect(service.stop).to be_true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment