Sha256: 096848884d72ded6b79bbc73fc231609825daec35c3830adb03b5c203e34f82a

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

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

describe GirFFI::Builder::Type::Object do
  before do
    GirFFI.setup :Regress
  end

  describe "#setup_method" do
    it "sets up singleton methods defined in a class's parent" do
      info = get_introspection_data 'Regress', 'TestSubObj'
      assert_nil info.find_method "static_method"
      parent = info.parent
      assert_not_nil parent.find_method "static_method"

      b = GirFFI::Builder::Type::Object.new(info)
      b.setup_method "static_method"
      pass
    end
  end

  describe "#find_property" do
    it "finds a property specified on the class itself" do
      builder = GirFFI::Builder::Type::Object.new(
        get_introspection_data('Regress', 'TestObj'))
      prop = builder.find_property("int")
      assert_equal "int", prop.name
    end

    it "finds a property specified on the parent class" do
      builder = GirFFI::Builder::Type::Object.new(
        get_introspection_data('Regress', 'TestSubObj'))
      prop = builder.find_property("int")
      assert_equal "int", prop.name
    end

    it "raises an error if the property is not found" do
      builder = GirFFI::Builder::Type::Object.new(
        get_introspection_data('Regress', 'TestSubObj'))
      assert_raises RuntimeError do
        builder.find_property("this-property-does-not-exist")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-0.2.2 test/unit/object_type_builder_test.rb
gir_ffi-0.2.1 test/unit/object_type_builder_test.rb
gir_ffi-0.2.0 test/unit/object_type_builder_test.rb