File: coderay_spec.rb

package info (click to toggle)
coderay 1.1.3-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,372 kB
  • sloc: ruby: 9,987; makefile: 14; sh: 2; python: 1
file content (34 lines) | stat: -rw-r--r-- 842 bytes parent folder | download | duplicates (3)
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
require File.expand_path('../spec_helper', __FILE__)

RSpec.describe CodeRay do
  describe '::VERSION' do
    it "returns the Gem's version" do
      expect(CodeRay::VERSION).to match(/\A\d\.\d\.\d?\z/)
    end
  end

  describe '.coderay_path' do
    it 'returns an absolute file path to the given code file' do
      expect(CodeRay.coderay_path('file')).to eq("#{CodeRay::CODERAY_PATH}/file")
    end
  end

  describe '.scan' do
    let(:code) { 'puts "Hello, World!"' }
    let(:tokens) do
      [
        ['puts', :ident],
        [' ', :space],
        [:begin_group, :string],
          ['"', :delimiter],
          ['Hello, World!', :content],
          ['"', :delimiter],
        [:end_group, :string]
      ].flatten
    end

    it 'returns tokens' do
      expect(CodeRay.scan(code, :ruby).tokens).to eq(tokens)
    end
  end
end