test/virtualbox/vm_test.rb in virtualbox-0.8.6 vs test/virtualbox/vm_test.rb in virtualbox-0.9.0

- old
+ new

@@ -18,38 +18,32 @@ end end context "finding a VM" do setup do - @all = [] - @klass.stubs(:all).returns(@all) + @lib = mock("lib") + @virtualbox = mock("virtualbox") + VirtualBox::Lib.stubs(:lib).returns(@lib) + @lib.stubs(:virtualbox).returns(@virtualbox) end def mock_vm(uuid, name=nil) vm = mock("vm-#{uuid}") vm.stubs(:uuid).returns(uuid) vm.stubs(:name).returns(name) vm end should "return nil if it doesn't exist" do - @all << mock_vm("foo") + @virtualbox.expects(:find_machine).raises(VirtualBox::Exceptions::ObjectNotFoundException) assert_nil @klass.find("bar") end should "return the matching vm if it is found" do - vm = mock_vm("foo") - @all << mock_vm("bar") - @all << vm - assert_equal vm, @klass.find("foo") + @virtualbox.expects(:find_machine).returns(mock_vm("foo")) + assert !@klass.find("foo").nil? end - - should "return if matching name is found" do - vm = mock_vm(nil, "foo") - @all << vm - assert_equal vm, @klass.find("foo") - end end context "importing" do setup do @path = "foo.rb" @@ -147,16 +141,16 @@ setup do @klass.any_instance.stubs(:load_interface_attributes) @klass.any_instance.stubs(:populate_relationships) end - should "load interface attribtues" do - @klass.any_instance.expects(:load_interface_attributes).with(@interface).once + should "not load interface attribtues" do + @klass.any_instance.expects(:load_interface_attributes).with(@interface).never @klass.new(@interface) end - should "populate relationships" do - @klass.any_instance.expects(:populate_relationships).with(@interface).once + should "not populate relationships" do + @klass.any_instance.expects(:populate_relationships).with(@interface).never @klass.new(@interface) end should "not be dirty" do @instance = @klass.new(@interface)