Sha256: c1e37943337654a3cf3b168a0ddfa0a330bfb1cfe697b8e510143e4b1037fd4e
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop module Style describe RedundantReturn do let(:cop) { RedundantReturn.new } it 'reports an offence for def with only a return' do src = ['def func', ' return something', 'end'] inspect_source(cop, src) expect(cop.offences).to have(1).item end it 'reports an offence for defs with only a return' do src = ['def Test.func', ' return something', 'end'] inspect_source(cop, src) expect(cop.offences).to have(1).item end it 'reports an offence for def ending with return' do src = ['def func', ' one', ' two', ' return something', 'end'] inspect_source(cop, src) expect(cop.offences).to have(1).item end it 'reports an offence for defs ending with return' do src = ['def func', ' one', ' two', ' return something', 'end'] inspect_source(cop, src) expect(cop.offences).to have(1).item end it 'accepts return in a non-final position' do src = ['def func', ' return something if something_else', 'end'] inspect_source(cop, src) expect(cop.offences).to be_empty end it 'does not blow up on empty method body' do src = ['def func', 'end'] inspect_source(cop, src) expect(cop.offences).to be_empty end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.10.0 | spec/rubocop/cops/style/redundant_return_spec.rb |