Sha256: 77bc9747aa70b53277a99dc2729836225be515f6519e04613cfc5f2a64fb3dbd

Contents?: true

Size: 1.12 KB

Versions: 68

Compression:

Stored size: 1.12 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 "should handle readonly attribute (rb_define_attr)" do
    run(1, 0)
    Registry.at('Foo#foo').should be_reader
    Registry.at('Foo#foo=').should be_nil
  end

  it "should handle writeonly attribute (rb_define_attr)" do
    run(0, 1)
    Registry.at('Foo#foo').should be_nil
    Registry.at('Foo#foo=').should be_writer
  end

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

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

Version data entries

68 entries across 52 versions & 7 rubygems

Version Path
yard-0.8.7.6 spec/handlers/c/attribute_handler_spec.rb
yard-0.8.7.5 spec/handlers/c/attribute_handler_spec.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/attribute_handler_spec.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/yard-0.8.7.3/spec/handlers/c/attribute_handler_spec.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/attribute_handler_spec.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/attribute_handler_spec.rb
yard-0.8.7.4 spec/handlers/c/attribute_handler_spec.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/attribute_handler_spec.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/attribute_handler_spec.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/yard-0.8.7.3/spec/handlers/c/attribute_handler_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/attribute_handler_spec.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/attribute_handler_spec.rb
climine-0.0.2 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/attribute_handler_spec.rb
climine-0.0.1 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/attribute_handler_spec.rb
yard-0.8.7.3 spec/handlers/c/attribute_handler_spec.rb
yard-0.8.7.2 spec/handlers/c/attribute_handler_spec.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/yard-0.8.7/spec/handlers/c/attribute_handler_spec.rb
candlepin-api-0.4.0 bundle/ruby/gems/yard-0.8.7/spec/handlers/c/attribute_handler_spec.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/yard-0.8.7/spec/handlers/c/attribute_handler_spec.rb
yard-0.8.7.1 spec/handlers/c/attribute_handler_spec.rb