Sha256: efe3c283ea4ef018af628e303f3ddd5992dab6e02728cc3f12122da4da639d66

Contents?: true

Size: 1.51 KB

Versions: 9

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

describe Minimart::Web::MarkdownParser do

  describe '::parse' do
    context 'when the file does not have a markdown extension' do
      let(:contents) { 'file contents here' }

      let(:file) do
        File.join(test_directory, 'readme.rdoc').tap do |file_name|
          File.open(file_name, 'w+') { |f| f.write(contents) }
        end
      end

      it 'should return the file contents' do
        expect(Minimart::Web::MarkdownParser.parse(file)).to eq contents
      end

      it 'should not attempt to parse the file' do
        expect(Minimart::Web::MarkdownParser).to_not receive(:new)
        Minimart::Web::MarkdownParser.parse(file)
      end
    end

    context 'when the file has a .md extension' do
      let(:contents) { '# Title' }

      let(:file) do
        File.join(test_directory, 'readme.md').tap do |file_name|
          File.open(file_name, 'w+') { |f| f.write(contents) }
        end
      end

      it 'should parse the contents as markdown' do
        expect(Minimart::Web::MarkdownParser.parse(file)).to match '<h1>Title</h1>'
      end
    end

    context 'when the file has a .markdown extension' do
      let(:contents) { '# Title' }

      let(:file) do
        File.join(test_directory, 'readme.markdown').tap do |file_name|
          File.open(file_name, 'w+') { |f| f.write(contents) }
        end
      end

      it 'should parse the contents as markdown' do
        expect(Minimart::Web::MarkdownParser.parse(file)).to match '<h1>Title</h1>'
      end
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
minimart-1.2.5 spec/lib/minimart/web/markdown_parser_spec.rb
minimart-1.2.4 spec/lib/minimart/web/markdown_parser_spec.rb
minimart-1.2.3 spec/lib/minimart/web/markdown_parser_spec.rb
minimart-1.2.0 spec/lib/minimart/web/markdown_parser_spec.rb
minimart-1.1.6 spec/lib/minimart/web/markdown_parser_spec.rb
minimart-1.1.3 spec/lib/minimart/web/markdown_parser_spec.rb
minimart-1.0.2 spec/lib/minimart/web/markdown_parser_spec.rb
minimart-1.0.1 spec/lib/minimart/web/markdown_parser_spec.rb
minimart-0.0.1 spec/lib/minimart/web/markdown_parser_spec.rb