linux_admin 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/linux_admin.rb +1 -0
- data/lib/linux_admin/command_result.rb +9 -0
- data/lib/linux_admin/common.rb +37 -23
- data/lib/linux_admin/disk.rb +6 -10
- data/lib/linux_admin/exceptions.rb +16 -1
- data/lib/linux_admin/logical_volume.rb +3 -5
- data/lib/linux_admin/partition.rb +3 -3
- data/lib/linux_admin/physical_volume.rb +3 -5
- data/lib/linux_admin/registration_system/rhn.rb +2 -2
- data/lib/linux_admin/registration_system/subscription_manager.rb +13 -7
- data/lib/linux_admin/rpm.rb +1 -1
- data/lib/linux_admin/service.rb +6 -8
- data/lib/linux_admin/system.rb +2 -2
- data/lib/linux_admin/version.rb +1 -1
- data/lib/linux_admin/volume_group.rb +4 -6
- data/lib/linux_admin/yum.rb +5 -5
- data/spec/common_spec.rb +55 -25
- data/spec/disk_spec.rb +15 -16
- data/spec/logical_volume_spec.rb +14 -15
- data/spec/partition_spec.rb +7 -7
- data/spec/physical_volume_spec.rb +15 -16
- data/spec/registration_system_spec.rb +2 -2
- data/spec/rhn_spec.rb +3 -3
- data/spec/rpm_spec.rb +1 -1
- data/spec/service_spec.rb +14 -16
- data/spec/subscription_manager_spec.rb +19 -9
- data/spec/system_spec.rb +2 -2
- data/spec/volume_group_spec.rb +11 -12
- data/spec/yum_spec.rb +14 -14
- metadata +3 -2
@@ -18,13 +18,13 @@ describe LinuxAdmin::RegistrationSystem do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should memoize results" do
|
21
|
-
described_class.should_receive(:registration_type_uncached).once.
|
21
|
+
described_class.should_receive(:registration_type_uncached).once.and_return("anything_non_nil")
|
22
22
|
described_class.registration_type
|
23
23
|
described_class.registration_type
|
24
24
|
end
|
25
25
|
|
26
26
|
it "with reload should refresh results" do
|
27
|
-
described_class.should_receive(:registration_type_uncached).twice.
|
27
|
+
described_class.should_receive(:registration_type_uncached).twice.and_return("anything_non_nil")
|
28
28
|
described_class.registration_type
|
29
29
|
described_class.registration_type(true)
|
30
30
|
end
|
data/spec/rhn_spec.rb
CHANGED
@@ -24,7 +24,7 @@ describe LinuxAdmin::Rhn do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "with username and password" do
|
27
|
-
described_class.any_instance.should_receive(:run).once.with("rhnreg_ks", {:params=>{"--username="=>"SomeUser", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass", "--serverUrl="=>"192.168.1.1"}})
|
27
|
+
described_class.any_instance.should_receive(:run!).once.with("rhnreg_ks", {:params=>{"--username="=>"SomeUser", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass", "--serverUrl="=>"192.168.1.1"}})
|
28
28
|
described_class.new.register(
|
29
29
|
:username => "SomeUser",
|
30
30
|
:password => "SomePass",
|
@@ -36,7 +36,7 @@ describe LinuxAdmin::Rhn do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "with activation key" do
|
39
|
-
described_class.any_instance.should_receive(:run).once.with("rhnreg_ks", {:params=>{"--activationkey="=>"123abc", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass", "--serverUrl="=>"192.168.1.1"}})
|
39
|
+
described_class.any_instance.should_receive(:run!).once.with("rhnreg_ks", {:params=>{"--activationkey="=>"123abc", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass", "--serverUrl="=>"192.168.1.1"}})
|
40
40
|
described_class.new.register(
|
41
41
|
:activationkey => "123abc",
|
42
42
|
:proxy_address => "1.2.3.4",
|
@@ -53,7 +53,7 @@ describe LinuxAdmin::Rhn do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it "with pools" do
|
56
|
-
described_class.any_instance.should_receive(:run).once.with("rhn-channel -a", {:params=>[["--user=", "SomeUser"], ["--password=", "SomePass"], ["--channel=", 123], ["--channel=", 456]]})
|
56
|
+
described_class.any_instance.should_receive(:run!).once.with("rhn-channel -a", {:params=>[["--user=", "SomeUser"], ["--password=", "SomePass"], ["--channel=", 123], ["--channel=", 456]]})
|
57
57
|
described_class.new.subscribe({
|
58
58
|
:username => "SomeUser",
|
59
59
|
:password => "SomePass",
|
data/spec/rpm_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe LinuxAdmin::Rpm do
|
4
4
|
it ".list_installed" do
|
5
|
-
described_class.stub(:run => sample_output("rpm/cmd_output_for_list_installed"))
|
5
|
+
described_class.stub(:run! => double(:output => sample_output("rpm/cmd_output_for_list_installed")))
|
6
6
|
expect(described_class.list_installed).to eq({
|
7
7
|
"ruby193-rubygem-some_really_long_name" =>"1.0.7-1.el6",
|
8
8
|
"fipscheck-lib" =>"1.2.0-7.el6",
|
data/spec/service_spec.rb
CHANGED
@@ -13,15 +13,14 @@ describe LinuxAdmin::Service do
|
|
13
13
|
it "checks service" do
|
14
14
|
@service.should_receive(:run).
|
15
15
|
with(@service.cmd(:service),
|
16
|
-
:params => { nil => ['foo', 'status']}
|
17
|
-
:return_exitstatus => true)
|
16
|
+
:params => { nil => ['foo', 'status']}).and_return(double(:exit_status => 0))
|
18
17
|
@service.running?
|
19
18
|
end
|
20
19
|
|
21
20
|
context "service is running" do
|
22
21
|
it "returns true" do
|
23
22
|
@service = LinuxAdmin::Service.new :id => :foo
|
24
|
-
@service.should_receive(:run).and_return(0)
|
23
|
+
@service.should_receive(:run).and_return(double(:exit_status => 0))
|
25
24
|
@service.should be_running
|
26
25
|
end
|
27
26
|
end
|
@@ -29,7 +28,7 @@ describe LinuxAdmin::Service do
|
|
29
28
|
context "service is not running" do
|
30
29
|
it "returns false" do
|
31
30
|
@service = LinuxAdmin::Service.new :id => :foo
|
32
|
-
@service.should_receive(:run).and_return(1)
|
31
|
+
@service.should_receive(:run).and_return(double(:exit_status => 1))
|
33
32
|
@service.should_not be_running
|
34
33
|
end
|
35
34
|
end
|
@@ -37,56 +36,56 @@ describe LinuxAdmin::Service do
|
|
37
36
|
|
38
37
|
describe "#enable" do
|
39
38
|
it "enables service" do
|
40
|
-
@service.should_receive(:run).
|
39
|
+
@service.should_receive(:run!).
|
41
40
|
with(@service.cmd(:systemctl),
|
42
41
|
:params => { nil => [ 'enable', 'foo.service']})
|
43
42
|
@service.enable
|
44
43
|
end
|
45
44
|
|
46
45
|
it "returns self" do
|
47
|
-
@service.should_receive(:run) # stub out cmd invocation
|
46
|
+
@service.should_receive(:run!) # stub out cmd invocation
|
48
47
|
@service.enable.should == @service
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
52
51
|
describe "#disable" do
|
53
52
|
it "disable service" do
|
54
|
-
@service.should_receive(:run).
|
53
|
+
@service.should_receive(:run!).
|
55
54
|
with(@service.cmd(:systemctl),
|
56
55
|
:params => { nil => [ 'disable', 'foo.service']})
|
57
56
|
@service.disable
|
58
57
|
end
|
59
58
|
|
60
59
|
it "returns self" do
|
61
|
-
@service.should_receive(:run)
|
60
|
+
@service.should_receive(:run!)
|
62
61
|
@service.disable.should == @service
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
66
65
|
describe "#start" do
|
67
66
|
it "starts service" do
|
68
|
-
@service.should_receive(:run).
|
67
|
+
@service.should_receive(:run!).
|
69
68
|
with(@service.cmd(:service),
|
70
69
|
:params => { nil => [ 'foo', 'start']})
|
71
70
|
@service.start
|
72
71
|
end
|
73
72
|
|
74
73
|
it "returns self" do
|
75
|
-
@service.should_receive(:run)
|
74
|
+
@service.should_receive(:run!)
|
76
75
|
@service.start.should == @service
|
77
76
|
end
|
78
77
|
end
|
79
78
|
|
80
79
|
describe "#stop" do
|
81
80
|
it "stops service" do
|
82
|
-
@service.should_receive(:run).
|
81
|
+
@service.should_receive(:run!).
|
83
82
|
with(@service.cmd(:service),
|
84
83
|
:params => { nil => [ 'foo', 'stop']})
|
85
84
|
@service.stop
|
86
85
|
end
|
87
86
|
|
88
87
|
it "returns self" do
|
89
|
-
@service.should_receive(:run)
|
88
|
+
@service.should_receive(:run!)
|
90
89
|
@service.stop.should == @service
|
91
90
|
end
|
92
91
|
end
|
@@ -95,14 +94,13 @@ describe LinuxAdmin::Service do
|
|
95
94
|
it "stops service" do
|
96
95
|
@service.should_receive(:run).
|
97
96
|
with(@service.cmd(:service),
|
98
|
-
:params => { nil => [ 'foo', 'restart']}
|
99
|
-
:return_exitstatus => true).and_return(0)
|
97
|
+
:params => { nil => [ 'foo', 'restart']}).and_return(double(:exit_status => 0))
|
100
98
|
@service.restart
|
101
99
|
end
|
102
100
|
|
103
101
|
context "service restart fails" do
|
104
102
|
it "manually stops/starts service" do
|
105
|
-
@service.should_receive(:run).and_return(1)
|
103
|
+
@service.should_receive(:run).and_return(double(:exit_status => 1))
|
106
104
|
@service.should_receive(:stop)
|
107
105
|
@service.should_receive(:start)
|
108
106
|
@service.restart
|
@@ -110,7 +108,7 @@ describe LinuxAdmin::Service do
|
|
110
108
|
end
|
111
109
|
|
112
110
|
it "returns self" do
|
113
|
-
@service.should_receive(:run).and_return(0)
|
111
|
+
@service.should_receive(:run).and_return(double(:exit_status => 0))
|
114
112
|
@service.restart.should == @service
|
115
113
|
end
|
116
114
|
end
|
@@ -3,18 +3,18 @@ require 'spec_helper'
|
|
3
3
|
describe LinuxAdmin::SubscriptionManager do
|
4
4
|
context "#registered?" do
|
5
5
|
it "system with subscription-manager commands" do
|
6
|
-
described_class.any_instance.should_receive(:run).once.with("subscription-manager identity"
|
6
|
+
described_class.any_instance.should_receive(:run).once.with("subscription-manager identity").and_return(double(:exit_status => 0))
|
7
7
|
expect(described_class.new.registered?).to be_true
|
8
8
|
end
|
9
9
|
|
10
10
|
it "system without subscription-manager commands" do
|
11
|
-
described_class.any_instance.should_receive(:run).once.with("subscription-manager identity"
|
11
|
+
described_class.any_instance.should_receive(:run).once.with("subscription-manager identity").and_return(double(:exit_status => 255))
|
12
12
|
expect(described_class.new.registered?).to be_false
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
it "#refresh" do
|
17
|
-
described_class.any_instance.should_receive(:run).once.with("subscription-manager refresh")
|
17
|
+
described_class.any_instance.should_receive(:run!).once.with("subscription-manager refresh")
|
18
18
|
described_class.new.refresh
|
19
19
|
end
|
20
20
|
|
@@ -24,7 +24,8 @@ describe LinuxAdmin::SubscriptionManager do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "with username and password" do
|
27
|
-
|
27
|
+
run_options = ["subscription-manager register", {:params=>{"--username="=>"SomeUser", "--password="=>"SomePass", "--org="=>"IT", "--proxy="=>"1.2.3.4", "--proxyuser="=>"ProxyUser", "--proxypassword="=>"ProxyPass", "--serverurl="=>"192.168.1.1"}}]
|
28
|
+
described_class.any_instance.should_receive(:run!).once.with(*run_options)
|
28
29
|
described_class.new.register(
|
29
30
|
:username => "SomeUser",
|
30
31
|
:password => "SomePass",
|
@@ -38,12 +39,12 @@ describe LinuxAdmin::SubscriptionManager do
|
|
38
39
|
end
|
39
40
|
|
40
41
|
it "#subscribe" do
|
41
|
-
described_class.any_instance.should_receive(:run).once.with("subscription-manager attach", {:params=>[["--pool", 123], ["--pool", 456]]})
|
42
|
+
described_class.any_instance.should_receive(:run!).once.with("subscription-manager attach", {:params=>[["--pool", 123], ["--pool", 456]]})
|
42
43
|
described_class.new.subscribe({:pools => [123, 456]})
|
43
44
|
end
|
44
45
|
|
45
46
|
it "#available_subscriptions" do
|
46
|
-
described_class.any_instance.should_receive(:run).once.with("subscription-manager list --all --available"
|
47
|
+
described_class.any_instance.should_receive(:run!).once.with("subscription-manager list --all --available").and_return(double(:output => sample_output("subscription_manager/output_list_all_available")))
|
47
48
|
expect(described_class.new.available_subscriptions).to eq({
|
48
49
|
"82c042fca983889b10178893f29b06e3" => {
|
49
50
|
:subscription_name => "Example Subscription",
|
@@ -92,8 +93,17 @@ describe LinuxAdmin::SubscriptionManager do
|
|
92
93
|
})
|
93
94
|
end
|
94
95
|
|
95
|
-
|
96
|
-
|
97
|
-
|
96
|
+
context "#organizations" do
|
97
|
+
it "with valid credentials" do
|
98
|
+
run_options = ["subscription-manager orgs", {:params=>{"--username="=>"SomeUser", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyuser="=>"ProxyUser", "--proxypassword="=>"ProxyPass", "--serverurl="=>"192.168.1.1"}}]
|
99
|
+
described_class.any_instance.should_receive(:run!).once.with(*run_options).and_return(double(:output => sample_output("subscription_manager/output_orgs")))
|
100
|
+
expect(described_class.new.organizations({:username=>"SomeUser", :password=>"SomePass", :proxy_address=>"1.2.3.4", :proxy_username=>"ProxyUser", :proxy_password=>"ProxyPass", :server_url=>"192.168.1.1"})).to eq({"SomeOrg"=>{:name=>"SomeOrg", :key=>"1234567"}})
|
101
|
+
end
|
102
|
+
|
103
|
+
it "with invalid credentials" do
|
104
|
+
run_options = ["subscription-manager orgs", {:params=>{"--username="=>"BadUser", "--password="=>"BadPass"}}]
|
105
|
+
described_class.any_instance.should_receive(:run).once.with(*run_options).and_return(CommandResult.new("", "Invalid username or password. To create a login, please visit https://www.redhat.com/wapps/ugc/register.html", 255))
|
106
|
+
expect { described_class.new.organizations({:username=>"BadUser", :password=>"BadPass"}) }.to raise_error(LinuxAdmin::CredentialError)
|
107
|
+
end
|
98
108
|
end
|
99
109
|
end
|
data/spec/system_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe LinuxAdmin::System do
|
4
4
|
describe "#reboot!" do
|
5
5
|
it "reboots the system" do
|
6
|
-
LinuxAdmin::System.should_receive(:run).
|
6
|
+
LinuxAdmin::System.should_receive(:run!).
|
7
7
|
with(LinuxAdmin::System.cmd(:shutdown),
|
8
8
|
:params => { '-r' => 'now'})
|
9
9
|
LinuxAdmin::System.reboot!
|
@@ -12,7 +12,7 @@ describe LinuxAdmin::System do
|
|
12
12
|
|
13
13
|
describe "#shutdown!" do
|
14
14
|
it "shuts down the system" do
|
15
|
-
LinuxAdmin::System.should_receive(:run).
|
15
|
+
LinuxAdmin::System.should_receive(:run!).
|
16
16
|
with(LinuxAdmin::System.cmd(:shutdown),
|
17
17
|
:params => { '-h' => '0'})
|
18
18
|
LinuxAdmin::System.shutdown!
|
data/spec/volume_group_spec.rb
CHANGED
@@ -20,7 +20,7 @@ eos
|
|
20
20
|
it "uses lvextend" do
|
21
21
|
lv = LinuxAdmin::LogicalVolume.new :name => 'lv'
|
22
22
|
vg = described_class.new :name => 'vg'
|
23
|
-
vg.should_receive(:run).
|
23
|
+
vg.should_receive(:run!).
|
24
24
|
with(vg.cmd(:lvextend),
|
25
25
|
:params => ['lv', 'vg'])
|
26
26
|
vg.attach_to(lv)
|
@@ -29,7 +29,7 @@ eos
|
|
29
29
|
it "returns self" do
|
30
30
|
lv = LinuxAdmin::LogicalVolume.new :name => 'lv'
|
31
31
|
vg = described_class.new :name => 'vg'
|
32
|
-
vg.stub(:run)
|
32
|
+
vg.stub(:run!)
|
33
33
|
vg.attach_to(lv).should == vg
|
34
34
|
end
|
35
35
|
end
|
@@ -38,7 +38,7 @@ eos
|
|
38
38
|
it "uses vgextend" do
|
39
39
|
vg = described_class.new :name => 'vg'
|
40
40
|
pv = LinuxAdmin::PhysicalVolume.new :device_name => '/dev/hda'
|
41
|
-
vg.should_receive(:run).
|
41
|
+
vg.should_receive(:run!).
|
42
42
|
with(vg.cmd(:vgextend),
|
43
43
|
:params => ['vg', '/dev/hda'])
|
44
44
|
vg.extend_with(pv)
|
@@ -47,7 +47,7 @@ eos
|
|
47
47
|
it "assigns volume group to physical volume" do
|
48
48
|
vg = described_class.new :name => 'vg'
|
49
49
|
pv = LinuxAdmin::PhysicalVolume.new :device_name => '/dev/hda'
|
50
|
-
vg.stub(:run)
|
50
|
+
vg.stub(:run!)
|
51
51
|
vg.extend_with(pv)
|
52
52
|
pv.volume_group.should == vg
|
53
53
|
end
|
@@ -55,7 +55,7 @@ eos
|
|
55
55
|
it "returns self" do
|
56
56
|
vg = described_class.new :name => 'vg'
|
57
57
|
pv = LinuxAdmin::PhysicalVolume.new :device_name => '/dev/hda'
|
58
|
-
vg.stub(:run)
|
58
|
+
vg.stub(:run!)
|
59
59
|
vg.extend_with(pv).should == vg
|
60
60
|
end
|
61
61
|
end
|
@@ -67,21 +67,21 @@ eos
|
|
67
67
|
|
68
68
|
it "uses vgcreate" do
|
69
69
|
described_class.instance_variable_set(:@vgs, [])
|
70
|
-
described_class.should_receive(:run).
|
70
|
+
described_class.should_receive(:run!).
|
71
71
|
with(LinuxAdmin.cmd(:vgcreate),
|
72
72
|
:params => ['vg', '/dev/hda'])
|
73
73
|
described_class.create 'vg', @pv
|
74
74
|
end
|
75
75
|
|
76
76
|
it "returns new volume group" do
|
77
|
-
described_class.stub(:run => "")
|
77
|
+
described_class.stub(:run! => double(:output => ""))
|
78
78
|
vg = described_class.create 'vg', @pv
|
79
79
|
vg.should be_an_instance_of(described_class)
|
80
80
|
vg.name.should == 'vg'
|
81
81
|
end
|
82
82
|
|
83
83
|
it "adds volume group to local registry" do
|
84
|
-
described_class.stub(:run => "")
|
84
|
+
described_class.stub(:run! => double(:output => ""))
|
85
85
|
vg = described_class.create 'vg', @pv
|
86
86
|
described_class.scan.should include(vg)
|
87
87
|
end
|
@@ -89,16 +89,15 @@ eos
|
|
89
89
|
|
90
90
|
describe "#scan" do
|
91
91
|
it "uses vgdisplay" do
|
92
|
-
described_class.should_receive(:run).
|
92
|
+
described_class.should_receive(:run!).
|
93
93
|
with(LinuxAdmin.cmd(:vgdisplay),
|
94
|
-
:return_output => true,
|
95
94
|
:params => { '-c' => nil}).
|
96
|
-
and_return(@groups)
|
95
|
+
and_return(double(:output => @groups))
|
97
96
|
described_class.scan
|
98
97
|
end
|
99
98
|
|
100
99
|
it "returns local volume groups" do
|
101
|
-
described_class.should_receive(:run).and_return(@groups)
|
100
|
+
described_class.should_receive(:run!).and_return(double(:output => @groups))
|
102
101
|
vgs = described_class.scan
|
103
102
|
|
104
103
|
vgs[0].should be_an_instance_of(described_class)
|
data/spec/yum_spec.rb
CHANGED
@@ -7,20 +7,20 @@ describe LinuxAdmin::Yum do
|
|
7
7
|
|
8
8
|
context ".create_repo" do
|
9
9
|
it "default arguments" do
|
10
|
-
described_class.should_receive(:run).once.with("yum createrepo", {:params=>{nil=>"some/path", "--database"=>nil, "--unique-md-filenames"=>nil}})
|
11
|
-
|
10
|
+
described_class.should_receive(:run!).once.with("yum createrepo", {:params=>{nil=>"some/path", "--database"=>nil, "--unique-md-filenames"=>nil}})
|
11
|
+
described_class.create_repo("some/path")
|
12
12
|
end
|
13
13
|
|
14
14
|
it "bare create" do
|
15
|
-
described_class.should_receive(:run).once.with("yum createrepo", {:params=>{nil=>"some/path"}})
|
16
|
-
|
15
|
+
described_class.should_receive(:run!).once.with("yum createrepo", {:params=>{nil=>"some/path"}})
|
16
|
+
described_class.create_repo("some/path", :database => false, :unique_file_names => false)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
context ".download_packages" do
|
21
21
|
it "with valid input" do
|
22
|
-
described_class.should_receive(:run).once.with("yum repotrack", {:params=>{"-p"=>"some/path", nil=>"pkg_a pkg_b"}})
|
23
|
-
|
22
|
+
described_class.should_receive(:run!).once.with("yum repotrack", {:params=>{"-p"=>"some/path", nil=>"pkg_a pkg_b"}})
|
23
|
+
described_class.download_packages("some/path", "pkg_a pkg_b")
|
24
24
|
end
|
25
25
|
|
26
26
|
it "without mirror type" do
|
@@ -68,39 +68,39 @@ describe LinuxAdmin::Yum do
|
|
68
68
|
|
69
69
|
context ".updates_available?" do
|
70
70
|
it "check updates for a specific package" do
|
71
|
-
described_class.should_receive(:run).once.with("yum check-update", {:params=>{nil=>["abc"]}
|
71
|
+
described_class.should_receive(:run).once.with("yum check-update", {:params=>{nil=>["abc"]}}).and_return(double(:exit_status => 100))
|
72
72
|
expect(described_class.updates_available?("abc")).to be_true
|
73
73
|
end
|
74
74
|
|
75
75
|
it "updates are available" do
|
76
|
-
described_class.stub(:run => 100)
|
76
|
+
described_class.stub(:run => double(:exit_status => 100))
|
77
77
|
expect(described_class.updates_available?).to be_true
|
78
78
|
end
|
79
79
|
|
80
80
|
it "updates not available" do
|
81
|
-
described_class.stub(:run => 0)
|
81
|
+
described_class.stub(:run => double(:exit_status => 0))
|
82
82
|
expect(described_class.updates_available?).to be_false
|
83
83
|
end
|
84
84
|
|
85
85
|
it "other exit code" do
|
86
|
-
described_class.stub(:run => 255)
|
86
|
+
described_class.stub(:run => double(:exit_status => 255))
|
87
87
|
expect { described_class.updates_available? }.to raise_error
|
88
88
|
end
|
89
89
|
|
90
90
|
it "other error" do
|
91
91
|
described_class.stub(:run).and_raise(RuntimeError)
|
92
|
-
expect { described_class.updates_available? }.to raise_error
|
92
|
+
expect { described_class.updates_available? }.to raise_error(RuntimeError)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
96
|
context ".update" do
|
97
97
|
it "no arguments" do
|
98
|
-
described_class.should_receive(:run).once.with("yum -y update", {:params=>nil})
|
98
|
+
described_class.should_receive(:run!).once.with("yum -y update", {:params=>nil})
|
99
99
|
described_class.update
|
100
100
|
end
|
101
101
|
|
102
102
|
it "with arguments" do
|
103
|
-
described_class.should_receive(:run).once.with("yum -y update", {:params=>{nil=>["1 2", "3"]}})
|
103
|
+
described_class.should_receive(:run!).once.with("yum -y update", {:params=>{nil=>["1 2", "3"]}})
|
104
104
|
described_class.update("1 2", "3")
|
105
105
|
end
|
106
106
|
end
|
@@ -111,7 +111,7 @@ describe LinuxAdmin::Yum do
|
|
111
111
|
end
|
112
112
|
|
113
113
|
it "with packages" do
|
114
|
-
described_class.should_receive(:run).once.with("repoquery --qf=\"%{name} %{version}\"", {:params=>{nil=>["curl"]}
|
114
|
+
described_class.should_receive(:run!).once.with("repoquery --qf=\"%{name} %{version}\"", {:params=>{nil=>["curl"]}}).and_return(double(:output => sample_output("yum/output_repoquery")))
|
115
115
|
expect(described_class.version_available("curl")).to eq({
|
116
116
|
"curl" => "7.19.7",
|
117
117
|
"subscription-manager" => "1.1.23.1",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linux_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-08-
|
15
|
+
date: 2013-08-16 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: bundler
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- Rakefile
|
169
169
|
- examples/subscription_manager_hosted.rb
|
170
170
|
- lib/linux_admin.rb
|
171
|
+
- lib/linux_admin/command_result.rb
|
171
172
|
- lib/linux_admin/common.rb
|
172
173
|
- lib/linux_admin/disk.rb
|
173
174
|
- lib/linux_admin/distro.rb
|