Sha256: 4773276d73afb439db255dd296f6d8604b5559a475211eb90b02790b791f81df

Contents?: true

Size: 1.75 KB

Versions: 3

Compression:

Stored size: 1.75 KB

Contents

require File.expand_path('../test_helper.rb', File.dirname(__FILE__))

describe "loading the shared library" do
  before do
    # Avoid cluttering the error stream with method redefinition warnings.
    stub(GObjectIntrospection::Lib).attach_function { }
  end

  describe "with ABI version 0 installed" do
    before do
      stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0.so.1") { raise LoadError }
      stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0.so.0") { }
      stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0") { raise "not expected" }
    end

    it "prints a warning message" do
      _, err = capture_io do
        load 'ffi-gobject_introspection/lib.rb'
      end

      assert_match(/not supported/, err)
    end
  end

  describe "with ABI version 1 installed" do
    before do
      stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0.so.0") { raise LoadError }
      stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0.so.1") { }
      stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0") { raise "not expected" }
    end

    it "does not print a warning message" do
      _, err = capture_io do
        load 'ffi-gobject_introspection/lib.rb'
      end

      assert_equal "", err
    end
  end

  describe "without being able to determine the ABI version" do
    before do
      stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0.so.0") { raise LoadError }
      stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0.so.1") { raise LoadError }
      stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0") { }
    end

    it "prints a warning message" do
      _, err = capture_io do
        load 'ffi-gobject_introspection/lib.rb'
      end

      assert_match(/not supported/, err)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-0.2.2 test/ffi-gobject_introspection/lib_test.rb
gir_ffi-0.2.1 test/ffi-gobject_introspection/lib_test.rb
gir_ffi-0.2.0 test/ffi-gobject_introspection/lib_test.rb