Sha256: c82160bdab6de42c1646a61f18624460de23b9d8291ae7bdb99bc40c180dc301

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'

describe Coffeelint do
  it 'should error with semicolon' do
    results = Coffeelint.lint('apple;')
    results.length.should == 1
    result = results[0]
    result['message'].should include 'trailing semicolon'
  end

  it 'should be able to disable a linter' do
    results = Coffeelint.lint('apple;', :no_trailing_semicolons =>  { :level => "ignore" } )
    results.length.should == 0
  end

  it 'should be able to take a config file in the parameters' do
    File.open('/tmp/coffeelint.json', 'w') {|f| f.write(JSON.dump({:no_trailing_semicolons => { :level => "ignore" }})) }
    results = Coffeelint.lint('apple;', :config_file => "/tmp/coffeelint.json")
    results.length.should == 0
  end

  it 'should report missing fat arrow' do
    results = Coffeelint.lint "hey: ->\n  @bort()\n", :missing_fat_arrows => { :level => "error" }
    results.length.should == 1
  end

  it 'should report unnecessary fat arrow' do
    results = Coffeelint.lint "hey: =>\n  bort()\n", :no_unnecessary_fat_arrows => { :level => "error" }
    results.length.should == 1
  end

  it 'should report cyclomatic complexity' do
    results = Coffeelint.lint(<<-EOF, :cyclomatic_complexity => { :level => "error" })
      x = ->
        1 and 2 and 3 and
        4 and 5 and 6 and
        7 and 8 and 9 and
        10 and 11
    EOF
    results.length.should == 1
    results[0]['name'].should == 'cyclomatic_complexity'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
coffeelint-0.3.0 spec/coffeelint_spec.rb
coffeelint-0.2.7 spec/coffeelint_spec.rb
coffeelint-0.2.6 spec/coffeelint_spec.rb
coffeelint-0.2.5 spec/coffeelint_spec.rb