Sha256: 1b93a0e615d8acacf50db5946b58937c5ba1a4dc27aa809a6a32ad80913653d1

Contents?: true

Size: 1.16 KB

Versions: 10

Compression:

Stored size: 1.16 KB

Contents

require 'gir_ffi_test_helper'

GirFFI.setup :Regress

# Tests deriving Ruby classes from GObject classes.
describe 'For derived classes' do
  describe 'setting up methods when first called' do
    before do
      save_module :GIMarshallingTests
      GirFFI.setup :GIMarshallingTests
    end

    describe 'when an interface is mixed in' do
      before do
        @klass = Class.new GIMarshallingTests::OverridesObject
        @klass.send :include, GIMarshallingTests::Interface
      end

      it 'finds class methods in the superclass' do
        @klass.returnv
      end

      it 'finds instance methods in the superclass' do
        obj = @klass.new
        result = obj.method
        result.must_equal 42
      end
    end

    after do
      restore_module :GIMarshallingTests
    end
  end

  describe 'the initializer' do
    it 'works if it calls super' do
      klass = Class.new Regress::TestSubObj do
        attr_reader :animal
        def initialize(animal)
          super()
          @animal = animal
        end
      end

      obj = klass.new 'dog'
      obj.must_be_instance_of klass
      obj.to_ptr.wont_be_nil
      obj.animal.must_equal 'dog'
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gir_ffi-0.9.2 test/integration/derived_classes_test.rb
gir_ffi-0.9.1 test/integration/derived_classes_test.rb
gir_ffi-0.9.0 test/integration/derived_classes_test.rb
gir_ffi-0.8.6 test/integration/derived_classes_test.rb
gir_ffi-0.8.5 test/integration/derived_classes_test.rb
gir_ffi-0.8.4 test/integration/derived_classes_test.rb
gir_ffi-0.8.3 test/integration/derived_classes_test.rb
gir_ffi-0.8.2 test/integration/derived_classes_test.rb
gir_ffi-0.8.1 test/integration/derived_classes_test.rb
gir_ffi-0.8.0 test/integration/derived_classes_test.rb