Sha256: 267de622b4ed9c76299ed91d53a4e085dc73691903e9ebe6f0d5a73b0278f13e
Contents?: true
Size: 1.84 KB
Versions: 1
Compression:
Stored size: 1.84 KB
Contents
require 'spec_helper' describe Libvirt::Ruby do let(:libvirt) { Libvirt::Ruby } context "when calling any libvirt function directly" do context "without a return type specified" do it "should raise an error" do lambda { libvirt.virConnectClose }.should raise_error(Libvirt::Ruby::Exceptions::NoReturnParameter) end end context "with libvirt installed" do before :each do libvirt.stub(:ffi_lib).with("libvirt") end context "and the function is a valid one" do before :each do libvirt.stub(:attach_function).with("virConnectClose", "virConnectClose", [], :int).and_return(true) libvirt.stub(:send).with("virConnectClose", []) end after :each do libvirt.virConnectClose([:int]) end it "should attach it as a binding for C's function" do libvirt.should_receive(:attach_function).with("virConnectClose", "virConnectClose", [], :int).and_return(true) end end context "and the function is not a valid one" do before :each do libvirt.stub(:attach_function).with("virConnectAbc", "virConnectAbc", [], :int).and_raise(FFI::NotFoundError.new('Abc', 'libvirt')) end it "should raise an exception" do lambda { libvirt.virConnectAbc([:int]) }.should raise_error(Libvirt::Ruby::Exceptions::InvalidFunction) end end end context "without libvirt installed" do it "should raise an exception" do lambda { libvirt.virConnectAbc([:int]) }.should raise_error(Libvirt::Ruby::Exceptions::MissingLib) end end end context "when calling method #dispatcher directly" do it "should raise an exception" do lambda { libvirt.dispatcher('virConnectClose', [], :int) }.should raise_error(Libvirt::Ruby::Exceptions::WrongCall) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
libvirt-ruby-1.0.2 | spec/libvirt-ruby_spec.rb |