Sha256: 69255f48e371d150d793be653b84538ae4f939845c7ca7538d6b2d9812d1e085

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require 'gir_ffi_test_helper'

require 'ffi-gobject'

describe GObject::Object do
  describe "#get_property" do
    it "is overridden to have arity 1" do
      assert_equal 1,
        GObject::Object.instance_method("get_property").arity
    end
  end

  describe "automatic accessor methods" do
    class AccessorTest < GObject::Object
      def get_x
        @x
      end
      def set_x(val)
        @x = val
      end
    end

    subject { AccessorTest.new GObject::TYPE_OBJECT, nil }

    it 'reads x by calling get_x' do
      subject.set_x(1)
      assert_equal 1, subject.x
    end

    it 'writes x by calling set_x' do
      subject.x = 2
      assert_equal 2, subject.x
    end
  end

  describe "#signal_connect" do
    subject { GObject::Object.new GObject::TYPE_OBJECT, nil }

    it 'delegates to GObject' do
      mock(GObject).signal_connect(subject, 'some-event', nil)
      subject.signal_connect('some-event') do
        nothing
      end

      RR.verify
    end

    it 'delegates to GObject if an optional data argument is passed' do
      mock(GObject).signal_connect(subject, 'some-event', 'data')
      subject.signal_connect('some-event', 'data') do
        nothing
      end

      RR.verify
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gir_ffi-0.7.7 test/ffi-gobject/object_test.rb
gir_ffi-0.7.6 test/ffi-gobject/object_test.rb