Sha256: be168d655c3933a05fe879295c01aa2daebd89a367fc2fd65656dfc2391ae74e
Contents?: true
Size: 1.57 KB
Versions: 4
Compression:
Stored size: 1.57 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Rubocop::Cop::Lint::ParenthesesAsGroupedExpression do subject(:cop) { described_class.new } it 'registers an offence for method call with space before the ' + 'parenthesis' do inspect_source(cop, ['a.func (x)']) expect(cop.offences).to have(1).item end it 'registers an offence for predicate method call with space ' + 'before the parenthesis' do inspect_source(cop, ['is? (x)']) expect(cop.offences).to have(1).item end it 'registers an offence for math expression' do inspect_source(cop, ['puts (2 + 3) * 4']) expect(cop.offences).to have(1).item end it 'accepts a method call without arguments' do inspect_source(cop, ['func']) expect(cop.offences).to be_empty end it 'accepts a method call with arguments but no parentheses' do inspect_source(cop, ['puts x']) expect(cop.offences).to be_empty end it 'accepts a chain of method calls' do inspect_source(cop, ['a.b', 'a.b 1', 'a.b(1)']) expect(cop.offences).to be_empty end it 'accepts method with parens as arg to method without' do inspect_source(cop, ['a b(c)']) expect(cop.offences).to be_empty end it 'accepts an operator call with argument in parentheses' do inspect_source(cop, ['a % (b + c)', 'a.b = (c == d)']) expect(cop.offences).to be_empty end it 'accepts a space inside opening paren followed by left paren' do inspect_source(cop, ['a( (b) )']) expect(cop.offences).to be_empty end end
Version data entries
4 entries across 4 versions & 1 rubygems