Sha256: 30bdd358fa3760fbc7c69ba0f6b4598799a16d6b5cdfa77a9d02999e56d7b257
Contents?: true
Size: 1.91 KB
Versions: 3
Compression:
Stored size: 1.91 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Rubocop::Cop::Style::DotPosition, :config do subject(:cop) { described_class.new(config) } context 'Leading dots style' do let(:cop_config) { { 'Style' => 'Leading' } } it 'registers an offence for trailing dot in multi-line call' do inspect_source(cop, ['something.', ' method_name']) expect(cop.offences.size).to eq(1) end it 'accepts leading do in multi-line method call' do inspect_source(cop, ['something', ' .method_name']) expect(cop.offences).to be_empty end it 'does not err on method call with no dots' do inspect_source(cop, ['puts something']) expect(cop.offences).to be_empty end it 'does not err on method call without a method name' do inspect_source(cop, ['l.', '(1)']) expect(cop.offences.size).to eq(1) end end context 'Trailing dots style' do let(:cop_config) { { 'Style' => 'Trailing' } } it 'registers an offence for leading dot in multi-line call' do inspect_source(cop, ['something', ' .method_name']) expect(cop.offences.size).to eq(1) end it 'accepts trailing dot in multi-line method call' do inspect_source(cop, ['something.', ' method_name']) expect(cop.offences).to be_empty end it 'does not err on method call with no dots' do inspect_source(cop, ['puts something']) expect(cop.offences).to be_empty end it 'does not err on method call without a method name' do inspect_source(cop, ['l', '.(1)']) expect(cop.offences.size).to eq(1) end end context 'Unknown style' do let(:cop_config) { { 'Style' => 'test' } } it 'raises an exception' do expect do inspect_source(cop, ['something.top']) end.to raise_error(RuntimeError) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.15.0 | spec/rubocop/cop/style/dot_position_spec.rb |
rubocop-0.14.1 | spec/rubocop/cop/style/dot_position_spec.rb |
rubocop-0.14.0 | spec/rubocop/cop/style/dot_position_spec.rb |