Sha256: 0d567d314d9d62a2368b0b6e2323e5a33189b1345ec086f8922756478fedd188
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
describe RuboCop::Cop::RSpec::ExampleLength, :config do subject(:cop) { described_class.new(config) } let(:cop_config) { { 'Max' => 3 } } it 'ignores non-spec blocks' do inspect_source( cop, [ 'foo do', ' line 1', ' line 2', ' line 3', ' line 4', 'end' ] ) expect(cop.offenses).to be_empty end 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
3 entries across 3 versions & 1 rubygems