Sha256: be30b721baccf1ed330037d824d3f33ccad7fa9336437c154fe14c0974a3b0f8

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

describe Libvirt::Ruby::Connect do
  let(:connect) { Libvirt::Ruby::Connect }
  let(:p) { Object }

  context "#open" do
    before :each do
      connect.stub(:virConnectOpen).with(:string, :pointer).and_return(true)
      connect.stub(:virConnectOpen).with("uri").and_return(p)
    end

    after :each do
      connect.open("uri")
    end

    context "when virConnectOpen is not attached yet" do
      it "should attach it" do
        connect.should_receive(:virConnectOpen).with(:string, :pointer)
      end
    end

    context "when virConnectOpen is already attached" do
      before :each do
        connect.stub(:respond_to_missing?).with(:virConnectOpen, false).and_return(true)
      end

      it "should not try to attach it again" do
        connect.should_not_receive(:virConnectOpen).with(:string, :pointer)
      end
    end

    it "should call virConnectOpen" do
      connect.should_receive(:virConnectOpen)
    end

    it "should return the pointer to the new connection" do
      connect.open("uri").should == p
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
libvirt-ruby-mapping-0.1.0 spec/libvirt-ruby-mapping/connect/open_spec.rb