Sha256: 321aec3674f6115608f1ff77a9c4b04ff4200de085b62970551b6456b7898402
Contents?: true
Size: 1.58 KB
Versions: 7
Compression:
Stored size: 1.58 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop module Style describe SpaceAroundBraces do let(:space) { SpaceAroundBraces.new } it 'registers an offence for left brace without spaces' do inspect_source(space, ['each{ puts }']) expect(space.offences.map(&:message)).to eq( ["Surrounding space missing for '{'."]) end it 'registers an offence for right brace without inner space' do inspect_source(space, ['each { puts}']) expect(space.offences.map(&:message)).to eq( ["Space missing to the left of '}'."]) end it 'accepts an empty hash literal with no space inside' do inspect_source(space, ['view_hash.each do |view_key|', 'end', '@views = {}', '']) expect(space.offences.map(&:message)).to be_empty end it 'accepts string interpolation braces with no space inside' do inspect_source(space, ['"A=#{a}"', ':"#{b}"', '/#{c}/', '`#{d}`', 'sprintf("#{message.gsub(/%/, \'%%\')}", line)']) expect(space.offences.map(&:message)).to be_empty end it 'accepts braces around a hash literal argument' do inspect_source(space, ["new({'user' => user_params})"]) expect(space.offences.map(&:message)).to be_empty end end end end end
Version data entries
7 entries across 7 versions & 2 rubygems