Sha256: f51190f98d4f17859bb5a03dea1494ae9c4451341431eec6039678ce1d6885c7

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Style::LeadingCommentSpace do
  subject(:cop) { described_class.new }

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

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

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

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

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

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

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

  it 'accepts rdoc syntax' do
    inspect_source(cop,
                   ['#++',
                    '#--',
                    '#:nodoc:'])

    expect(cop.offences).to be_empty
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.14.1 spec/rubocop/cop/style/leading_comment_space_spec.rb
rubocop-0.14.0 spec/rubocop/cop/style/leading_comment_space_spec.rb