spec/handlers/constant_handler_spec.rb in yard-0.2.3.5 vs spec/handlers/constant_handler_spec.rb in yard-0.4.0

- old
+ new

@@ -8,6 +8,44 @@ end it "should only parse valid constants" do Registry.at("A::B::notaconstant").should be_nil end + + it "should maintain newlines" do + Registry.at("A::B::MYCONSTANT").value.should == "A +\nB +\nC +\nD" + end + + it "should turn Const = Struct.new(:sym) into class Const with attr :sym" do + obj = Registry.at("MyClass") + obj.should be_kind_of(CodeObjects::ClassObject) + attrs = obj.attributes[:instance] + [:a, :b, :c].each do |key| + attrs.should have_key(key) + attrs[key][:read].should_not be_nil + attrs[key][:write].should_not be_nil + end + end + + it "should turn Const = Struct.new('Name', :sym) into class Const with attr :sym" do + obj = Registry.at("NotMyClass") + obj.should be_kind_of(CodeObjects::ClassObject) + attrs = obj.attributes[:instance] + [:b, :c].each do |key| + attrs.should have_key(key) + attrs[key][:read].should_not be_nil + attrs[key][:write].should_not be_nil + end + + Registry.at("NotMyClass2").should be_nil + end + + it "should turn Const = Struct.new into empty struct" do + obj = Registry.at("MyEmptyStruct") + obj.should_not be_nil + obj.attributes[:instance].should be_empty + end + + it "should raise undocumentable error in 1.9 parser for Struct.new assignment to non-const" do + undoc_error "nonconst = Struct.new" + end if RUBY19 end \ No newline at end of file