require 'spec_helper' describe Marksman::Parser do it 'should parse a file with meta data' do presentation = Marksman::Parser.new.parse('spec/data/example.md') expect(presentation.title).to eq('This is an example presentation') expect(presentation.slides).to eq([ Marksman::Slide.new({ slide: '
First Page
', notes: '' }), Marksman::Slide.new({ slide: 'Second Page
', notes: 'Author comment
' }), Marksman::Slide.new({ slide: 'Third Page
', notes: '' }) ]) expect(presentation.filename).to eq('example.md') expect(presentation.theme).to eq(Marksman::Theme.new('plain')) expect(presentation.metadata).to eq({ example: true, filename: 'example.md', theme: 'plain', title: 'This is an example presentation' }) end it 'should parse a file without meta data' do presentation = Marksman::Parser.new.parse('spec/data/example_without_metadata.md') expect(presentation.title).to eq('example_without_metadata.md') expect(presentation.slides).to eq([ Marksman::Slide.new({ slide: 'First Page
', notes: '' }), Marksman::Slide.new({ slide: 'Second Page
', notes: 'Author comment
' }), Marksman::Slide.new({ slide: 'Third Page
', notes: '' }) ]) expect(presentation.filename).to eq('example_without_metadata.md') expect(presentation.theme).to eq(Marksman::Theme.new('plain')) expect(presentation.metadata).to eq({ filename: 'example_without_metadata.md', theme: 'plain', title: 'example_without_metadata.md' }) end it 'should throw an exception if the file was not there' do expect{Marksman::Parser.new.parse('spec/data/example-not-existing.md')}.to raise_error end end