Loading spec/aggregator_cfgs_and_properties_spec.rb 0 → 100644 +179 −0 Original line number Diff line number Diff line require "jsduck/aggregator" describe JsDuck::Aggregator do def parse(string) agr = JsDuck::Aggregator.new agr.parse(string) agr.result end shared_examples_for "cfg" do it "creates cfg" do @doc[:tagname].should == :cfg end end shared_examples_for "property" do it "creates property" do @doc[:tagname].should == :property end end shared_examples_for "cfg or property" do it "takes documentation from doc-comment" do @doc[:doc].should == "Some documentation." end it "detects name" do @doc[:name].should == "foo" end end shared_examples_for "cfg or property default type" do it "default type is Object" do @doc[:type].should == "Object" end end shared_examples_for "cfg or property String type" do it "detects type" do @doc[:type].should == "String" end end describe "explicit @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg {String} foo * Some documentation. */ EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "explicit @property" do before do @doc = parse(<<-EOS)[0] /** * @property {String} foo * Some documentation. */ EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "implicit @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg * Some documentation. */ foo: "asdf" EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "implicit @property" do before do @doc = parse(<<-EOS)[0] /** * Some documentation. */ foo: "asdf" EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "typeless @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg * Some documentation. */ foo: func(), EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property default type" end describe "typeless @property" do before do @doc = parse(<<-EOS)[0] /** * @property * Some documentation. */ foo: func(), EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property default type" end describe "@property with @type" do before do @doc = parse(<<-EOS)[0] /** * @property foo * @type String * Some documentation. */ EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "@type without @property" do before do @doc = parse(<<-EOS)[0] /** * @type String * Some documentation. */ MY_CONSTANT: true, EOS end it_should_behave_like "property" it_should_behave_like "cfg or property String type" it "detects name" do @doc[:name].should == "MY_CONSTANT" end end describe "@property with 'this' in ident chain" do before do @doc = parse(<<-EOS)[0] /** * @property * Some documentation. */ this.foo = ""; EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end end spec/aggregator_classes_spec.rb 0 → 100644 +81 −0 Original line number Diff line number Diff line require "jsduck/aggregator" describe JsDuck::Aggregator do def parse(string) agr = JsDuck::Aggregator.new agr.parse(string) agr.result end describe "one class many times" do before do @classes = parse(<<-EOS) /** * @class Foo * @cfg c1 */ /** @method fun1 */ /** @event eve1 */ /** @property prop1 */ /** * @class Foo * @extends Bar * Second description. * @xtype xfoo * @private * @cfg c2 */ /** @method fun2 */ /** @event eve3 */ /** @property prop2 */ /** * @class Foo * @extends Bazaar * @singleton * Third description. * @xtype xxxfoo * @cfg c3 */ /** @method fun3 */ /** @event eve3 */ /** @property prop3 */ EOS end it "results in only one class" do @classes.length.should == 1 end it "takes class doc from first doc-block that has one" do @classes[0][:doc].should == "Second description." end it "takes @extends from first doc-block that has one" do @classes[0][:extends].should == "Bar" end it "takes @xtype from first doc-block that has one" do @classes[0][:xtype].should == "xfoo" end it "is singleton when one doc-block is singleton" do @classes[0][:singleton].should == true end it "is private when one doc-block is private" do @classes[0][:private].should == true end it "combines all configs" do @classes[0][:cfg].length.should == 3 end it "combines all methods, events, properties" do @classes[0][:method].length.should == 3 @classes[0][:event].length.should == 3 @classes[0][:property].length.should == 3 end end end spec/aggregator_members_spec.rb 0 → 100644 +54 −0 Original line number Diff line number Diff line require "jsduck/aggregator" describe JsDuck::Aggregator do def parse(string) agr = JsDuck::Aggregator.new agr.parse(string) agr.result end describe "@member" do it "defines the class where item belongs" do items = parse(<<-EOS) /** * @cfg foo * @member Bar */ EOS items[0][:member].should == "Bar" end it "forces item to be moved into that class" do items = parse(<<-EOS) /** * @class Bar */ /** * @class Baz */ /** * @cfg foo * @member Bar */ EOS items[0][:cfg].length.should == 1 items[1][:cfg].length.should == 0 end it "even when @member comes before the class itself" do items = parse(<<-EOS) /** * @cfg foo * @member Bar */ /** * @class Bar */ EOS items[0][:cfg].length.should == 1 end end end spec/aggregator_spec.rb→spec/aggregator_methods_and_events_spec.rb +0 −281 Original line number Diff line number Diff line Loading @@ -343,285 +343,4 @@ describe JsDuck::Aggregator do it_should_behave_like "no parameters" end shared_examples_for "cfg" do it "creates cfg" do @doc[:tagname].should == :cfg end end shared_examples_for "property" do it "creates property" do @doc[:tagname].should == :property end end shared_examples_for "cfg or property" do it "takes documentation from doc-comment" do @doc[:doc].should == "Some documentation." end it "detects name" do @doc[:name].should == "foo" end end shared_examples_for "cfg or property default type" do it "default type is Object" do @doc[:type].should == "Object" end end shared_examples_for "cfg or property String type" do it "detects type" do @doc[:type].should == "String" end end describe "explicit @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg {String} foo * Some documentation. */ EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "explicit @property" do before do @doc = parse(<<-EOS)[0] /** * @property {String} foo * Some documentation. */ EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "implicit @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg * Some documentation. */ foo: "asdf" EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "implicit @property" do before do @doc = parse(<<-EOS)[0] /** * Some documentation. */ foo: "asdf" EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "typeless @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg * Some documentation. */ foo: func(), EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property default type" end describe "typeless @property" do before do @doc = parse(<<-EOS)[0] /** * @property * Some documentation. */ foo: func(), EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property default type" end describe "@property with @type" do before do @doc = parse(<<-EOS)[0] /** * @property foo * @type String * Some documentation. */ EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "@type without @property" do before do @doc = parse(<<-EOS)[0] /** * @type String * Some documentation. */ MY_CONSTANT: true, EOS end it_should_behave_like "property" it_should_behave_like "cfg or property String type" it "detects name" do @doc[:name].should == "MY_CONSTANT" end end describe "@property with 'this' in ident chain" do before do @doc = parse(<<-EOS)[0] /** * @property * Some documentation. */ this.foo = ""; EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "@member" do it "defines the class where item belongs" do items = parse(<<-EOS) /** * @cfg foo * @member Bar */ EOS items[0][:member].should == "Bar" end it "forces item to be moved into that class" do items = parse(<<-EOS) /** * @class Bar */ /** * @class Baz */ /** * @cfg foo * @member Bar */ EOS items[0][:cfg].length.should == 1 items[1][:cfg].length.should == 0 end it "even when @member comes before the class itself" do items = parse(<<-EOS) /** * @cfg foo * @member Bar */ /** * @class Bar */ EOS items[0][:cfg].length.should == 1 end end describe "one class many times" do before do @classes = parse(<<-EOS) /** * @class Foo * @cfg c1 */ /** @method fun1 */ /** @event eve1 */ /** @property prop1 */ /** * @class Foo * @extends Bar * Second description. * @xtype xfoo * @private * @cfg c2 */ /** @method fun2 */ /** @event eve3 */ /** @property prop2 */ /** * @class Foo * @extends Bazaar * @singleton * Third description. * @xtype xxxfoo * @cfg c3 */ /** @method fun3 */ /** @event eve3 */ /** @property prop3 */ EOS end it "results in only one class" do @classes.length.should == 1 end it "takes class doc from first doc-block that has one" do @classes[0][:doc].should == "Second description." end it "takes @extends from first doc-block that has one" do @classes[0][:extends].should == "Bar" end it "takes @xtype from first doc-block that has one" do @classes[0][:xtype].should == "xfoo" end it "is singleton when one doc-block is singleton" do @classes[0][:singleton].should == true end it "is private when one doc-block is private" do @classes[0][:private].should == true end it "combines all configs" do @classes[0][:cfg].length.should == 3 end it "combines all methods, events, properties" do @classes[0][:method].length.should == 3 @classes[0][:event].length.should == 3 @classes[0][:property].length.should == 3 end end end Loading
spec/aggregator_cfgs_and_properties_spec.rb 0 → 100644 +179 −0 Original line number Diff line number Diff line require "jsduck/aggregator" describe JsDuck::Aggregator do def parse(string) agr = JsDuck::Aggregator.new agr.parse(string) agr.result end shared_examples_for "cfg" do it "creates cfg" do @doc[:tagname].should == :cfg end end shared_examples_for "property" do it "creates property" do @doc[:tagname].should == :property end end shared_examples_for "cfg or property" do it "takes documentation from doc-comment" do @doc[:doc].should == "Some documentation." end it "detects name" do @doc[:name].should == "foo" end end shared_examples_for "cfg or property default type" do it "default type is Object" do @doc[:type].should == "Object" end end shared_examples_for "cfg or property String type" do it "detects type" do @doc[:type].should == "String" end end describe "explicit @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg {String} foo * Some documentation. */ EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "explicit @property" do before do @doc = parse(<<-EOS)[0] /** * @property {String} foo * Some documentation. */ EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "implicit @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg * Some documentation. */ foo: "asdf" EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "implicit @property" do before do @doc = parse(<<-EOS)[0] /** * Some documentation. */ foo: "asdf" EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "typeless @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg * Some documentation. */ foo: func(), EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property default type" end describe "typeless @property" do before do @doc = parse(<<-EOS)[0] /** * @property * Some documentation. */ foo: func(), EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property default type" end describe "@property with @type" do before do @doc = parse(<<-EOS)[0] /** * @property foo * @type String * Some documentation. */ EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "@type without @property" do before do @doc = parse(<<-EOS)[0] /** * @type String * Some documentation. */ MY_CONSTANT: true, EOS end it_should_behave_like "property" it_should_behave_like "cfg or property String type" it "detects name" do @doc[:name].should == "MY_CONSTANT" end end describe "@property with 'this' in ident chain" do before do @doc = parse(<<-EOS)[0] /** * @property * Some documentation. */ this.foo = ""; EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end end
spec/aggregator_classes_spec.rb 0 → 100644 +81 −0 Original line number Diff line number Diff line require "jsduck/aggregator" describe JsDuck::Aggregator do def parse(string) agr = JsDuck::Aggregator.new agr.parse(string) agr.result end describe "one class many times" do before do @classes = parse(<<-EOS) /** * @class Foo * @cfg c1 */ /** @method fun1 */ /** @event eve1 */ /** @property prop1 */ /** * @class Foo * @extends Bar * Second description. * @xtype xfoo * @private * @cfg c2 */ /** @method fun2 */ /** @event eve3 */ /** @property prop2 */ /** * @class Foo * @extends Bazaar * @singleton * Third description. * @xtype xxxfoo * @cfg c3 */ /** @method fun3 */ /** @event eve3 */ /** @property prop3 */ EOS end it "results in only one class" do @classes.length.should == 1 end it "takes class doc from first doc-block that has one" do @classes[0][:doc].should == "Second description." end it "takes @extends from first doc-block that has one" do @classes[0][:extends].should == "Bar" end it "takes @xtype from first doc-block that has one" do @classes[0][:xtype].should == "xfoo" end it "is singleton when one doc-block is singleton" do @classes[0][:singleton].should == true end it "is private when one doc-block is private" do @classes[0][:private].should == true end it "combines all configs" do @classes[0][:cfg].length.should == 3 end it "combines all methods, events, properties" do @classes[0][:method].length.should == 3 @classes[0][:event].length.should == 3 @classes[0][:property].length.should == 3 end end end
spec/aggregator_members_spec.rb 0 → 100644 +54 −0 Original line number Diff line number Diff line require "jsduck/aggregator" describe JsDuck::Aggregator do def parse(string) agr = JsDuck::Aggregator.new agr.parse(string) agr.result end describe "@member" do it "defines the class where item belongs" do items = parse(<<-EOS) /** * @cfg foo * @member Bar */ EOS items[0][:member].should == "Bar" end it "forces item to be moved into that class" do items = parse(<<-EOS) /** * @class Bar */ /** * @class Baz */ /** * @cfg foo * @member Bar */ EOS items[0][:cfg].length.should == 1 items[1][:cfg].length.should == 0 end it "even when @member comes before the class itself" do items = parse(<<-EOS) /** * @cfg foo * @member Bar */ /** * @class Bar */ EOS items[0][:cfg].length.should == 1 end end end
spec/aggregator_spec.rb→spec/aggregator_methods_and_events_spec.rb +0 −281 Original line number Diff line number Diff line Loading @@ -343,285 +343,4 @@ describe JsDuck::Aggregator do it_should_behave_like "no parameters" end shared_examples_for "cfg" do it "creates cfg" do @doc[:tagname].should == :cfg end end shared_examples_for "property" do it "creates property" do @doc[:tagname].should == :property end end shared_examples_for "cfg or property" do it "takes documentation from doc-comment" do @doc[:doc].should == "Some documentation." end it "detects name" do @doc[:name].should == "foo" end end shared_examples_for "cfg or property default type" do it "default type is Object" do @doc[:type].should == "Object" end end shared_examples_for "cfg or property String type" do it "detects type" do @doc[:type].should == "String" end end describe "explicit @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg {String} foo * Some documentation. */ EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "explicit @property" do before do @doc = parse(<<-EOS)[0] /** * @property {String} foo * Some documentation. */ EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "implicit @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg * Some documentation. */ foo: "asdf" EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "implicit @property" do before do @doc = parse(<<-EOS)[0] /** * Some documentation. */ foo: "asdf" EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "typeless @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg * Some documentation. */ foo: func(), EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property default type" end describe "typeless @property" do before do @doc = parse(<<-EOS)[0] /** * @property * Some documentation. */ foo: func(), EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property default type" end describe "@property with @type" do before do @doc = parse(<<-EOS)[0] /** * @property foo * @type String * Some documentation. */ EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "@type without @property" do before do @doc = parse(<<-EOS)[0] /** * @type String * Some documentation. */ MY_CONSTANT: true, EOS end it_should_behave_like "property" it_should_behave_like "cfg or property String type" it "detects name" do @doc[:name].should == "MY_CONSTANT" end end describe "@property with 'this' in ident chain" do before do @doc = parse(<<-EOS)[0] /** * @property * Some documentation. */ this.foo = ""; EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "@member" do it "defines the class where item belongs" do items = parse(<<-EOS) /** * @cfg foo * @member Bar */ EOS items[0][:member].should == "Bar" end it "forces item to be moved into that class" do items = parse(<<-EOS) /** * @class Bar */ /** * @class Baz */ /** * @cfg foo * @member Bar */ EOS items[0][:cfg].length.should == 1 items[1][:cfg].length.should == 0 end it "even when @member comes before the class itself" do items = parse(<<-EOS) /** * @cfg foo * @member Bar */ /** * @class Bar */ EOS items[0][:cfg].length.should == 1 end end describe "one class many times" do before do @classes = parse(<<-EOS) /** * @class Foo * @cfg c1 */ /** @method fun1 */ /** @event eve1 */ /** @property prop1 */ /** * @class Foo * @extends Bar * Second description. * @xtype xfoo * @private * @cfg c2 */ /** @method fun2 */ /** @event eve3 */ /** @property prop2 */ /** * @class Foo * @extends Bazaar * @singleton * Third description. * @xtype xxxfoo * @cfg c3 */ /** @method fun3 */ /** @event eve3 */ /** @property prop3 */ EOS end it "results in only one class" do @classes.length.should == 1 end it "takes class doc from first doc-block that has one" do @classes[0][:doc].should == "Second description." end it "takes @extends from first doc-block that has one" do @classes[0][:extends].should == "Bar" end it "takes @xtype from first doc-block that has one" do @classes[0][:xtype].should == "xfoo" end it "is singleton when one doc-block is singleton" do @classes[0][:singleton].should == true end it "is private when one doc-block is private" do @classes[0][:private].should == true end it "combines all configs" do @classes[0][:cfg].length.should == 3 end it "combines all methods, events, properties" do @classes[0][:method].length.should == 3 @classes[0][:event].length.should == 3 @classes[0][:property].length.should == 3 end end end