Sha256: c822308de30c03f2997e6c62685735a37b5b9d8e6958324b6bcfd27fbe57307c
Contents?: true
Size: 1.4 KB
Versions: 2
Compression:
Stored size: 1.4 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop module Style describe ParameterLists, :config do subject(:list) { ParameterLists.new(config) } let(:cop_config) do { 'Max' => 4, 'CountKeywordArgs' => true } end it 'registers an offence for a method def with 5 parameters' do inspect_source(list, ['def meth(a, b, c, d, e)', 'end']) expect(list.offences.size).to eq(1) end it 'accepts a method def with 4 parameters' do inspect_source(list, ['def meth(a, b, c, d)', 'end']) expect(list.offences).to be_empty end context 'When CountKeywordArgs is true' do it 'counts keyword arguments as well', ruby: 2.0 do inspect_source(list, ['def meth(a, b, c, d: 1, e: 2)', 'end']) expect(list.offences.size).to eq(1) end end context 'When CountKeywordArgs is false' do before { cop_config['CountKeywordArgs'] = false } it 'it does not count keyword arguments', ruby: 2.0 do inspect_source(list, ['def meth(a, b, c, d: 1, e: 2)', 'end']) expect(list.offences).to be_empty end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.13.1 | spec/rubocop/cop/style/parameter_lists_spec.rb |
rubocop-0.13.0 | spec/rubocop/cop/style/parameter_lists_spec.rb |