Sha256: f18c63ab4efcce56a2f98e165f0c768f1f31d80ac70e71a760d4e0666741f369

Contents?: true

Size: 1.48 KB

Versions: 4

Compression:

Stored size: 1.48 KB

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    describe LeadingCommentSpace do
      let(:lcs) { LeadingCommentSpace.new }

      it 'registers an offence for comment without leading space' do
        inspect_source(lcs,
                       ['#missing space'])
        expect(lcs.offences.size).to eq(1)
      end

      it 'does not register an offence for # followed by no text' do
        inspect_source(lcs,
                       ['#'])
        expect(lcs.offences).to be_empty
      end

      it 'does not register an offence for more than one space' do
        inspect_source(lcs,
                       ['#   heavily indented'])
        expect(lcs.offences).to be_empty
      end

      it 'does not register an offence for more than one #' do
        inspect_source(lcs,
                       ['###### heavily indented'])
        expect(lcs.offences).to be_empty
      end

      it 'does not register an offence for only #s' do
        inspect_source(lcs,
                       ['######'])
        expect(lcs.offences).to be_empty
      end

      it 'does not register an offence for #! on first line' do
        inspect_source(lcs,
                       ['#!/usr/bin/ruby',
                        'test'])
        expect(lcs.offences).to be_empty
      end

      it 'registers an offence for #! after the first line' do
        inspect_source(lcs,
                       ['test', '#!/usr/bin/ruby'])
        expect(lcs.offences.size).to eq(1)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.8.3 spec/rubocop/cops/leading_comment_space_spec.rb
rubocop-0.8.2 spec/rubocop/cops/leading_comment_space_spec.rb
rubocop-0.8.1 spec/rubocop/cops/leading_comment_space_spec.rb
rubocop-0.8.0 spec/rubocop/cops/leading_comment_space_spec.rb