-
Notifications
You must be signed in to change notification settings - Fork 45
/
services_test.rb
executable file
·51 lines (40 loc) · 1.39 KB
/
services_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#! /usr/bin/env rspec
require_relative "./test_helper"
require "installation/services"
describe ::Installation::Services do
before do
# simulate non used class
described_class.instance_variable_set(:@enabled, nil)
end
describe ".enabled" do
it "returns list of previously set services" do
described_class.enabled = ["test"]
expect(described_class.enabled).to eq ["test"]
end
it "returns empty list if not set previously" do
expect(described_class.enabled).to eq []
end
end
describe ".enabled=" do
it "sets list of services to enable" do
described_class.enabled = ["test"]
expect(described_class.enabled).to eq ["test"]
end
it "raise exception if non-array is passed" do
expect { described_class.enabled = "test" }.to raise_error(ArgumentError)
end
end
describe ".write" do
it "enables all services previously set" do
described_class.enabled = ["test"]
service = double(enable: true)
expect(Yast2::Systemd::Service).to receive(:find!).with("test").and_return(service)
expect(service).to receive(:enable)
described_class.write
end
it "raises Yast2::Systemd::ServiceNotFound exception if service to enable does not exist" do
described_class.enabled = ["non-existing-service"]
expect { described_class.write }.to raise_error(Yast2::Systemd::ServiceNotFound)
end
end
end