Sha256: 843568cfc0e78b5593f6673b75ffd27cc44c1f3d1f9ead94ceb5d0c1c304e505

Contents?: true

Size: 1.13 KB

Versions: 8

Compression:

Stored size: 1.13 KB

Contents

require File.dirname(__FILE__) + "/spec_helper"

describe YARD::Handlers::C::AttributeHandler do
  def run(read, write, commented = nil)
    parse <<-eof
      /* FOO */
      VALUE foo(VALUE x) { int value = x; }
      void Init_Foo() {
        rb_cFoo = rb_define_class("Foo", rb_cObject);
        #{commented ? '/*' : ''}
          rb_define_attr(rb_cFoo, "foo", #{read}, #{write});
        #{commented ? '*/' : ''}
      }
    eof
  end

  it "handles readonly attribute (rb_define_attr)" do
    run(1, 0)
    expect(Registry.at('Foo#foo')).to be_reader
    expect(Registry.at('Foo#foo=')).to be nil
  end

  it "handles writeonly attribute (rb_define_attr)" do
    run(0, 1)
    expect(Registry.at('Foo#foo')).to be nil
    expect(Registry.at('Foo#foo=')).to be_writer
  end

  it "handles readwrite attribute (rb_define_attr)" do
    run(1, 1)
    expect(Registry.at('Foo#foo')).to be_reader
    expect(Registry.at('Foo#foo=')).to be_writer
  end

  it "handles commented writeonly attribute (/* rb_define_attr */)" do
    run(1, 1, true)
    expect(Registry.at('Foo#foo')).to be_reader
    expect(Registry.at('Foo#foo=')).to be_writer
  end
end

Version data entries

8 entries across 7 versions & 2 rubygems

Version Path
abaci-0.3.0 vendor/bundle/gems/yard-0.9.2/spec/handlers/c/attribute_handler_spec.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.1/spec/handlers/c/attribute_handler_spec.rb
yard-0.9.5 spec/handlers/c/attribute_handler_spec.rb
yard-0.9.4 spec/handlers/c/attribute_handler_spec.rb
yard-0.9.3 spec/handlers/c/attribute_handler_spec.rb
yard-0.9.2 spec/handlers/c/attribute_handler_spec.rb
yard-0.9.1 spec/handlers/c/attribute_handler_spec.rb
yard-0.9.0 spec/handlers/c/attribute_handler_spec.rb