summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/gfm/ast/syntax/markdown/code_block_spec.rb
blob: c8a5c05310fd4bd38df7d9f1f8f1a450fefbdb7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'spec_helper'

describe Gitlab::Gfm::Ast::Syntax::Markdown::CodeBlock do
  let(:text) { "```ruby\ncode block\n```" }

  describe 'token' do
    it 'matches entire text' do
      expect(text).to match described_class.pattern
    end
  end

  describe 'lexeme' do
    let(:lexeme) { Gitlab::Gfm::Ast::Lexer.single(text, described_class) }

    describe '#nodes' do
      subject { lexeme.nodes }
      it { is_expected.to be_empty }
    end

    describe '#leaf?' do
      subject { lexeme.leaf? }
      it { is_expected.to be true }
    end

    describe '#to_s' do
      subject { lexeme.to_s }
      it { is_expected.to eq text }
    end

    describe '#lang' do
      subject { lexeme.lang }
      it { is_expected.to eq 'ruby' }
    end
  end
end