Sha256: 2bc76eb0bc29f15737198c45473c980254f351ab4ec4510ef6f02d19a283a2d0
Contents?: true
Size: 1.6 KB
Versions: 4
Compression:
Stored size: 1.6 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop describe SpaceInsideBrackets do let(:space) { SpaceInsideBrackets.new } it 'registers an offence for an array literal with spaces inside' do inspect_source(space, ['a = [1, 2 ]', 'b = [ 1, 2]']) expect(space.offences.map(&:message)).to eq( ['Space inside square brackets detected.', 'Space inside square brackets detected.']) end it 'accepts space inside strings within square brackets' do inspect_source(space, ["['Encoding:',", " ' Enabled: false']"]) expect(space.offences.map(&:message)).to be_empty end it 'accepts space inside square brackets if on its own row' do inspect_source(space, ['a = [', ' 1, 2', ' ]']) expect(space.offences.map(&:message)).to be_empty end it 'accepts square brackets as method name' do inspect_source(space, ['def Vector.[](*array)', 'end']) expect(space.offences.map(&:message)).to be_empty end it 'accepts square brackets called with method call syntax' do inspect_source(space, ['subject.[](0)']) expect(space.offences.map(&:message)).to be_empty end it 'only reports a single space once' do inspect_source(space, ['[ ]']) expect(space.offences.map(&:message)).to eq( ['Space inside square brackets detected.']) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems