virtualbox 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/virtualbox/command.rb +4 -0
- data/lib/virtualbox/vm.rb +15 -12
- data/test/virtualbox/command_test.rb +6 -1
- data/test/virtualbox/vm_test.rb +6 -0
- data/virtualbox.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.2
|
data/lib/virtualbox/command.rb
CHANGED
data/lib/virtualbox/vm.rb
CHANGED
@@ -329,21 +329,24 @@ module VirtualBox
|
|
329
329
|
# attributes of the virtual machine. If any related attributes were saved
|
330
330
|
# as well (such as storage controllers), those will be saved, too.
|
331
331
|
def save(raise_errors=false)
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
332
|
+
if changed?
|
333
|
+
# First save all the changed attributes in a single batch
|
334
|
+
saves = changes.inject([]) do |acc, kv|
|
335
|
+
key, values = kv
|
336
|
+
acc << ["--#{key}", values[1]]
|
337
|
+
end
|
337
338
|
|
338
|
-
|
339
|
-
|
339
|
+
# Flatten to pass into vboxmanage
|
340
|
+
saves.flatten!
|
340
341
|
|
341
|
-
|
342
|
-
|
342
|
+
# Save all the attributes in one command
|
343
|
+
Command.vboxmanage("modifyvm", @original_name, *saves)
|
344
|
+
|
345
|
+
# Now clear attributes and call super so relationships are saved
|
346
|
+
@original_name = name
|
347
|
+
clear_dirty!
|
348
|
+
end
|
343
349
|
|
344
|
-
# Now clear attributes and call super so relationships are saved
|
345
|
-
@original_name = name
|
346
|
-
clear_dirty!
|
347
350
|
super()
|
348
351
|
|
349
352
|
# Force reload
|
@@ -3,10 +3,15 @@ require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
|
3
3
|
class CommandTest < Test::Unit::TestCase
|
4
4
|
context "getting the version" do
|
5
5
|
setup do
|
6
|
-
VirtualBox::Command.stubs(:execute)
|
6
|
+
VirtualBox::Command.stubs(:execute).returns("foo")
|
7
7
|
VirtualBox::Command.stubs(:success?).returns(true)
|
8
8
|
end
|
9
9
|
|
10
|
+
should "be able to call version on VirtualBox and it calls the class method" do
|
11
|
+
version = "foo"
|
12
|
+
assert_equal version, VirtualBox.version
|
13
|
+
end
|
14
|
+
|
10
15
|
should "run the command with the version flag" do
|
11
16
|
VirtualBox::Command.expects(:execute).with("VBoxManage --version").once.returns("7")
|
12
17
|
VirtualBox::Command.version
|
data/test/virtualbox/vm_test.rb
CHANGED
@@ -318,6 +318,12 @@ raw
|
|
318
318
|
assert @vm.save
|
319
319
|
end
|
320
320
|
|
321
|
+
should "do nothing if no attributes changed" do
|
322
|
+
VirtualBox::Command.expects(:vboxmanage).never
|
323
|
+
assert !@vm.changed?
|
324
|
+
assert @vm.save
|
325
|
+
end
|
326
|
+
|
321
327
|
should "save name first if changed, then following values should modify new VM" do
|
322
328
|
new_name = "foo2"
|
323
329
|
VirtualBox::Command.expects(:vboxmanage).with("modifyvm", @name, "--ostype", "Zubuntu", "--name", new_name)
|
data/virtualbox.gemspec
CHANGED