Sha256: 78b1a00b509b146b7934bca68297d619b433f14c1b30777fdf7bd24f68d8a279

Contents?: true

Size: 934 Bytes

Versions: 11

Compression:

Stored size: 934 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe RuboCop::Cop::Style::SpaceBeforeComment do
  subject(:cop) { described_class.new }

  it 'registers an offense for missing space before an EOL comment' do
    inspect_source(cop, ['a += 1# increment'])
    expect(cop.highlights).to eq(['# increment'])
  end

  it 'accepts an EOL comment with a preceding space' do
    inspect_source(cop, ['a += 1 # increment'])
    expect(cop.offenses).to be_empty
  end

  it 'accepts a comment that begins a line' do
    inspect_source(cop, ['# comment'])
    expect(cop.offenses).to be_empty
  end

  it 'accepts a doc comment' do
    inspect_source(cop, ['=begin',
                         'Doc comment',
                         '=end'])
    expect(cop.offenses).to be_empty
  end

  it 'auto-corrects missing space' do
    new_source = autocorrect_source(cop, 'a += 1# increment')
    expect(new_source).to eq('a += 1 # increment')
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/style/space_before_comment_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/style/space_before_comment_spec.rb
rubocop-0.28.0 spec/rubocop/cop/style/space_before_comment_spec.rb
rubocop-0.27.1 spec/rubocop/cop/style/space_before_comment_spec.rb
rubocop-0.27.0 spec/rubocop/cop/style/space_before_comment_spec.rb
rubocop-0.26.1 spec/rubocop/cop/style/space_before_comment_spec.rb
rubocop-0.26.0 spec/rubocop/cop/style/space_before_comment_spec.rb
rubocop-0.25.0 spec/rubocop/cop/style/space_before_comment_spec.rb
rubocop-0.24.1 spec/rubocop/cop/style/space_before_comment_spec.rb
rubocop-0.24.0 spec/rubocop/cop/style/space_before_comment_spec.rb
rubocop-0.23.0 spec/rubocop/cop/style/space_before_comment_spec.rb