linux_admin 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +6 -8
- data/lib/linux_admin/distro.rb +2 -2
- data/lib/linux_admin/etc_issue.rb +1 -1
- data/lib/linux_admin/fstab.rb +0 -1
- data/lib/linux_admin/logical_volume.rb +6 -8
- data/lib/linux_admin/registration_system/rhn.rb +2 -2
- data/lib/linux_admin/registration_system/subscription_manager.rb +1 -1
- data/lib/linux_admin/version.rb +1 -1
- data/lib/linux_admin/volume.rb +3 -3
- data/lib/linux_admin/yum.rb +8 -3
- data/spec/common_spec.rb +2 -4
- data/spec/deb_spec.rb +7 -9
- data/spec/disk_spec.rb +61 -63
- data/spec/distro_spec.rb +2 -4
- data/spec/etc_issue_spec.rb +1 -2
- data/spec/fstab_spec.rb +23 -24
- data/spec/hosts_spec.rb +3 -5
- data/spec/logical_volume_spec.rb +42 -44
- data/spec/mountable_spec.rb +28 -30
- data/spec/partition_spec.rb +5 -7
- data/spec/physical_volume_spec.rb +25 -27
- data/spec/registration_system_spec.rb +8 -10
- data/spec/rhn_spec.rb +17 -19
- data/spec/rpm_spec.rb +17 -19
- data/spec/service_spec.rb +23 -25
- data/spec/spec_helper.rb +68 -14
- data/spec/subscription_manager_spec.rb +21 -23
- data/spec/system_spec.rb +2 -4
- data/spec/volume_group_spec.rb +18 -20
- data/spec/yum_spec.rb +27 -23
- metadata +19 -45
- data/spec/linux_admin_spec.rb +0 -4
data/spec/partition_spec.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe LinuxAdmin::Partition do
|
4
2
|
before(:each) do
|
5
3
|
@disk = LinuxAdmin::Disk.new :path => '/dev/sda'
|
@@ -8,18 +6,18 @@ describe LinuxAdmin::Partition do
|
|
8
6
|
|
9
7
|
describe "#path" do
|
10
8
|
it "returns partition path" do
|
11
|
-
@partition.path.
|
9
|
+
expect(@partition.path).to eq('/dev/sda2')
|
12
10
|
end
|
13
11
|
end
|
14
12
|
|
15
13
|
describe "#mount" do
|
16
14
|
context "mount_point not specified" do
|
17
15
|
it "sets default mount_point" do
|
18
|
-
described_class.
|
19
|
-
File.
|
20
|
-
@partition.
|
16
|
+
expect(described_class).to receive(:mount_point_exists?).and_return(false)
|
17
|
+
expect(File).to receive(:directory?).with('/mnt/sda2').and_return(true)
|
18
|
+
expect(@partition).to receive(:run!)
|
21
19
|
@partition.mount
|
22
|
-
@partition.mount_point.
|
20
|
+
expect(@partition.mount_point).to eq('/mnt/sda2')
|
23
21
|
end
|
24
22
|
end
|
25
23
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe LinuxAdmin::PhysicalVolume do
|
4
2
|
before(:each) do
|
5
3
|
@physical_volumes = <<eos
|
@@ -22,7 +20,7 @@ eos
|
|
22
20
|
it "uses vgextend" do
|
23
21
|
vg = LinuxAdmin::VolumeGroup.new :name => 'vg'
|
24
22
|
pv = described_class.new :device_name => '/dev/hda'
|
25
|
-
pv.
|
23
|
+
expect(pv).to receive(:run!).
|
26
24
|
with(pv.cmd(:vgextend),
|
27
25
|
:params => ['vg', '/dev/hda'])
|
28
26
|
pv.attach_to(vg)
|
@@ -31,77 +29,77 @@ eos
|
|
31
29
|
it "assigns volume group to physical volume" do
|
32
30
|
vg = LinuxAdmin::VolumeGroup.new :name => 'vg'
|
33
31
|
pv = described_class.new :device_name => '/dev/hda'
|
34
|
-
pv.
|
32
|
+
allow(pv).to receive(:run!)
|
35
33
|
pv.attach_to(vg)
|
36
|
-
pv.volume_group.
|
34
|
+
expect(pv.volume_group).to eq(vg)
|
37
35
|
end
|
38
36
|
|
39
37
|
it "returns self" do
|
40
38
|
vg = LinuxAdmin::VolumeGroup.new :name => 'vg'
|
41
39
|
pv = described_class.new :device_name => '/dev/hda'
|
42
|
-
pv.
|
43
|
-
pv.attach_to(vg).
|
40
|
+
allow(pv).to receive(:run!)
|
41
|
+
expect(pv.attach_to(vg)).to eq(pv)
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
47
45
|
describe "#create" do
|
48
46
|
before do
|
49
47
|
@disk = LinuxAdmin::Disk.new :path => '/dev/hda'
|
50
|
-
@disk.
|
48
|
+
allow(@disk).to receive(:size)
|
51
49
|
end
|
52
50
|
|
53
51
|
let(:disk) {@disk}
|
54
52
|
|
55
53
|
it "uses pvcreate" do
|
56
54
|
described_class.instance_variable_set(:@pvs, [])
|
57
|
-
described_class.
|
55
|
+
expect(described_class).to receive(:run!).
|
58
56
|
with(LinuxAdmin.cmd(:pvcreate),
|
59
57
|
:params => { nil => '/dev/hda'})
|
60
58
|
described_class.create disk
|
61
59
|
end
|
62
60
|
|
63
61
|
it "returns new physical volume" do
|
64
|
-
LinuxAdmin::VolumeGroup.
|
65
|
-
described_class.
|
62
|
+
allow(LinuxAdmin::VolumeGroup).to receive_messages(:run! => double(:output => ""))
|
63
|
+
allow(described_class).to receive_messages(:run! => double(:output => ""))
|
66
64
|
pv = described_class.create disk
|
67
|
-
pv.
|
68
|
-
pv.device_name.
|
65
|
+
expect(pv).to be_an_instance_of(described_class)
|
66
|
+
expect(pv.device_name).to eq('/dev/hda')
|
69
67
|
end
|
70
68
|
|
71
69
|
it "adds physical volume to local registry" do
|
72
|
-
LinuxAdmin::VolumeGroup.
|
73
|
-
described_class.
|
70
|
+
allow(LinuxAdmin::VolumeGroup).to receive_messages(:run! => double(:output => ""))
|
71
|
+
allow(described_class).to receive_messages(:run! => double(:output => ""))
|
74
72
|
pv = described_class.create disk
|
75
|
-
described_class.scan.
|
73
|
+
expect(described_class.scan).to include(pv)
|
76
74
|
end
|
77
75
|
end
|
78
76
|
|
79
77
|
describe "#scan" do
|
80
78
|
it "uses pvdisplay" do
|
81
|
-
described_class.
|
79
|
+
expect(described_class).to receive(:run!).
|
82
80
|
with(LinuxAdmin.cmd(:pvdisplay),
|
83
81
|
:params => { '-c' => nil}).
|
84
82
|
and_return(double(:output => @physical_volumes))
|
85
|
-
LinuxAdmin::VolumeGroup.
|
83
|
+
expect(LinuxAdmin::VolumeGroup).to receive(:run!).and_return(double(:output => @groups)) # stub out call to vgdisplay
|
86
84
|
described_class.scan
|
87
85
|
end
|
88
86
|
|
89
87
|
it "returns local physical volumes" do
|
90
|
-
described_class.
|
91
|
-
LinuxAdmin::VolumeGroup.
|
88
|
+
expect(described_class).to receive(:run!).and_return(double(:output => @physical_volumes))
|
89
|
+
expect(LinuxAdmin::VolumeGroup).to receive(:run!).and_return(double(:output => @groups))
|
92
90
|
pvs = described_class.scan
|
93
91
|
|
94
|
-
pvs[0].
|
95
|
-
pvs[0].device_name.
|
96
|
-
pvs[0].size.
|
92
|
+
expect(pvs[0]).to be_an_instance_of(described_class)
|
93
|
+
expect(pvs[0].device_name).to eq('/dev/vda2')
|
94
|
+
expect(pvs[0].size).to eq(24139776)
|
97
95
|
end
|
98
96
|
|
99
97
|
it "resolves volume group references" do
|
100
|
-
described_class.
|
101
|
-
LinuxAdmin::VolumeGroup.
|
98
|
+
expect(described_class).to receive(:run!).and_return(double(:output => @physical_volumes))
|
99
|
+
expect(LinuxAdmin::VolumeGroup).to receive(:run!).and_return(double(:output => @groups))
|
102
100
|
pvs = described_class.scan
|
103
|
-
pvs[0].volume_group.
|
104
|
-
pvs[0].volume_group.name.
|
101
|
+
expect(pvs[0].volume_group).to be_an_instance_of(LinuxAdmin::VolumeGroup)
|
102
|
+
expect(pvs[0].volume_group.name).to eq('vg_foobar')
|
105
103
|
end
|
106
104
|
end
|
107
105
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe LinuxAdmin::RegistrationSystem do
|
4
2
|
context ".registration_type" do
|
5
3
|
it "when registered Subscription Manager" do
|
@@ -18,13 +16,13 @@ describe LinuxAdmin::RegistrationSystem do
|
|
18
16
|
end
|
19
17
|
|
20
18
|
it "should memoize results" do
|
21
|
-
described_class.
|
19
|
+
expect(described_class).to receive(:registration_type_uncached).once.and_return("anything_non_nil")
|
22
20
|
described_class.registration_type
|
23
21
|
described_class.registration_type
|
24
22
|
end
|
25
23
|
|
26
24
|
it "with reload should refresh results" do
|
27
|
-
described_class.
|
25
|
+
expect(described_class).to receive(:registration_type_uncached).twice.and_return("anything_non_nil")
|
28
26
|
described_class.registration_type
|
29
27
|
described_class.registration_type(true)
|
30
28
|
end
|
@@ -32,7 +30,7 @@ describe LinuxAdmin::RegistrationSystem do
|
|
32
30
|
|
33
31
|
it "#registered? when unregistered" do
|
34
32
|
stub_registered_to_system(nil)
|
35
|
-
expect(described_class.registered?).to
|
33
|
+
expect(described_class.registered?).to be_falsey
|
36
34
|
end
|
37
35
|
|
38
36
|
context ".method_missing" do
|
@@ -41,7 +39,7 @@ describe LinuxAdmin::RegistrationSystem do
|
|
41
39
|
end
|
42
40
|
|
43
41
|
it "exists on the subclass" do
|
44
|
-
expect(LinuxAdmin::RegistrationSystem.registered?).to
|
42
|
+
expect(LinuxAdmin::RegistrationSystem.registered?).to be_truthy
|
45
43
|
end
|
46
44
|
|
47
45
|
it "does not exist on the subclass" do
|
@@ -49,12 +47,12 @@ describe LinuxAdmin::RegistrationSystem do
|
|
49
47
|
end
|
50
48
|
|
51
49
|
it "is an unknown method" do
|
52
|
-
expect { LinuxAdmin::RegistrationSystem.method_does_not_exist }.to
|
50
|
+
expect { LinuxAdmin::RegistrationSystem.method_does_not_exist }.to raise_error(NoMethodError)
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
56
54
|
def stub_registered_to_system(*system)
|
57
|
-
LinuxAdmin::SubscriptionManager.
|
58
|
-
LinuxAdmin::Rhn.
|
55
|
+
allow_any_instance_of(LinuxAdmin::SubscriptionManager).to receive_messages(:registered? => (system.include?(:sm)))
|
56
|
+
allow_any_instance_of(LinuxAdmin::Rhn).to receive_messages(:registered? => (system.include?(:rhn)))
|
59
57
|
end
|
60
|
-
end
|
58
|
+
end
|
data/spec/rhn_spec.rb
CHANGED
@@ -1,19 +1,17 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe LinuxAdmin::Rhn do
|
4
2
|
context "#registered?" do
|
5
3
|
it "with registered system_id" do
|
6
|
-
described_class.
|
4
|
+
allow_any_instance_of(described_class).to receive_messages(:systemid_file => data_file_path("rhn/systemid"))
|
7
5
|
expect(described_class.new).to be_registered
|
8
6
|
end
|
9
7
|
|
10
8
|
it "with unregistered system_id" do
|
11
|
-
described_class.
|
9
|
+
allow_any_instance_of(described_class).to receive_messages(:systemid_file => data_file_path("rhn/systemid.missing_system_id"))
|
12
10
|
expect(described_class.new).to_not be_registered
|
13
11
|
end
|
14
12
|
|
15
13
|
it "with missing systemid file" do
|
16
|
-
described_class.
|
14
|
+
allow_any_instance_of(described_class).to receive_messages(:systemid_file => data_file_path("rhn/systemid.missing_file"))
|
17
15
|
expect(described_class.new).to_not be_registered
|
18
16
|
end
|
19
17
|
end
|
@@ -41,25 +39,25 @@ describe LinuxAdmin::Rhn do
|
|
41
39
|
run_params.store_path(:params, "--sslCACert=", "/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT")
|
42
40
|
base_options.store_path(:server_url, "https://server.url")
|
43
41
|
|
44
|
-
described_class.
|
45
|
-
LinuxAdmin::Rpm.
|
46
|
-
LinuxAdmin::Rpm.
|
42
|
+
expect_any_instance_of(described_class).to receive(:run!).once.with("rhnreg_ks", run_params)
|
43
|
+
expect(LinuxAdmin::Rpm).to receive(:upgrade).with("http://server.url/pub/rhn-org-trusted-ssl-cert-1.0-1.noarch.rpm")
|
44
|
+
expect(LinuxAdmin::Rpm).to receive(:list_installed).and_return({"rhn-org-trusted-ssl-cert" => "1.0"})
|
47
45
|
|
48
46
|
described_class.new.register(base_options)
|
49
47
|
end
|
50
48
|
|
51
49
|
it "without server_url" do
|
52
|
-
described_class.
|
53
|
-
described_class.
|
54
|
-
LinuxAdmin::Rpm.
|
50
|
+
expect_any_instance_of(described_class).to receive(:run!).once.with("rhnreg_ks", run_params)
|
51
|
+
expect_any_instance_of(described_class).not_to receive(:install_server_certificate)
|
52
|
+
expect(LinuxAdmin::Rpm).to receive(:list_installed).and_return({"rhn-org-trusted-ssl-cert" => nil})
|
55
53
|
|
56
54
|
described_class.new.register(base_options)
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
60
58
|
it "with activation key" do
|
61
|
-
described_class.
|
62
|
-
LinuxAdmin::Rpm.
|
59
|
+
expect_any_instance_of(described_class).to receive(:run!).once.with("rhnreg_ks", {:params=>{"--activationkey="=>"123abc", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass"}})
|
60
|
+
expect(LinuxAdmin::Rpm).to receive(:list_installed).and_return({"rhn-org-trusted-ssl-cert" => nil})
|
63
61
|
|
64
62
|
described_class.new.register(
|
65
63
|
:activationkey => "123abc",
|
@@ -71,19 +69,19 @@ describe LinuxAdmin::Rhn do
|
|
71
69
|
end
|
72
70
|
|
73
71
|
it "#enable_channel" do
|
74
|
-
described_class.
|
72
|
+
expect_any_instance_of(described_class).to receive(:run!).once.with("rhn-channel -a", {:params=>{"--user="=>"SomeUser", "--password="=>"SomePass", "--channel="=>123}})
|
75
73
|
|
76
74
|
described_class.new.enable_channel(123, :username => "SomeUser", :password => "SomePass")
|
77
75
|
end
|
78
76
|
|
79
77
|
it "#enabled_channels" do
|
80
|
-
described_class.
|
78
|
+
expect_any_instance_of(described_class).to receive(:run!).once.with("rhn-channel -l").and_return(double(:output => sample_output("rhn/output_rhn-channel_list")))
|
81
79
|
|
82
80
|
expect(described_class.new.enabled_channels).to eq(["rhel-x86_64-server-6", "rhel-x86_64-server-6-cf-me-2"])
|
83
81
|
end
|
84
82
|
|
85
83
|
it "#disable_channel" do
|
86
|
-
described_class.
|
84
|
+
expect_any_instance_of(described_class).to receive(:run!).once.with("rhn-channel -r", {:params=>{"--user="=>"SomeUser", "--password="=>"SomePass", "--channel="=>123}})
|
87
85
|
|
88
86
|
described_class.new.disable_channel(123, :username => "SomeUser", :password => "SomePass")
|
89
87
|
end
|
@@ -107,7 +105,7 @@ describe LinuxAdmin::Rhn do
|
|
107
105
|
}
|
108
106
|
}
|
109
107
|
|
110
|
-
described_class.
|
108
|
+
expect_any_instance_of(described_class).to receive(:run!).once.with(cmd, params).and_return(double(:output => sample_output("rhn/output_rhn-channel_list_available")))
|
111
109
|
|
112
110
|
expect(described_class.new.available_channels(credentials)).to eq(expected)
|
113
111
|
end
|
@@ -125,8 +123,8 @@ describe LinuxAdmin::Rhn do
|
|
125
123
|
{:repo_id => "rhel-x86_64-server-6", :enabled => true}
|
126
124
|
]
|
127
125
|
|
128
|
-
described_class.
|
129
|
-
described_class.
|
126
|
+
expect_any_instance_of(described_class).to receive(:run!).once.and_return(double(:output => sample_output("rhn/output_rhn-channel_list_available")))
|
127
|
+
expect_any_instance_of(described_class).to receive(:run!).once.with("rhn-channel -l").and_return(double(:output => sample_output("rhn/output_rhn-channel_list")))
|
130
128
|
|
131
129
|
expect(described_class.new.all_repos(credentials)).to eq(expected)
|
132
130
|
end
|
data/spec/rpm_spec.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe LinuxAdmin::Rpm do
|
4
2
|
it ".list_installed" do
|
5
|
-
described_class.
|
3
|
+
allow(described_class).to receive_messages(:run! => double(:output => sample_output("rpm/cmd_output_for_list_installed")))
|
6
4
|
expect(described_class.list_installed).to eq({
|
7
5
|
"ruby193-rubygem-some_really_long_name" =>"1.0.7-1.el6",
|
8
6
|
"fipscheck-lib" =>"1.2.0-7.el6",
|
@@ -28,7 +26,7 @@ describe LinuxAdmin::Rpm do
|
|
28
26
|
end
|
29
27
|
|
30
28
|
it ".import_key" do
|
31
|
-
described_class.
|
29
|
+
expect(described_class).to receive(:run!).with("rpm", {:params => {"--import" => "abc"}})
|
32
30
|
expect { described_class.import_key("abc") }.to_not raise_error
|
33
31
|
end
|
34
32
|
|
@@ -61,25 +59,25 @@ straight-forward, and extensible.
|
|
61
59
|
EOS
|
62
60
|
arguments = [described_class.rpm_cmd, :params => {"-qi" => "ruby"}]
|
63
61
|
result = AwesomeSpawn::CommandResult.new("", data, "", 0)
|
64
|
-
described_class.
|
62
|
+
expect(described_class).to receive(:run!).with(*arguments).and_return(result)
|
65
63
|
metadata = described_class.info("ruby")
|
66
|
-
metadata['name'].
|
67
|
-
metadata['version'].
|
68
|
-
metadata['release'].
|
69
|
-
metadata['architecture'].
|
70
|
-
metadata['group'].
|
71
|
-
metadata['size'].
|
72
|
-
metadata['license'].
|
73
|
-
metadata['source_rpm'].
|
74
|
-
metadata['build_host'].
|
75
|
-
metadata['packager'].
|
76
|
-
metadata['vendor'].
|
77
|
-
metadata['summary'].
|
64
|
+
expect(metadata['name']).to eq('ruby')
|
65
|
+
expect(metadata['version']).to eq('2.0.0.247')
|
66
|
+
expect(metadata['release']).to eq('15.fc19')
|
67
|
+
expect(metadata['architecture']).to eq('x86_64')
|
68
|
+
expect(metadata['group']).to eq('Development/Languages')
|
69
|
+
expect(metadata['size']).to eq('64473')
|
70
|
+
expect(metadata['license']).to eq('(Ruby or BSD) and Public Domain')
|
71
|
+
expect(metadata['source_rpm']).to eq('ruby-2.0.0.247-15.fc19.src.rpm')
|
72
|
+
expect(metadata['build_host']).to eq('buildvm-16.phx2.fedoraproject.org')
|
73
|
+
expect(metadata['packager']).to eq('Fedora Project')
|
74
|
+
expect(metadata['vendor']).to eq('Fedora Project')
|
75
|
+
expect(metadata['summary']).to eq('An interpreter of object-oriented scripting language')
|
78
76
|
end
|
79
77
|
end
|
80
78
|
|
81
79
|
it ".upgrade" do
|
82
|
-
described_class.
|
83
|
-
expect(described_class.upgrade("abc")).to
|
80
|
+
expect(described_class).to receive(:run).with("rpm -U", {:params=>{nil=>"abc"}}).and_return(double(:exit_status => 0))
|
81
|
+
expect(described_class.upgrade("abc")).to be_truthy
|
84
82
|
end
|
85
83
|
end
|
data/spec/service_spec.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe LinuxAdmin::Service do
|
4
2
|
before(:each) do
|
5
3
|
@service = LinuxAdmin::Service.new 'foo'
|
@@ -7,7 +5,7 @@ describe LinuxAdmin::Service do
|
|
7
5
|
|
8
6
|
describe "#running?" do
|
9
7
|
it "checks service" do
|
10
|
-
@service.
|
8
|
+
expect(@service).to receive(:run).
|
11
9
|
with(@service.cmd(:service),
|
12
10
|
:params => { nil => ['foo', 'status']}).and_return(double(:exit_status => 0))
|
13
11
|
@service.running?
|
@@ -16,79 +14,79 @@ describe LinuxAdmin::Service do
|
|
16
14
|
context "service is running" do
|
17
15
|
it "returns true" do
|
18
16
|
@service = LinuxAdmin::Service.new :id => :foo
|
19
|
-
@service.
|
20
|
-
@service.
|
17
|
+
expect(@service).to receive(:run).and_return(double(:exit_status => 0))
|
18
|
+
expect(@service).to be_running
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
24
22
|
context "service is not running" do
|
25
23
|
it "returns false" do
|
26
24
|
@service = LinuxAdmin::Service.new :id => :foo
|
27
|
-
@service.
|
28
|
-
@service.
|
25
|
+
expect(@service).to receive(:run).and_return(double(:exit_status => 1))
|
26
|
+
expect(@service).not_to be_running
|
29
27
|
end
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
31
|
describe "#enable" do
|
34
32
|
it "enables service" do
|
35
|
-
@service.
|
33
|
+
expect(@service).to receive(:run!).
|
36
34
|
with(@service.cmd(:chkconfig),
|
37
35
|
:params => { nil => [ 'foo', 'on']})
|
38
36
|
@service.enable
|
39
37
|
end
|
40
38
|
|
41
39
|
it "returns self" do
|
42
|
-
@service.
|
43
|
-
@service.enable.
|
40
|
+
expect(@service).to receive(:run!) # stub out cmd invocation
|
41
|
+
expect(@service.enable).to eq(@service)
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
47
45
|
describe "#disable" do
|
48
46
|
it "disable service" do
|
49
|
-
@service.
|
47
|
+
expect(@service).to receive(:run!).
|
50
48
|
with(@service.cmd(:chkconfig),
|
51
49
|
:params => { nil => [ 'foo', 'off']})
|
52
50
|
@service.disable
|
53
51
|
end
|
54
52
|
|
55
53
|
it "returns self" do
|
56
|
-
@service.
|
57
|
-
@service.disable.
|
54
|
+
expect(@service).to receive(:run!)
|
55
|
+
expect(@service.disable).to eq(@service)
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
61
59
|
describe "#start" do
|
62
60
|
it "starts service" do
|
63
|
-
@service.
|
61
|
+
expect(@service).to receive(:run!).
|
64
62
|
with(@service.cmd(:service),
|
65
63
|
:params => { nil => [ 'foo', 'start']})
|
66
64
|
@service.start
|
67
65
|
end
|
68
66
|
|
69
67
|
it "returns self" do
|
70
|
-
@service.
|
71
|
-
@service.start.
|
68
|
+
expect(@service).to receive(:run!)
|
69
|
+
expect(@service.start).to eq(@service)
|
72
70
|
end
|
73
71
|
end
|
74
72
|
|
75
73
|
describe "#stop" do
|
76
74
|
it "stops service" do
|
77
|
-
@service.
|
75
|
+
expect(@service).to receive(:run!).
|
78
76
|
with(@service.cmd(:service),
|
79
77
|
:params => { nil => [ 'foo', 'stop']})
|
80
78
|
@service.stop
|
81
79
|
end
|
82
80
|
|
83
81
|
it "returns self" do
|
84
|
-
@service.
|
85
|
-
@service.stop.
|
82
|
+
expect(@service).to receive(:run!)
|
83
|
+
expect(@service.stop).to eq(@service)
|
86
84
|
end
|
87
85
|
end
|
88
86
|
|
89
87
|
describe "#restart" do
|
90
88
|
it "stops service" do
|
91
|
-
@service.
|
89
|
+
expect(@service).to receive(:run).
|
92
90
|
with(@service.cmd(:service),
|
93
91
|
:params => { nil => [ 'foo', 'restart']}).and_return(double(:exit_status => 0))
|
94
92
|
@service.restart
|
@@ -96,16 +94,16 @@ describe LinuxAdmin::Service do
|
|
96
94
|
|
97
95
|
context "service restart fails" do
|
98
96
|
it "manually stops/starts service" do
|
99
|
-
@service.
|
100
|
-
@service.
|
101
|
-
@service.
|
97
|
+
expect(@service).to receive(:run).and_return(double(:exit_status => 1))
|
98
|
+
expect(@service).to receive(:stop)
|
99
|
+
expect(@service).to receive(:start)
|
102
100
|
@service.restart
|
103
101
|
end
|
104
102
|
end
|
105
103
|
|
106
104
|
it "returns self" do
|
107
|
-
@service.
|
108
|
-
@service.restart.
|
105
|
+
expect(@service).to receive(:run).and_return(double(:exit_status => 0))
|
106
|
+
expect(@service.restart).to eq(@service)
|
109
107
|
end
|
110
108
|
end
|
111
109
|
|