Sha256: 6518e8f196b96ef72b61363f8fca18105f1321ca2776d3844025e4e0367892bf
Contents?: true
Size: 1.78 KB
Versions: 3
Compression:
Stored size: 1.78 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Rubocop::Cop::Lint::SpaceBeforeFirstArg do subject(:cop) { described_class.new } context 'for method calls without parentheses' do it 'registers an offense for method call with no space before the ' \ 'first arg' do inspect_source(cop, ['something?x', 'a.something!y, z']) expect(cop.messages) .to eq(['Put space between the method name and the first ' \ 'argument.'] * 2) expect(cop.highlights).to eq(%w(x y)) end it 'accepts a method call with space before the first arg' do inspect_source(cop, ['something? x', 'a.something! y, z']) expect(cop.offenses).to be_empty end it 'accepts square brackets operator' do inspect_source(cop, ['something[:x]']) expect(cop.offenses).to be_empty end it 'accepts a method call with space before a multiline arg' do inspect_source(cop, "something [\n 'foo',\n 'bar'\n]") expect(cop.offenses).to be_empty end it 'accepts an assignment without space before first arg' do inspect_source(cop, ['a.something=c', 'a.something,b=c,d']) expect(cop.offenses).to be_empty end end context 'for method calls with parentheses' do it 'accepts a method call without space' do inspect_source(cop, ['something?(x)', 'a.something(y, z)']) expect(cop.offenses).to be_empty end it 'accepts a method call with space after the left parenthesis' do inspect_source(cop, ['something?( x )']) expect(cop.offenses).to be_empty end it 'accepts setter call' do inspect_source(cop, ['self.class.controller_path=(path)']) expect(cop.offenses).to be_empty end end end
Version data entries
3 entries across 3 versions & 1 rubygems