virtualbox 0.4.1 → 0.4.2
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/Readme.md +9 -9
- data/VERSION +1 -1
- data/docs/GettingStarted.md +11 -11
- data/docs/WhatsNew.md +1 -1
- data/lib/virtualbox.rb +10 -1
- data/lib/virtualbox/abstract_model.rb +47 -29
- data/lib/virtualbox/abstract_model/attributable.rb +16 -16
- data/lib/virtualbox/abstract_model/dirty.rb +10 -10
- data/lib/virtualbox/abstract_model/relatable.rb +22 -22
- data/lib/virtualbox/abstract_model/validatable.rb +4 -4
- data/lib/virtualbox/attached_device.rb +23 -23
- data/lib/virtualbox/command.rb +9 -9
- data/lib/virtualbox/dvd.rb +7 -7
- data/lib/virtualbox/ext/subclass_listing.rb +1 -1
- data/lib/virtualbox/extra_data.rb +17 -17
- data/lib/virtualbox/forwarded_port.rb +23 -23
- data/lib/virtualbox/hard_drive.rb +27 -27
- data/lib/virtualbox/image.rb +25 -18
- data/lib/virtualbox/nic.rb +22 -22
- data/lib/virtualbox/proxies/collection.rb +4 -4
- data/lib/virtualbox/shared_folder.rb +25 -25
- data/lib/virtualbox/storage_controller.rb +16 -16
- data/lib/virtualbox/vm.rb +95 -42
- data/test/virtualbox/abstract_model/attributable_test.rb +28 -28
- data/test/virtualbox/abstract_model/dirty_test.rb +13 -13
- data/test/virtualbox/abstract_model/relatable_test.rb +36 -36
- data/test/virtualbox/abstract_model/validatable_test.rb +22 -22
- data/test/virtualbox/abstract_model_test.rb +46 -36
- data/test/virtualbox/attached_device_test.rb +47 -47
- data/test/virtualbox/command_test.rb +12 -12
- data/test/virtualbox/dvd_test.rb +15 -19
- data/test/virtualbox/ext/subclass_listing_test.rb +2 -2
- data/test/virtualbox/extra_data_test.rb +37 -37
- data/test/virtualbox/forwarded_port_test.rb +31 -31
- data/test/virtualbox/hard_drive_test.rb +40 -48
- data/test/virtualbox/image_test.rb +36 -33
- data/test/virtualbox/nic_test.rb +22 -22
- data/test/virtualbox/proxies/collection_test.rb +6 -6
- data/test/virtualbox/shared_folder_test.rb +36 -36
- data/test/virtualbox/storage_controller_test.rb +14 -14
- data/test/virtualbox/vm_test.rb +121 -70
- data/test/virtualbox_test.rb +19 -0
- data/virtualbox.gemspec +5 -3
- metadata +4 -2
data/test/virtualbox/nic_test.rb
CHANGED
@@ -7,51 +7,51 @@ class NicTest < Test::Unit::TestCase
|
|
7
7
|
:nic2 => "foo",
|
8
8
|
:nic3 => "bar"
|
9
9
|
}
|
10
|
-
|
10
|
+
|
11
11
|
@caller = mock("caller")
|
12
12
|
@caller.stubs(:name).returns("foo")
|
13
|
-
|
13
|
+
|
14
14
|
VirtualBox::VM.stubs(:human_info).returns(<<-raw)
|
15
15
|
NIC 1: MAC: 08002745B49F, Attachment: Bridged Interface 'en0: Ethernet', Cable connected: on, Trace: off (file: none), Type: Am79C973, Reported speed: 0 Mbps
|
16
16
|
NIC 2: MAC: 08002745B49F, Attachment: Bridged Interface 'en0: Ethernet', Cable connected: on, Trace: off (file: none), Type: Am79C973, Reported speed: 0 Mbps
|
17
17
|
NIC 3: MAC: 08002745B49F, Attachment: Bridged Interface 'en0: Ethernet', Cable connected: on, Trace: off (file: none), Type: Am79C973, Reported speed: 0 Mbps
|
18
18
|
raw
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
context "saving" do
|
22
22
|
setup do
|
23
23
|
@nic = VirtualBox::Nic.populate_relationship(@caller, @data)
|
24
24
|
@vmname = "myvm"
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
should "use the vmname strung through the save" do
|
28
28
|
VirtualBox::Command.expects(:vboxmanage).with("modifyvm #{@vmname} --nic1 foo")
|
29
|
-
|
29
|
+
|
30
30
|
nic = @nic[0]
|
31
31
|
nic.nic = "foo"
|
32
32
|
nic.save(@vmname)
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
should "use the proper index" do
|
36
36
|
VirtualBox::Command.expects(:vboxmanage).with("modifyvm #{@vmname} --nic2 far")
|
37
|
-
|
37
|
+
|
38
38
|
nic = @nic[1]
|
39
39
|
nic.nic = "far"
|
40
40
|
nic.save(@vmname)
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
should "save the nictype" do
|
44
44
|
VirtualBox::Command.expects(:vboxmanage).with("modifyvm #{@vmname} --nictype1 ZOO")
|
45
|
-
|
45
|
+
|
46
46
|
nic = @nic[0]
|
47
47
|
nic.nictype = "ZOO"
|
48
48
|
assert nic.nictype_changed?
|
49
49
|
nic.save(@vmname)
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
should "raise a CommandFailedException if it fails" do
|
53
53
|
VirtualBox::Command.stubs(:vboxmanage).raises(VirtualBox::Exceptions::CommandFailedException)
|
54
|
-
|
54
|
+
|
55
55
|
nic = @nic[0]
|
56
56
|
nic.nictype = "ZOO"
|
57
57
|
assert_raises(VirtualBox::Exceptions::CommandFailedException) {
|
@@ -59,7 +59,7 @@ raw
|
|
59
59
|
}
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
context "populating relationships" do
|
64
64
|
setup do
|
65
65
|
@value = VirtualBox::Nic.populate_relationship(@caller, @data)
|
@@ -68,16 +68,16 @@ raw
|
|
68
68
|
should "create the correct amount of objects" do
|
69
69
|
assert_equal 3, @value.length
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
should "parse the type" do
|
73
73
|
assert_equal "Am79C973", @value[0].nictype
|
74
74
|
end
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
context "parsing nic data from human readable output" do
|
78
78
|
setup do
|
79
79
|
@raw = "NIC 1: MAC: 08002745B49F, Attachment: Bridged Interface 'en0: Ethernet', Cable connected: on, Trace: off (file: none), Type: Am79C973, Reported speed: 0 Mbps"
|
80
|
-
|
80
|
+
|
81
81
|
@multiline_raw = <<-raw
|
82
82
|
Storage Controller Port Count (0): 2
|
83
83
|
Storage Controller Name (1): Floppy Controller
|
@@ -89,21 +89,21 @@ IDE Controller (0, 0): /Users/mitchellh/Library/VirtualBox/HardDisks/HoboBase.vm
|
|
89
89
|
IDE Controller (1, 0): Empty
|
90
90
|
Floppy Controller (0, 0): Empty
|
91
91
|
NIC 1: MAC: 08002745B49F, Attachment: Bridged Interface 'en0: Ethernet', Cable connected: on, Trace: off (file: none), Type: Am79C973, Reported speed: 0 Mbps
|
92
|
-
NIC 2: disabled
|
92
|
+
NIC 2: disabled
|
93
93
|
raw
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
should "only return valid objects in hash" do
|
97
97
|
VirtualBox::VM.expects(:human_info).returns(@multiline_raw)
|
98
98
|
result = VirtualBox::Nic.nic_data("foo")
|
99
99
|
assert result.is_a?(Hash)
|
100
100
|
assert_equal 1, result.length
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
should "return nil if its an invalid string" do
|
104
104
|
assert_nil VirtualBox::Nic.parse_nic("FOO")
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
should "return proper data for valid string" do
|
108
108
|
@name = :nic1
|
109
109
|
@expected = {
|
@@ -112,16 +112,16 @@ raw
|
|
112
112
|
:trace => "off (file: none)",
|
113
113
|
:type => "Am79C973"
|
114
114
|
}
|
115
|
-
|
115
|
+
|
116
116
|
name, result = VirtualBox::Nic.parse_nic(@raw)
|
117
117
|
assert_equal @name, name
|
118
118
|
assert result.is_a?(Hash)
|
119
|
-
|
119
|
+
|
120
120
|
@expected.each do |k,v|
|
121
121
|
assert_equal v, result[k]
|
122
122
|
end
|
123
123
|
end
|
124
|
-
|
124
|
+
|
125
125
|
should "ignore nics that are disabled" do
|
126
126
|
assert_nil VirtualBox::Nic.parse_nic("NIC 1: disabled")
|
127
127
|
end
|
@@ -9,32 +9,32 @@ class CollectionTest < Test::Unit::TestCase
|
|
9
9
|
should "be a subclass of Array" do
|
10
10
|
assert @collection.is_a?(Array)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
context "element callbacks" do
|
14
14
|
setup do
|
15
15
|
@item = mock("item")
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
should "not call added_to_relationship if it doesn't exist" do
|
19
19
|
assert_nothing_raised { @collection << @item }
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
should "not call removed_from_relationship if it doesn't exist" do
|
23
23
|
@collection << @item
|
24
24
|
assert_nothing_raised { @collection.delete(@item) }
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
should "call added_to_relationship on the item when its added to a collection" do
|
28
28
|
@item.expects(:added_to_relationship).with(@parent).once
|
29
29
|
@collection << @item
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
should "call removed_from_relationship on the item when its deleted" do
|
33
33
|
@collection << @item
|
34
34
|
@item.expects(:removed_from_relationship).with(@parent).once
|
35
35
|
@collection.delete(@item)
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
should "call removed_from_relationship if clear is called" do
|
39
39
|
@collection << @item
|
40
40
|
@item.expects(:removed_from_relationship).with(@parent).once
|
@@ -8,13 +8,13 @@ class SharedFolderTest < Test::Unit::TestCase
|
|
8
8
|
:sharedfoldernamemachinemapping2 => "barfolder",
|
9
9
|
:sharedfolderpathmachinemapping2 => "/bar"
|
10
10
|
}
|
11
|
-
|
11
|
+
|
12
12
|
@caller = mock("caller")
|
13
13
|
@caller.stubs(:name).returns("foo")
|
14
|
-
|
14
|
+
|
15
15
|
VirtualBox::Command.stubs(:execute)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
context "validations" do
|
19
19
|
setup do
|
20
20
|
@sf = VirtualBox::SharedFolder.new
|
@@ -22,27 +22,27 @@ class SharedFolderTest < Test::Unit::TestCase
|
|
22
22
|
@sf.hostpath = "bar"
|
23
23
|
@sf.added_to_relationship(@caller)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
should "be valid with all fields" do
|
27
27
|
assert @sf.valid?
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
should "be invalid with no name" do
|
31
31
|
@sf.name = nil
|
32
32
|
assert !@sf.valid?
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
should "be invalid with no hostpath" do
|
36
36
|
@sf.hostpath = nil
|
37
37
|
assert !@sf.valid?
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
should "be invalid if not in a relationship" do
|
41
41
|
@sf.write_attribute(:parent, nil)
|
42
42
|
assert !@sf.valid?
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
context "saving an existing shared folder" do
|
47
47
|
setup do
|
48
48
|
@value = VirtualBox::SharedFolder.populate_relationship(@caller, @data)
|
@@ -50,46 +50,46 @@ class SharedFolderTest < Test::Unit::TestCase
|
|
50
50
|
@value.name = "different"
|
51
51
|
assert @value.changed?
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
should "first destroy the shared folder then recreate it" do
|
55
55
|
seq = sequence("create_seq")
|
56
56
|
@value.expects(:destroy).in_sequence(seq)
|
57
57
|
VirtualBox::Command.expects(:vboxmanage).in_sequence(seq)
|
58
58
|
assert @value.save
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
should "call destroy with raise errors if set" do
|
62
62
|
@value.expects(:destroy).with(true).once
|
63
63
|
assert @value.save(true)
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
context "creating a new shared folder" do
|
68
68
|
setup do
|
69
69
|
@sf = VirtualBox::SharedFolder.new
|
70
70
|
@sf.name = "foo"
|
71
71
|
@sf.hostpath = "bar"
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
should "return false and not call vboxmanage if invalid" do
|
75
75
|
VirtualBox::Command.expects(:vboxmanage).never
|
76
76
|
@sf.expects(:valid?).returns(false)
|
77
77
|
assert !@sf.save
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
should "raise a ValidationFailedException if invalid and raise_errors is true" do
|
81
81
|
@sf.expects(:valid?).returns(false)
|
82
82
|
assert_raises(VirtualBox::Exceptions::ValidationFailedException) {
|
83
83
|
@sf.save(true)
|
84
84
|
}
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
context "has a parent" do
|
88
88
|
setup do
|
89
89
|
@sf.added_to_relationship(@caller)
|
90
90
|
VirtualBox::Command.stubs(:vboxmanage)
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
should "not call destroy since its a new record" do
|
94
94
|
@sf.expects(:destroy).never
|
95
95
|
assert @sf.save
|
@@ -108,20 +108,20 @@ class SharedFolderTest < Test::Unit::TestCase
|
|
108
108
|
should "return true if the command was a success" do
|
109
109
|
assert @sf.save
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
should "raise an exception if true sent to save and error occured" do
|
113
113
|
VirtualBox::Command.stubs(:vboxmanage).raises(VirtualBox::Exceptions::CommandFailedException)
|
114
114
|
assert_raises(VirtualBox::Exceptions::CommandFailedException) {
|
115
115
|
@sf.save(true)
|
116
116
|
}
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
should "not be a new record after saving" do
|
120
120
|
assert @sf.new_record?
|
121
121
|
assert @sf.save
|
122
122
|
assert !@sf.new_record?
|
123
123
|
end
|
124
|
-
|
124
|
+
|
125
125
|
should "not be changed after saving" do
|
126
126
|
assert @sf.changed?
|
127
127
|
assert @sf.save
|
@@ -129,56 +129,56 @@ class SharedFolderTest < Test::Unit::TestCase
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
context "constructor" do
|
134
134
|
should "call initialize_for_relationship if 3 args are given" do
|
135
135
|
VirtualBox::SharedFolder.any_instance.expects(:initialize_for_relationship).with(1,2,3).once
|
136
136
|
VirtualBox::SharedFolder.new(1,2,3)
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
should "raise a NoMethodError if anything other than 0,1,or 3 arguments" do
|
140
140
|
2.upto(9) do |i|
|
141
141
|
next if i == 3
|
142
142
|
args = Array.new(i, "A")
|
143
|
-
|
143
|
+
|
144
144
|
assert_raises(NoMethodError) {
|
145
145
|
VirtualBox::SharedFolder.new(*args)
|
146
146
|
}
|
147
147
|
end
|
148
148
|
end
|
149
|
-
|
149
|
+
|
150
150
|
should "populate from a hash if one argument is given" do
|
151
151
|
VirtualBox::SharedFolder.any_instance.expects(:initialize_for_data).with("HI").once
|
152
152
|
VirtualBox::SharedFolder.new("HI")
|
153
153
|
end
|
154
|
-
|
154
|
+
|
155
155
|
context "initializing from data" do
|
156
156
|
setup do
|
157
157
|
@sf = VirtualBox::SharedFolder.new({:name => "foo", :hostpath => "bar"})
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
should "allow the use of :name and :hostpath in the hash" do
|
161
161
|
assert_equal "foo", @sf.name
|
162
162
|
assert_equal "bar", @sf.hostpath
|
163
163
|
end
|
164
|
-
|
164
|
+
|
165
165
|
should "keep the record new" do
|
166
166
|
assert @sf.new_record?
|
167
167
|
end
|
168
168
|
end
|
169
169
|
end
|
170
|
-
|
170
|
+
|
171
171
|
context "destroying" do
|
172
172
|
setup do
|
173
173
|
@value = VirtualBox::SharedFolder.populate_relationship(@caller, @data)
|
174
174
|
@value = @value[0]
|
175
175
|
end
|
176
|
-
|
176
|
+
|
177
177
|
should "call the proper command" do
|
178
178
|
VirtualBox::Command.expects(:vboxmanage).with("sharedfolder remove #{@caller.name} --name #{@value.name}").once
|
179
179
|
assert @value.destroy
|
180
180
|
end
|
181
|
-
|
181
|
+
|
182
182
|
should "shell escape VM name and storage controller name" do
|
183
183
|
shell_seq = sequence("shell_seq")
|
184
184
|
VirtualBox::Command.expects(:shell_escape).with(@caller.name).in_sequence(shell_seq)
|
@@ -186,20 +186,20 @@ class SharedFolderTest < Test::Unit::TestCase
|
|
186
186
|
VirtualBox::Command.expects(:vboxmanage).in_sequence(shell_seq)
|
187
187
|
assert @value.destroy
|
188
188
|
end
|
189
|
-
|
189
|
+
|
190
190
|
should "return false if destroy failed" do
|
191
191
|
VirtualBox::Command.stubs(:vboxmanage).raises(VirtualBox::Exceptions::CommandFailedException)
|
192
192
|
assert !@value.destroy
|
193
193
|
end
|
194
|
-
|
194
|
+
|
195
195
|
should "raise an exception if destroy failed and an error occured" do
|
196
196
|
VirtualBox::Command.stubs(:vboxmanage).raises(VirtualBox::Exceptions::CommandFailedException)
|
197
197
|
assert_raises(VirtualBox::Exceptions::CommandFailedException) {
|
198
198
|
@value.destroy(true)
|
199
199
|
}
|
200
200
|
end
|
201
|
-
|
202
|
-
should "use the old name if it was changed" do
|
201
|
+
|
202
|
+
should "use the old name if it was changed" do
|
203
203
|
@value.name = "DIFFERENT"
|
204
204
|
shell_seq = sequence("shell_seq")
|
205
205
|
VirtualBox::Command.expects(:shell_escape).with(@caller.name).in_sequence(shell_seq)
|
@@ -208,12 +208,12 @@ class SharedFolderTest < Test::Unit::TestCase
|
|
208
208
|
assert @value.destroy
|
209
209
|
end
|
210
210
|
end
|
211
|
-
|
211
|
+
|
212
212
|
context "populating relationships" do
|
213
213
|
setup do
|
214
214
|
@value = VirtualBox::SharedFolder.populate_relationship(@caller, @data)
|
215
215
|
end
|
216
|
-
|
216
|
+
|
217
217
|
should "be a 'collection'" do
|
218
218
|
assert @value.is_a?(VirtualBox::Proxies::Collection)
|
219
219
|
end
|
@@ -221,12 +221,12 @@ class SharedFolderTest < Test::Unit::TestCase
|
|
221
221
|
should "create the correct amount of objects" do
|
222
222
|
assert_equal 2, @value.length
|
223
223
|
end
|
224
|
-
|
224
|
+
|
225
225
|
should "parse the proper data" do
|
226
226
|
value = @value[0]
|
227
227
|
assert_equal "foofolder", value.name
|
228
228
|
assert_equal "/foo", value.hostpath
|
229
|
-
|
229
|
+
|
230
230
|
value = @value[1]
|
231
231
|
assert_equal "barfolder", value.name
|
232
232
|
assert_equal "/bar", value.hostpath
|
@@ -11,77 +11,77 @@ class StorageControllerTest < Test::Unit::TestCase
|
|
11
11
|
:"foo-1-0" => "again",
|
12
12
|
:"bar-0-0" => "rawr"
|
13
13
|
}
|
14
|
-
|
14
|
+
|
15
15
|
@caller = mock("caller")
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
context "saving" do
|
19
19
|
setup do
|
20
20
|
@value = VirtualBox::StorageController.populate_relationship(@caller, @data)
|
21
21
|
@value = @value[0]
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
should "save relationship" do
|
25
25
|
VirtualBox::AttachedDevice.expects(:save_relationship).once
|
26
26
|
@value.save
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
context "destroying" do
|
31
31
|
setup do
|
32
32
|
@value = VirtualBox::StorageController.populate_relationship(@caller, @data)
|
33
33
|
@value = @value[0]
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
should "simply call destroy on each object when destroying the relationship" do
|
37
37
|
obj_one = mock("one")
|
38
38
|
obj_two = mock("two")
|
39
|
-
|
39
|
+
|
40
40
|
obj_one.expects(:destroy).with("HELLO").once
|
41
41
|
obj_two.expects(:destroy).with("HELLO").once
|
42
|
-
|
42
|
+
|
43
43
|
VirtualBox::StorageController.destroy_relationship(self, [obj_one, obj_two], "HELLO")
|
44
44
|
end
|
45
45
|
|
46
46
|
should "call destroy_relationship on AttachedDevices when destroyed" do
|
47
47
|
assert !@value.devices.empty?
|
48
|
-
|
48
|
+
|
49
49
|
VirtualBox::AttachedDevice.expects(:destroy_relationship).once
|
50
50
|
@value.destroy
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
context "populating relationships" do
|
55
55
|
should "create the correct amount of objects" do
|
56
56
|
value = VirtualBox::StorageController.populate_relationship(@caller, @data)
|
57
57
|
assert_equal 2, value.length
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
should "use populate keys when extracting keys" do
|
61
61
|
value = VirtualBox::StorageController.new(0, @caller, @data)
|
62
62
|
assert_equal "foo", value.name
|
63
63
|
assert_equal 7, value.max_ports
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
should "call populate attributes with the merged populate data" do
|
67
67
|
VirtualBox::StorageController.any_instance.expects(:extract_devices).returns({ :name => "BAR" })
|
68
68
|
value = VirtualBox::StorageController.new(0, @caller, @data)
|
69
69
|
assert_equal "BAR", value.name
|
70
70
|
end
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
context "extracting related device info" do
|
74
74
|
setup do
|
75
75
|
@controller = VirtualBox::StorageController.new(0, @caller, @data)
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
should "extract only those keys related to current controller name" do
|
79
79
|
data = @controller.extract_devices(0, @data)
|
80
80
|
assert data
|
81
81
|
assert data.has_key?(:"foo-0-0")
|
82
82
|
assert data.has_key?(:"foo-1-0")
|
83
83
|
assert !data.has_key?(:"bar-0-0")
|
84
|
-
|
84
|
+
|
85
85
|
data = @controller.extract_devices(1, @data)
|
86
86
|
assert data
|
87
87
|
assert !data.has_key?(:"foo-0-0")
|