Sha256: 6831aa43cdd46f86ae82d66185f717342069726f8d53657ffddc0c3e22e49e07

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

require 'gir_ffi_test_helper'

describe GirFFI::InfoExt::IFieldInfo do
  let(:klass) do
    Class.new do
      include GirFFI::InfoExt::IFieldInfo
    end
  end
  let(:field_info) { klass.new }
  describe '#layout_specification' do
    it 'returns an array of name, typespec and offset' do
      expect(type = Object.new).to receive(:to_ffi_type).and_return :bar

      expect(field_info).to receive(:name).and_return 'foo'
      expect(field_info).to receive(:field_type).and_return type
      expect(field_info).to receive(:offset).and_return 0

      result = field_info.layout_specification

      assert_equal [:foo, :bar, 0], result
    end

    it 'keeps a complex typespec intact' do
      expect(type = Object.new).to receive(:to_ffi_type).and_return [:bar, 2]

      expect(field_info).to receive(:name).and_return 'foo'
      expect(field_info).to receive(:field_type).and_return type
      expect(field_info).to receive(:offset).and_return 0

      result = field_info.layout_specification

      assert_equal [:foo, [:bar, 2], 0], result
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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