spec/murdoc/annotator_spec.rb in murdoc-0.2.0 vs spec/murdoc/annotator_spec.rb in murdoc-0.2.1
- old
+ new
@@ -122,6 +122,25 @@
it "should remove semi-empty lines" do
subject = described_class.new("def hi\n\nend", :ruby)
subject.paragraphs[0].source.should == "def hi\n\nend"
end
end
+
+ describe "metadata extraction" do
+ subject { described_class.new("# ---\n# foo: 'bar'\n# baz: 'foobar'\n# ---\nhello, world!", :ruby) }
+ it "extracts and parses yaml blocks in the beginning of the file" do
+ subject.metadata.should == {
+ 'foo' => 'bar',
+ 'baz' => 'foobar'
+ }
+ end
+
+ it "cuts metadata from the paragraph annotation text" do
+ subject.paragraphs[0].annotation.should_not include('---')
+ end
+
+ it "doesn't raise on invalid yaml" do
+ subject = described_class.new("---\n{\n---\nfoo bar", :ruby)
+ subject.metadata.should == {}
+ end
+ end
end