Sha256: 00658474c0dc2fff64aac2f229674e5d8fb32f819773b115f84f2598240b8549
Contents?: true
Size: 1.6 KB
Versions: 2
Compression:
Stored size: 1.6 KB
Contents
# encoding: utf-8 describe RuboCop::Cop::RSpec::ExampleLength, :config do subject(:cop) { described_class.new(config) } let(:cop_config) { { 'Max' => 3 } } it 'allows an empty example' do inspect_source( cop, [ 'it do', 'end' ] ) expect(cop.offenses).to be_empty end it 'allows a short example' do inspect_source( cop, [ 'it do', ' line 1', ' line 2', ' line 3', 'end' ] ) expect(cop.offenses).to be_empty end it 'doesn\t allow a long example' do inspect_source( cop, [ 'it do', ' line 1', ' line 2', ' line 3', ' line 4', 'end' ] ) expect(cop.offenses.size).to eq(1) expect(cop.offenses.map(&:line).sort).to eq([1]) expect(cop.messages).to eq(['Example has too many lines. [4/3]']) end it 'ignores comments' do inspect_source( cop, [ 'it do', ' line 1', ' line 2', ' # comment', ' line 3', 'end' ] ) expect(cop.offenses).to be_empty end context 'with CountComments enabled' do before { cop_config['CountComments'] = true } it 'counts comments' do inspect_source( cop, [ 'it do', ' line 1', ' line 2', ' # comment', ' line 3', 'end' ] ) expect(cop.offenses.size).to eq(1) expect(cop.offenses.map(&:line).sort).to eq([1]) expect(cop.messages).to eq(['Example has too many lines. [4/3]']) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-rspec-1.5.1 | spec/rubocop/cop/rspec/example_length_spec.rb |
rubocop-rspec-1.5.0 | spec/rubocop/cop/rspec/example_length_spec.rb |