spec/libvirt-ruby_spec.rb in libvirt-ruby-1.0.2 vs spec/libvirt-ruby_spec.rb in libvirt-ruby-2.0.0
- old
+ new
@@ -1,14 +1,14 @@
require 'spec_helper'
-describe Libvirt::Ruby do
- let(:libvirt) { Libvirt::Ruby }
+describe Libvirt::Base do
+ let(:libvirt) { Libvirt::Base.new }
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)
+ lambda { libvirt.virConnectClose }.should raise_error(Libvirt::Exceptions::NoReturnParameter)
end
end
context "with libvirt installed" do
before :each do
@@ -34,23 +34,28 @@
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)
+ lambda { libvirt.virConnectAbc([:int]) }.should raise_error(Libvirt::Exceptions::InvalidFunction)
end
end
end
context "without libvirt installed" do
+ before :each do
+ libvirt.stub(:attach_function).with("virConnectAbc", "virConnectAbc", [], :int)
+ libvirt.stub(:ffi_lib).and_raise(LoadError)
+ end
+
it "should raise an exception" do
- lambda { libvirt.virConnectAbc([:int]) }.should raise_error(Libvirt::Ruby::Exceptions::MissingLib)
+ lambda { libvirt.virConnectAbc([:int]) }.should raise_error(Libvirt::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)
+ lambda { libvirt.send('dispatcher', 'virConnectClose', [], :int) }.should raise_error(Libvirt::Exceptions::WrongCall)
end
end
end
\ No newline at end of file