Sha256: 86a4d6abcea6875de34fdfcfa5e25add7a57b182c9f255adbc409c180d51aa42

Contents?: true

Size: 1.47 KB

Versions: 11

Compression:

Stored size: 1.47 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  it 'registers an offense for block comments' do
    inspect_source(cop,
                   ['=begin',
                    'comment',
                    '=end'])
    expect(cop.offenses.size).to eq(1)
  end

  it 'accepts regular comments' do
    inspect_source(cop,
                   ['# comment'])
    expect(cop.offenses).to be_empty
  end

  it 'auto-corrects a block comment into a regular comment' do
    new_source = autocorrect_source(cop, ['=begin',
                                          'comment line 1',
                                          '',
                                          'comment line 2',
                                          '=end',
                                          'def foo',
                                          'end'])
    expect(new_source).to eq(['# comment line 1',
                              '#',
                              '# comment line 2',
                              'def foo',
                              'end'].join("\n"))
  end

  it 'auto-corrects an empty block comment by removing it' do
    new_source = autocorrect_source(cop, ['=begin',
                                          '=end',
                                          'def foo',
                                          'end'])
    expect(new_source).to eq(['def foo',
                              'end'].join("\n"))
  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/block_comments_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/style/block_comments_spec.rb
rubocop-0.28.0 spec/rubocop/cop/style/block_comments_spec.rb
rubocop-0.27.1 spec/rubocop/cop/style/block_comments_spec.rb
rubocop-0.27.0 spec/rubocop/cop/style/block_comments_spec.rb
rubocop-0.26.1 spec/rubocop/cop/style/block_comments_spec.rb
rubocop-0.26.0 spec/rubocop/cop/style/block_comments_spec.rb
rubocop-0.25.0 spec/rubocop/cop/style/block_comments_spec.rb
rubocop-0.24.1 spec/rubocop/cop/style/block_comments_spec.rb
rubocop-0.24.0 spec/rubocop/cop/style/block_comments_spec.rb
rubocop-0.23.0 spec/rubocop/cop/style/block_comments_spec.rb