Kaspar Schiess avatar Kaspar Schiess committed 68506c9

Fixes missing require and constant lookup problems

and adds a spec for this

Comments (0)

Files changed (2)

lib/qemu-toolkit/vm.rb

 require 'qemu-toolkit/iscsi_target'
 
 require 'fileutils'
+require 'socket'
 
 module QemuToolkit
   # Abstracts a virtual machine on a vm host. This class provides all sorts
     
   private 
     def monitor_cmd(cmd)
-      socket = UNIXSocket.new(monitor_path)
+      socket = ::UNIXSocket.new(monitor_path)
       socket.puts cmd
       socket.close
     end

spec/lib/qemu-toolkit/vm_spec.rb

       vm.shutdown
     end 
   end
+
+  describe '#monitor_cmd' do
+    let(:path) { '/tmp/sock' }
+    before(:each) { flexmock(vm, :monitor_path => path) }
+    
+    it "sends the command through the socket" do
+      UNIXServer.open(path) do |serv|
+        vm.send :monitor_cmd, 'foobar'
+        conn = serv.accept
+        conn.gets.should == "foobar\n"
+        conn.close
+      end
+    end 
+  end
 end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.