Sha256: 17914fe393cbd1ae7fe653cc6dd48c9f2e8c03ab5c0ba007b1ae31239871cf5e

Contents?: true

Size: 1.43 KB

Versions: 26

Compression:

Stored size: 1.43 KB

Contents

require 'xcpretty/syntax'

module XCPretty
  describe Syntax do
    it 'syntax highlights given code' do
      code = 'self.color = [UIColor redColor];'
      snippet = Snippet.new(code, 'test.m')
      output = Syntax.highlight(snippet)

      stripped_output = output.gsub(/(?:(?:\u001b\[)|\u009b)(?:(?:[0-9]{1,3})?(?:;[0-9]{0,3})*?[A-M|f-m])|\u001b[A-M]/, '')
      stripped_output.should == code
    end

    it 'uses Objective-C lexer for Objective-C' do
      Syntax.find_lexer('test.m', '').should == Rouge::Lexers::ObjectiveC
      Syntax.find_lexer('test.h', '').should == Rouge::Lexers::ObjectiveC
    end

    it 'uses Swift lexer for Swift' do
      Syntax.find_lexer('test.swift', '').should == Rouge::Lexers::Swift
    end

    it 'uses Ruby lexer for Ruby' do
      Syntax.find_lexer('test.rb', '').should == Rouge::Lexers::Ruby
      Syntax.find_lexer('test.ruby', '').should == Rouge::Lexers::Ruby
    end

    it 'uses C++ lexer for C++' do
      Syntax.find_lexer('test.cpp', '').should == Rouge::Lexers::Cpp
      Syntax.find_lexer('test.cc', '').should == Rouge::Lexers::Cpp
      Syntax.find_lexer('test.c++', '').should == Rouge::Lexers::Cpp
      Syntax.find_lexer('test.cxx', '').should == Rouge::Lexers::Cpp
      Syntax.find_lexer('test.hpp', '').should == Rouge::Lexers::Cpp
      Syntax.find_lexer('test.h++', '').should == Rouge::Lexers::Cpp
      Syntax.find_lexer('test.hxx', '').should == Rouge::Lexers::Cpp
    end
  end
end

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
xcpretty-0.4.0 spec/xcpretty/syntax_spec.rb
xcpretty-security-patched-0.3.2 spec/xcpretty/syntax_spec.rb
xcpretty-security-patched-0.3.0 spec/xcpretty/syntax_spec.rb
xcpretty-0.3.0 spec/xcpretty/syntax_spec.rb
xcpretty-0.2.8 spec/xcpretty/syntax_spec.rb
xcpretty-0.2.7 spec/xcpretty/syntax_spec.rb
xcpretty-0.2.6 spec/xcpretty/syntax_spec.rb
xcpretty-0.2.4 spec/xcpretty/syntax_spec.rb
xcpretty-0.2.3 spec/xcpretty/syntax_spec.rb
xcpretty-bb-0.1.12.bb14 spec/xcpretty/syntax_spec.rb
xcpretty-bb-0.1.12.bb13 spec/xcpretty/syntax_spec.rb
xcpretty-bb-0.1.12.bb12 spec/xcpretty/syntax_spec.rb
xcpretty-bb-0.1.12.bb11 spec/xcpretty/syntax_spec.rb
xcpretty-bb-0.1.12.bb10 spec/xcpretty/syntax_spec.rb
xcpretty-bb-0.1.12.bb9 spec/xcpretty/syntax_spec.rb
xcpretty-bb-0.1.12.bb8 spec/xcpretty/syntax_spec.rb
xcpretty-0.2.2 spec/xcpretty/syntax_spec.rb
xcpretty-bb-0.1.12.bb7 spec/xcpretty/syntax_spec.rb
xcpretty-0.2.1 spec/xcpretty/syntax_spec.rb
xcpretty-bb-0.1.12.bb6 spec/xcpretty/syntax_spec.rb