Sha256: 1158b13762f00ee4c39a70cda6eac77e45409e56099b594cfba378c2a7effd42

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  it 'registers an offense for space inside .. literal' do
    inspect_source(cop,
                   ['1 .. 2',
                    '1.. 2',
                    '1 ..2'])
    expect(cop.offenses.size).to eq(3)
    expect(cop.messages)
      .to eq(['Space inside range literal.'] * 3)
  end

  it 'accepts no space inside .. literal' do
    inspect_source(cop, '1..2')
    expect(cop.offenses).to be_empty
  end

  it 'registers an offense for space inside ... literal' do
    inspect_source(cop,
                   ['1 ... 2',
                    '1... 2',
                    '1 ...2'])
    expect(cop.offenses.size).to eq(3)
    expect(cop.messages)
      .to eq(['Space inside range literal.'] * 3)
  end

  it 'accepts no space inside ... literal' do
    inspect_source(cop, '1...2')
    expect(cop.offenses).to be_empty
  end

  it 'accepts complex range literal with space in it' do
    inspect_source(cop, '0...(line - 1)')
    expect(cop.offenses).to be_empty
  end

  it 'autocorrects space around .. literal' do
    corrected = autocorrect_source(cop, ['1  .. 2'])
    expect(corrected).to eq '1..2'
  end

  it 'autocorrects space around ... literal' do
    corrected = autocorrect_source(cop, ['1  ... 2'])
    expect(corrected).to eq '1...2'
  end
end

Version data entries

5 entries across 5 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_inside_range_literal_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/style/space_inside_range_literal_spec.rb
rubocop-0.27.0 spec/rubocop/cop/style/space_inside_range_literal_spec.rb
rubocop-0.26.1 spec/rubocop/cop/style/space_inside_range_literal_spec.rb
rubocop-0.26.0 spec/rubocop/cop/style/space_inside_range_literal_spec.rb