virtualbox 0.5.1 → 0.5.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
@@ -1,4 +1,8 @@
1
1
  module VirtualBox
2
+ def self.version
3
+ Command.version
4
+ end
5
+
2
6
  # Used by the rest of the virtualbox library to call shell commands.
3
7
  # It also can be used to change the path for your VBoxManage program.
4
8
  #
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
- # First save all the changed attributes in a single batch
333
- saves = changes.inject([]) do |acc, kv|
334
- key, values = kv
335
- acc << ["--#{key}", values[1]]
336
- end
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
- # Flatten to pass into vboxmanage
339
- saves.flatten!
339
+ # Flatten to pass into vboxmanage
340
+ saves.flatten!
340
341
 
341
- # Save all the attributes in one command
342
- Command.vboxmanage("modifyvm", @original_name, *saves)
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
@@ -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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{virtualbox}
8
- s.version = "0.5.1"
8
+ s.version = "0.5.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mitchell Hashimoto"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 1
9
- version: 0.5.1
8
+ - 2
9
+ version: 0.5.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mitchell Hashimoto