Sha256: 53c87f9e318d6b15ce89685eb63aac698e311e795abc58581491cad2252b32b3

Contents?: true

Size: 1.36 KB

Versions: 4

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

require "gir_ffi_test_helper"

describe GirFFI::Builders::ModuleBuilder do
  let(:gir) { GObjectIntrospection::IRepository.default }

  describe "#find_namespaced_class_info" do
    it "finds the info in the GIR" do
      allow(gir).to receive(:require).with("Foo", nil)

      builder = GirFFI::Builders::ModuleBuilder.new "Foo"

      expect(gir).to receive(:find_by_name).with("Foo", "Bar").and_return "gir info"

      _(builder.find_namespaced_class_info(:Bar)).must_equal "gir info"
    end

    it "checks downcased class name as an alternative" do
      allow(gir).to receive(:require).with("Foo", nil)

      builder = GirFFI::Builders::ModuleBuilder.new "Foo"

      expect(gir).to receive(:find_by_name).with("Foo", "Bar").and_return nil
      expect(gir).to receive(:find_by_name).with("Foo", "bar").and_return "gir info"

      _(builder.find_namespaced_class_info(:Bar)).must_equal "gir info"
    end

    it "raises a clear error if the named class does not exist" do
      allow(gir).to receive(:require).with("Foo", nil)

      builder = GirFFI::Builders::ModuleBuilder.new "Foo"

      expect(gir).to receive(:find_by_name).with("Foo", "Bar").and_return nil
      expect(gir).to receive(:find_by_name).with("Foo", "bar").and_return nil

      assert_raises NameError do
        builder.find_namespaced_class_info :Bar
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gir_ffi-0.15.3 test/gir_ffi/builders/module_builder_test.rb
gir_ffi-0.15.2 test/gir_ffi/builders/module_builder_test.rb
gir_ffi-0.15.1 test/gir_ffi/builders/module_builder_test.rb
gir_ffi-0.15.0 test/gir_ffi/builders/module_builder_test.rb