Skip to content

Commit

Permalink
Merge pull request #1534 from bquorning/spec-invalid-configuration
Browse files Browse the repository at this point in the history
Spec invalid configuration
  • Loading branch information
bbatsov committed Dec 28, 2014
2 parents 4d3f9a5 + 8892153 commit 2209008
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/rubocop/cop/style/guard_clause_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,21 @@
expect(cop.offenses).to be_empty
end
end

context 'Invalid MinBodyLength' do
let(:cop_config) do
{ 'MinBodyLength' => -2 }
end

it 'fails with an error' do
source = ['def func',
' if something',
' work',
' end',
'end']

expect { inspect_source(cop, source) }
.to raise_error('MinBodyLength needs to be a positive integer!')
end
end
end
16 changes: 16 additions & 0 deletions spec/rubocop/cop/style/next_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,20 @@
expect(cop.highlights).to eq(['each'])
end
end

context 'Invalid MinBodyLength' do
let(:cop_config) do
{ 'MinBodyLength' => -2 }
end

it 'fails with an error' do
source = ['loop do',
' if o == 1',
' puts o',
' end',
'end']
expect { inspect_source(cop, source) }
.to raise_error('MinBodyLength needs to be a positive integer!')
end
end
end
9 changes: 9 additions & 0 deletions spec/rubocop/cop/style/space_inside_block_braces_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@
end
end

context 'with invalid value for EnforcedStyleForEmptyBraces' do
let(:cop_config) { { 'EnforcedStyleForEmptyBraces' => 'unknown' } }

it 'fails with an error' do
expect { inspect_source(cop, 'each { }') }
.to raise_error('Unknown EnforcedStyleForEmptyBraces selected!')
end
end

it 'accepts braces surrounded by spaces' do
inspect_source(cop, 'each { puts }')
expect(cop.messages).to be_empty
Expand Down

0 comments on commit 2209008

Please sign in to comment.