linux_admin 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/lib/linux_admin/common.rb +4 -4
  3. data/lib/linux_admin/deb.rb +1 -1
  4. data/lib/linux_admin/disk.rb +6 -8
  5. data/lib/linux_admin/hosts.rb +4 -6
  6. data/lib/linux_admin/ip_address.rb +4 -6
  7. data/lib/linux_admin/logical_volume.rb +3 -3
  8. data/lib/linux_admin/mountable.rb +5 -8
  9. data/lib/linux_admin/network_interface.rb +4 -6
  10. data/lib/linux_admin/package.rb +0 -1
  11. data/lib/linux_admin/physical_volume.rb +3 -6
  12. data/lib/linux_admin/registration_system/rhn.rb +5 -5
  13. data/lib/linux_admin/registration_system/subscription_manager.rb +2 -2
  14. data/lib/linux_admin/registration_system.rb +1 -2
  15. data/lib/linux_admin/rpm.rb +7 -5
  16. data/lib/linux_admin/service/sys_v_init_service.rb +12 -12
  17. data/lib/linux_admin/service/systemd_service.rb +12 -12
  18. data/lib/linux_admin/service.rb +1 -3
  19. data/lib/linux_admin/system.rb +2 -4
  20. data/lib/linux_admin/time_date.rb +3 -4
  21. data/lib/linux_admin/version.rb +1 -1
  22. data/lib/linux_admin/volume.rb +1 -1
  23. data/lib/linux_admin/volume_group.rb +7 -10
  24. data/lib/linux_admin/yum.rb +6 -8
  25. data/lib/linux_admin.rb +0 -2
  26. data/spec/common_spec.rb +6 -8
  27. data/spec/deb_spec.rb +3 -3
  28. data/spec/disk_spec.rb +27 -27
  29. data/spec/hosts_spec.rb +5 -5
  30. data/spec/ip_address_spec.rb +4 -4
  31. data/spec/logical_volume_spec.rb +38 -38
  32. data/spec/mountable_spec.rb +22 -20
  33. data/spec/network_interface/network_interface_rh_spec.rb +13 -9
  34. data/spec/network_interface_spec.rb +4 -6
  35. data/spec/partition_spec.rb +1 -1
  36. data/spec/physical_volume_spec.rb +16 -20
  37. data/spec/rhn_spec.rb +22 -9
  38. data/spec/rpm_spec.rb +6 -4
  39. data/spec/service/sys_v_init_service_spec.rb +27 -28
  40. data/spec/service/systemd_service_spec.rb +20 -20
  41. data/spec/service_spec.rb +1 -1
  42. data/spec/subscription_manager_spec.rb +27 -15
  43. data/spec/system_spec.rb +2 -6
  44. data/spec/time_date_spec.rb +1 -1
  45. data/spec/volume_group_spec.rb +15 -19
  46. data/spec/yum_spec.rb +27 -15
  47. metadata +8 -6
@@ -20,8 +20,8 @@ eos
20
20
  it "uses vgextend" do
21
21
  vg = LinuxAdmin::VolumeGroup.new :name => 'vg'
22
22
  pv = described_class.new :device_name => '/dev/hda'
23
- expect(pv).to receive(:run!).
24
- with(pv.cmd(:vgextend),
23
+ expect(LinuxAdmin::Common).to receive(:run!)
24
+ .with(LinuxAdmin::Common.cmd(:vgextend),
25
25
  :params => ['vg', '/dev/hda'])
26
26
  pv.attach_to(vg)
27
27
  end
@@ -29,7 +29,7 @@ eos
29
29
  it "assigns volume group to physical volume" do
30
30
  vg = LinuxAdmin::VolumeGroup.new :name => 'vg'
31
31
  pv = described_class.new :device_name => '/dev/hda'
32
- allow(pv).to receive(:run!)
32
+ allow(LinuxAdmin::Common).to receive(:run!)
33
33
  pv.attach_to(vg)
34
34
  expect(pv.volume_group).to eq(vg)
35
35
  end
@@ -37,7 +37,7 @@ eos
37
37
  it "returns self" do
38
38
  vg = LinuxAdmin::VolumeGroup.new :name => 'vg'
39
39
  pv = described_class.new :device_name => '/dev/hda'
40
- allow(pv).to receive(:run!)
40
+ allow(LinuxAdmin::Common).to receive(:run!)
41
41
  expect(pv.attach_to(vg)).to eq(pv)
42
42
  end
43
43
  end
@@ -52,23 +52,21 @@ eos
52
52
 
53
53
  it "uses pvcreate" do
54
54
  described_class.instance_variable_set(:@pvs, [])
55
- expect(described_class).to receive(:run!).
56
- with(LinuxAdmin.cmd(:pvcreate),
57
- :params => { nil => '/dev/hda'})
55
+ expect(LinuxAdmin::Common).to receive(:run!)
56
+ .with(LinuxAdmin::Common.cmd(:pvcreate),
57
+ :params => {nil => '/dev/hda'})
58
58
  described_class.create disk
59
59
  end
60
60
 
61
61
  it "returns new physical volume" do
62
- allow(LinuxAdmin::VolumeGroup).to receive_messages(:run! => double(:output => ""))
63
- allow(described_class).to receive_messages(:run! => double(:output => ""))
62
+ allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
64
63
  pv = described_class.create disk
65
64
  expect(pv).to be_an_instance_of(described_class)
66
65
  expect(pv.device_name).to eq('/dev/hda')
67
66
  end
68
67
 
69
68
  it "adds physical volume to local registry" do
70
- allow(LinuxAdmin::VolumeGroup).to receive_messages(:run! => double(:output => ""))
71
- allow(described_class).to receive_messages(:run! => double(:output => ""))
69
+ allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
72
70
  pv = described_class.create disk
73
71
  expect(described_class.scan).to include(pv)
74
72
  end
@@ -76,17 +74,16 @@ eos
76
74
 
77
75
  describe "#scan" do
78
76
  it "uses pvdisplay" do
79
- expect(described_class).to receive(:run!).
80
- with(LinuxAdmin.cmd(:pvdisplay),
81
- :params => { '-c' => nil}).
82
- and_return(double(:output => @physical_volumes))
83
- expect(LinuxAdmin::VolumeGroup).to receive(:run!).and_return(double(:output => @groups)) # stub out call to vgdisplay
77
+ expect(LinuxAdmin::Common).to receive(:run!)
78
+ .with(LinuxAdmin::Common.cmd(:pvdisplay),
79
+ :params => {'-c' => nil})
80
+ .and_return(double(:output => @physical_volumes))
81
+ expect(LinuxAdmin::Common).to receive(:run!).and_return(double(:output => @groups)) # stub out call to vgdisplay
84
82
  described_class.scan
85
83
  end
86
84
 
87
85
  it "returns local physical volumes" do
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))
86
+ expect(LinuxAdmin::Common).to receive(:run!).and_return(double(:output => @physical_volumes), double(:output => @groups))
90
87
  pvs = described_class.scan
91
88
 
92
89
  expect(pvs[0]).to be_an_instance_of(described_class)
@@ -95,8 +92,7 @@ eos
95
92
  end
96
93
 
97
94
  it "resolves volume group references" do
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))
95
+ expect(LinuxAdmin::Common).to receive(:run!).and_return(double(:output => @physical_volumes), double(:output => @groups))
100
96
  pvs = described_class.scan
101
97
  expect(pvs[0].volume_group).to be_an_instance_of(LinuxAdmin::VolumeGroup)
102
98
  expect(pvs[0].volume_group.name).to eq('vg_foobar')
data/spec/rhn_spec.rb CHANGED
@@ -39,7 +39,7 @@ describe LinuxAdmin::Rhn do
39
39
  run_params.store_path(:params, "--sslCACert=", "/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT")
40
40
  base_options.store_path(:server_url, "https://server.url")
41
41
 
42
- expect_any_instance_of(described_class).to receive(:run!).once.with("rhnreg_ks", run_params)
42
+ expect(LinuxAdmin::Common).to receive(:run!).once.with("rhnreg_ks", run_params)
43
43
  expect(LinuxAdmin::Rpm).to receive(:upgrade).with("http://server.url/pub/rhn-org-trusted-ssl-cert-1.0-1.noarch.rpm")
44
44
  expect(LinuxAdmin::Rpm).to receive(:list_installed).and_return({"rhn-org-trusted-ssl-cert" => "1.0"})
45
45
 
@@ -47,7 +47,7 @@ describe LinuxAdmin::Rhn do
47
47
  end
48
48
 
49
49
  it "without server_url" do
50
- expect_any_instance_of(described_class).to receive(:run!).once.with("rhnreg_ks", run_params)
50
+ expect(LinuxAdmin::Common).to receive(:run!).once.with("rhnreg_ks", run_params)
51
51
  expect_any_instance_of(described_class).not_to receive(:install_server_certificate)
52
52
  expect(LinuxAdmin::Rpm).to receive(:list_installed).and_return({"rhn-org-trusted-ssl-cert" => nil})
53
53
 
@@ -56,7 +56,11 @@ describe LinuxAdmin::Rhn do
56
56
  end
57
57
 
58
58
  it "with activation key" do
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"}})
59
+ expect(LinuxAdmin::Common).to receive(:run!).once.with("rhnreg_ks",
60
+ :params => {"--activationkey=" => "123abc",
61
+ "--proxy=" => "1.2.3.4",
62
+ "--proxyUser=" => "ProxyUser",
63
+ "--proxyPassword=" => "ProxyPass"})
60
64
  expect(LinuxAdmin::Rpm).to receive(:list_installed).and_return({"rhn-org-trusted-ssl-cert" => nil})
61
65
 
62
66
  described_class.new.register(
@@ -69,19 +73,25 @@ describe LinuxAdmin::Rhn do
69
73
  end
70
74
 
71
75
  it "#enable_channel" do
72
- expect_any_instance_of(described_class).to receive(:run!).once.with("rhn-channel -a", {:params=>{"--user="=>"SomeUser", "--password="=>"SomePass", "--channel="=>123}})
76
+ expect(LinuxAdmin::Common).to receive(:run!).once.with("rhn-channel -a",
77
+ :params => {"--user=" => "SomeUser",
78
+ "--password=" => "SomePass",
79
+ "--channel=" => 123})
73
80
 
74
81
  described_class.new.enable_channel(123, :username => "SomeUser", :password => "SomePass")
75
82
  end
76
83
 
77
84
  it "#enabled_channels" do
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")))
85
+ expect(LinuxAdmin::Common).to receive(:run!).once.with("rhn-channel -l")
86
+ .and_return(double(:output => sample_output("rhn/output_rhn-channel_list")))
79
87
 
80
88
  expect(described_class.new.enabled_channels).to eq(["rhel-x86_64-server-6", "rhel-x86_64-server-6-cf-me-2"])
81
89
  end
82
90
 
83
91
  it "#disable_channel" do
84
- expect_any_instance_of(described_class).to receive(:run!).once.with("rhn-channel -r", {:params=>{"--user="=>"SomeUser", "--password="=>"SomePass", "--channel="=>123}})
92
+ expect(LinuxAdmin::Common).to receive(:run!).once.with("rhn-channel -r", :params => {"--user=" => "SomeUser",
93
+ "--password=" => "SomePass",
94
+ "--channel=" => 123})
85
95
 
86
96
  described_class.new.disable_channel(123, :username => "SomeUser", :password => "SomePass")
87
97
  end
@@ -105,7 +115,8 @@ describe LinuxAdmin::Rhn do
105
115
  }
106
116
  }
107
117
 
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")))
118
+ expect(LinuxAdmin::Common).to receive(:run!).once.with(cmd, params)
119
+ .and_return(double(:output => sample_output("rhn/output_rhn-channel_list_available")))
109
120
 
110
121
  expect(described_class.new.available_channels(credentials)).to eq(expected)
111
122
  end
@@ -123,8 +134,10 @@ describe LinuxAdmin::Rhn do
123
134
  {:repo_id => "rhel-x86_64-server-6", :enabled => true}
124
135
  ]
125
136
 
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")))
137
+ expect(LinuxAdmin::Common).to receive(:run!).once
138
+ .and_return(double(:output => sample_output("rhn/output_rhn-channel_list_available")))
139
+ expect(LinuxAdmin::Common).to receive(:run!).once.with("rhn-channel -l")
140
+ .and_return(double(:output => sample_output("rhn/output_rhn-channel_list")))
128
141
 
129
142
  expect(described_class.new.all_repos(credentials)).to eq(expected)
130
143
  end
data/spec/rpm_spec.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  describe LinuxAdmin::Rpm do
2
2
  it ".list_installed" do
3
- allow(described_class).to receive_messages(:run! => double(:output => sample_output("rpm/cmd_output_for_list_installed")))
3
+ allow(LinuxAdmin::Common).to receive(:run!)
4
+ .and_return(double(:output => sample_output("rpm/cmd_output_for_list_installed")))
4
5
  expect(described_class.list_installed).to eq({
5
6
  "ruby193-rubygem-some_really_long_name" =>"1.0.7-1.el6",
6
7
  "fipscheck-lib" =>"1.2.0-7.el6",
@@ -26,7 +27,7 @@ describe LinuxAdmin::Rpm do
26
27
  end
27
28
 
28
29
  it ".import_key" do
29
- expect(described_class).to receive(:run!).with("rpm", {:params => {"--import" => "abc"}})
30
+ expect(LinuxAdmin::Common).to receive(:run!).with("rpm", :params => {"--import" => "abc"})
30
31
  expect { described_class.import_key("abc") }.to_not raise_error
31
32
  end
32
33
 
@@ -59,7 +60,7 @@ straight-forward, and extensible.
59
60
  EOS
60
61
  arguments = [described_class.rpm_cmd, :params => {"-qi" => "ruby"}]
61
62
  result = AwesomeSpawn::CommandResult.new("", data, "", 0)
62
- expect(described_class).to receive(:run!).with(*arguments).and_return(result)
63
+ expect(LinuxAdmin::Common).to receive(:run!).with(*arguments).and_return(result)
63
64
  metadata = described_class.info("ruby")
64
65
  expect(metadata['name']).to eq('ruby')
65
66
  expect(metadata['version']).to eq('2.0.0.247')
@@ -77,7 +78,8 @@ EOS
77
78
  end
78
79
 
79
80
  it ".upgrade" do
80
- expect(described_class).to receive(:run).with("rpm -U", {:params=>{nil=>"abc"}}).and_return(double(:exit_status => 0))
81
+ expect(LinuxAdmin::Common).to receive(:run).with("rpm -U", :params => {nil => "abc"})
82
+ .and_return(double(:exit_status => 0))
81
83
  expect(described_class.upgrade("abc")).to be_truthy
82
84
  end
83
85
  end
@@ -5,24 +5,24 @@ describe LinuxAdmin::SysVInitService do
5
5
 
6
6
  describe "#running?" do
7
7
  it "checks service" do
8
- expect(@service).to receive(:run).
9
- with(@service.cmd(:service),
10
- :params => { nil => ['foo', 'status']}).and_return(double(:exit_status => 0))
8
+ expect(LinuxAdmin::Common).to receive(:run)
9
+ .with(LinuxAdmin::Common.cmd(:service),
10
+ :params => {nil => %w(foo status)}).and_return(double(:exit_status => 0))
11
11
  @service.running?
12
12
  end
13
13
 
14
14
  context "service is running" do
15
15
  it "returns true" do
16
16
  @service = described_class.new :id => :foo
17
- expect(@service).to receive(:run).and_return(double(:exit_status => 0))
17
+ expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 0))
18
18
  expect(@service).to be_running
19
- end
19
+ end
20
20
  end
21
21
 
22
22
  context "service is not running" do
23
23
  it "returns false" do
24
24
  @service = described_class.new :id => :foo
25
- expect(@service).to receive(:run).and_return(double(:exit_status => 1))
25
+ expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 1))
26
26
  expect(@service).not_to be_running
27
27
  end
28
28
  end
@@ -30,71 +30,71 @@ describe LinuxAdmin::SysVInitService do
30
30
 
31
31
  describe "#enable" do
32
32
  it "enables service" do
33
- expect(@service).to receive(:run!).
34
- with(@service.cmd(:chkconfig),
35
- :params => { nil => [ 'foo', 'on']})
33
+ expect(LinuxAdmin::Common).to receive(:run!)
34
+ .with(LinuxAdmin::Common.cmd(:chkconfig),
35
+ :params => {nil => %w(foo on)})
36
36
  @service.enable
37
37
  end
38
38
 
39
39
  it "returns self" do
40
- expect(@service).to receive(:run!) # stub out cmd invocation
40
+ expect(LinuxAdmin::Common).to receive(:run!) # stub out cmd invocation
41
41
  expect(@service.enable).to eq(@service)
42
42
  end
43
43
  end
44
44
 
45
45
  describe "#disable" do
46
46
  it "disable service" do
47
- expect(@service).to receive(:run!).
48
- with(@service.cmd(:chkconfig),
49
- :params => { nil => [ 'foo', 'off']})
47
+ expect(LinuxAdmin::Common).to receive(:run!)
48
+ .with(LinuxAdmin::Common.cmd(:chkconfig),
49
+ :params => {nil => %w(foo off)})
50
50
  @service.disable
51
51
  end
52
52
 
53
53
  it "returns self" do
54
- expect(@service).to receive(:run!)
54
+ expect(LinuxAdmin::Common).to receive(:run!)
55
55
  expect(@service.disable).to eq(@service)
56
56
  end
57
57
  end
58
58
 
59
59
  describe "#start" do
60
60
  it "starts service" do
61
- expect(@service).to receive(:run!).
62
- with(@service.cmd(:service),
63
- :params => { nil => [ 'foo', 'start']})
61
+ expect(LinuxAdmin::Common).to receive(:run!)
62
+ .with(LinuxAdmin::Common.cmd(:service),
63
+ :params => {nil => %w(foo start)})
64
64
  @service.start
65
65
  end
66
66
 
67
67
  it "returns self" do
68
- expect(@service).to receive(:run!)
68
+ expect(LinuxAdmin::Common).to receive(:run!)
69
69
  expect(@service.start).to eq(@service)
70
70
  end
71
71
  end
72
72
 
73
73
  describe "#stop" do
74
74
  it "stops service" do
75
- expect(@service).to receive(:run!).
76
- with(@service.cmd(:service),
77
- :params => { nil => [ 'foo', 'stop']})
75
+ expect(LinuxAdmin::Common).to receive(:run!)
76
+ .with(LinuxAdmin::Common.cmd(:service),
77
+ :params => {nil => %w(foo stop)})
78
78
  @service.stop
79
79
  end
80
80
 
81
81
  it "returns self" do
82
- expect(@service).to receive(:run!)
82
+ expect(LinuxAdmin::Common).to receive(:run!)
83
83
  expect(@service.stop).to eq(@service)
84
84
  end
85
85
  end
86
86
 
87
87
  describe "#restart" do
88
88
  it "stops service" do
89
- expect(@service).to receive(:run).
90
- with(@service.cmd(:service),
91
- :params => { nil => [ 'foo', 'restart']}).and_return(double(:exit_status => 0))
89
+ expect(LinuxAdmin::Common).to receive(:run)
90
+ .with(LinuxAdmin::Common.cmd(:service),
91
+ :params => {nil => %w(foo restart)}).and_return(double(:exit_status => 0))
92
92
  @service.restart
93
93
  end
94
94
 
95
95
  context "service restart fails" do
96
96
  it "manually stops/starts service" do
97
- expect(@service).to receive(:run).and_return(double(:exit_status => 1))
97
+ expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 1))
98
98
  expect(@service).to receive(:stop)
99
99
  expect(@service).to receive(:start)
100
100
  @service.restart
@@ -102,9 +102,8 @@ describe LinuxAdmin::SysVInitService do
102
102
  end
103
103
 
104
104
  it "returns self" do
105
- expect(@service).to receive(:run).and_return(double(:exit_status => 0))
105
+ expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 0))
106
106
  expect(@service.restart).to eq(@service)
107
107
  end
108
108
  end
109
-
110
109
  end
@@ -5,96 +5,96 @@ describe LinuxAdmin::SystemdService do
5
5
 
6
6
  describe "#running?" do
7
7
  it "checks service" do
8
- expect(@service).to receive(:run)
9
- .with(@service.cmd(:systemctl),
8
+ expect(LinuxAdmin::Common).to receive(:run)
9
+ .with(LinuxAdmin::Common.cmd(:systemctl),
10
10
  :params => {nil => %w(status foo)}).and_return(double(:exit_status => 0))
11
11
  @service.running?
12
12
  end
13
13
 
14
14
  it "returns true when service is running" do
15
- expect(@service).to receive(:run).and_return(double(:exit_status => 0))
15
+ expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 0))
16
16
  expect(@service).to be_running
17
17
  end
18
18
 
19
19
  it "returns false when service is not running" do
20
- expect(@service).to receive(:run).and_return(double(:exit_status => 1))
20
+ expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 1))
21
21
  expect(@service).not_to be_running
22
22
  end
23
23
  end
24
24
 
25
25
  describe "#enable" do
26
26
  it "enables service" do
27
- expect(@service).to receive(:run!)
28
- .with(@service.cmd(:systemctl),
27
+ expect(LinuxAdmin::Common).to receive(:run!)
28
+ .with(LinuxAdmin::Common.cmd(:systemctl),
29
29
  :params => {nil => %w(enable foo)})
30
30
  @service.enable
31
31
  end
32
32
 
33
33
  it "returns self" do
34
- expect(@service).to receive(:run!) # stub out cmd invocation
34
+ expect(LinuxAdmin::Common).to receive(:run!) # stub out cmd invocation
35
35
  expect(@service.enable).to eq(@service)
36
36
  end
37
37
  end
38
38
 
39
39
  describe "#disable" do
40
40
  it "disables service" do
41
- expect(@service).to receive(:run!)
42
- .with(@service.cmd(:systemctl),
41
+ expect(LinuxAdmin::Common).to receive(:run!)
42
+ .with(LinuxAdmin::Common.cmd(:systemctl),
43
43
  :params => {nil => %w(disable foo)})
44
44
  @service.disable
45
45
  end
46
46
 
47
47
  it "returns self" do
48
- expect(@service).to receive(:run!)
48
+ expect(LinuxAdmin::Common).to receive(:run!)
49
49
  expect(@service.disable).to eq(@service)
50
50
  end
51
51
  end
52
52
 
53
53
  describe "#start" do
54
54
  it "starts service" do
55
- expect(@service).to receive(:run!)
56
- .with(@service.cmd(:systemctl),
55
+ expect(LinuxAdmin::Common).to receive(:run!)
56
+ .with(LinuxAdmin::Common.cmd(:systemctl),
57
57
  :params => {nil => %w(start foo)})
58
58
  @service.start
59
59
  end
60
60
 
61
61
  it "returns self" do
62
- expect(@service).to receive(:run!)
62
+ expect(LinuxAdmin::Common).to receive(:run!)
63
63
  expect(@service.start).to eq(@service)
64
64
  end
65
65
  end
66
66
 
67
67
  describe "#stop" do
68
68
  it "stops service" do
69
- expect(@service).to receive(:run!)
70
- .with(@service.cmd(:systemctl),
69
+ expect(LinuxAdmin::Common).to receive(:run!)
70
+ .with(LinuxAdmin::Common.cmd(:systemctl),
71
71
  :params => {nil => %w(stop foo)})
72
72
  @service.stop
73
73
  end
74
74
 
75
75
  it "returns self" do
76
- expect(@service).to receive(:run!)
76
+ expect(LinuxAdmin::Common).to receive(:run!)
77
77
  expect(@service.stop).to eq(@service)
78
78
  end
79
79
  end
80
80
 
81
81
  describe "#restart" do
82
82
  it "restarts service" do
83
- expect(@service).to receive(:run)
84
- .with(@service.cmd(:systemctl),
83
+ expect(LinuxAdmin::Common).to receive(:run)
84
+ .with(LinuxAdmin::Common.cmd(:systemctl),
85
85
  :params => {nil => %w(restart foo)}).and_return(double(:exit_status => 0))
86
86
  @service.restart
87
87
  end
88
88
 
89
89
  it "manually stops then starts service when restart fails" do
90
- expect(@service).to receive(:run).and_return(double(:exit_status => 1))
90
+ expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 1))
91
91
  expect(@service).to receive(:stop)
92
92
  expect(@service).to receive(:start)
93
93
  @service.restart
94
94
  end
95
95
 
96
96
  it "returns self" do
97
- expect(@service).to receive(:run).and_return(double(:exit_status => 0))
97
+ expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 0))
98
98
  expect(@service.restart).to eq(@service)
99
99
  end
100
100
  end