spec/murdoc/annotator_spec.rb in murdoc-0.1.6 vs spec/murdoc/annotator_spec.rb in murdoc-0.1.7

- old
+ new

@@ -76,17 +76,34 @@ subject.paragraphs[0].source.should =~ /\A\s*def hi\s*puts 'hello'\s*end\s*\Z/m subject.paragraphs[0].annotation.should =~ /\ABlock one\s*Block one!!!!\Z/m subject.paragraphs[1].source.should =~ /\A\s*def yo\s*puts 'rap'\s*end\s*\Z/m subject.paragraphs[1].annotation.should =~ /\ABlock two\Z/m end + + it "should not hang upon non-closed comments" do + source = "=begin\n" + lambda { + subject = described_class.new(source, :ruby) + subject.source = source + }.should_not raise_error + end end context "for comment without code" do let(:source) { "# Header\n\n\n# Comment\ndef body\nend" } it "should create a separate paragraph" do subject.should have_exactly(2).paragraphs subject.paragraphs[0].source.should == "" subject.paragraphs[0].annotation.should == "Header" + end + end + + context "for commented code" do + let(:source) { "# :code:\n# def hello\n# end\n\n\# Comment\ndef hi\nend" } + it "should not create paragraphs" do + subject.should have_exactly(1).paragraphs + subject.paragraphs[0].source.should == "def hi\nend" + subject.paragraphs[0].annotation.should == "Comment" end end it "should not choke on edge cases" do subject.source = "" \ No newline at end of file