spec/rubocop/cop/rspec/file_path_spec.rb in rubocop-rspec-1.2.1 vs spec/rubocop/cop/rspec/file_path_spec.rb in rubocop-rspec-1.2.2

- old
+ new

@@ -4,41 +4,41 @@ subject(:cop) { described_class.new(config) } let(:cop_config) { { 'CustomTransform' => { 'FooFoo' => 'foofoo' } } } it 'checks the path' do inspect_source(cop, - ["describe MyClass, 'foo' do; end"], + "describe MyClass, 'foo' do; end", 'wrong_path_foo_spec.rb') expect(cop.offenses.size).to eq(1) expect(cop.offenses.map(&:line).sort).to eq([1]) expect(cop.messages) .to eq(['Spec path should end with `my_class*foo*_spec.rb`']) end it 'checks the path' do inspect_source(cop, - ["describe MyClass, '#foo' do; end"], + "describe MyClass, '#foo' do; end", 'wrong_class_foo_spec.rb') expect(cop.offenses.size).to eq(1) expect(cop.offenses.map(&:line).sort).to eq([1]) expect(cop.messages) .to eq(['Spec path should end with `my_class*foo*_spec.rb`']) end it 'checks class spec paths' do inspect_source(cop, - ['describe MyClass do; end'], + 'describe MyClass do; end', 'wrong_class_spec.rb') expect(cop.offenses.size).to eq(1) expect(cop.offenses.map(&:line).sort).to eq([1]) expect(cop.messages) .to eq(['Spec path should end with `my_class*_spec.rb`']) end it 'skips specs that do not describe a class / method' do inspect_source(cop, - ["describe 'Test something' do; end"], + "describe 'Test something' do; end", 'some/class/spec.rb') expect(cop.offenses).to be_empty end it 'skips specs that do have multiple top level describes' do @@ -49,101 +49,101 @@ expect(cop.offenses).to be_empty end it 'checks class specs' do inspect_source(cop, - ['describe Some::Class do; end'], + 'describe Some::Class do; end', 'some/class_spec.rb') expect(cop.offenses).to be_empty end it 'handles CamelCaps class names' do inspect_source(cop, - ['describe MyClass do; end'], + 'describe MyClass do; end', 'my_class_spec.rb') expect(cop.offenses).to be_empty end it 'handles ACRONYMClassNames' do inspect_source(cop, - ['describe ABCOne::Two do; end'], + 'describe ABCOne::Two do; end', 'abc_one/two_spec.rb') expect(cop.offenses).to be_empty end it 'handles ALLCAPS class names' do inspect_source(cop, - ['describe ALLCAPS do; end'], + 'describe ALLCAPS do; end', 'allcaps_spec.rb') expect(cop.offenses).to be_empty end it 'checks instance methods' do inspect_source(cop, - ["describe Some::Class, '#inst' do; end"], + "describe Some::Class, '#inst' do; end", 'some/class/inst_spec.rb') expect(cop.offenses).to be_empty end it 'checks class methods' do inspect_source(cop, - ["describe Some::Class, '.inst' do; end"], + "describe Some::Class, '.inst' do; end", 'some/class/inst_spec.rb') expect(cop.offenses).to be_empty end it 'allows flat hierarchies for instance methods' do inspect_source(cop, - ["describe Some::Class, '#inst' do; end"], + "describe Some::Class, '#inst' do; end", 'some/class_inst_spec.rb') expect(cop.offenses).to be_empty end it 'allows flat hierarchies for class methods' do inspect_source(cop, - ["describe Some::Class, '.inst' do; end"], + "describe Some::Class, '.inst' do; end", 'some/class_inst_spec.rb') expect(cop.offenses).to be_empty end it 'allows subdirs for instance methods' do inspect_source(cop, - ["describe Some::Class, '#inst' do; end"], + "describe Some::Class, '#inst' do; end", 'some/class/instance_methods/inst_spec.rb') expect(cop.offenses).to be_empty end it 'allows subdirs for class methods' do inspect_source(cop, - ["describe Some::Class, '.inst' do; end"], + "describe Some::Class, '.inst' do; end", 'some/class/class_methods/inst_spec.rb') expect(cop.offenses).to be_empty end it 'ignores non-alphanumeric characters' do inspect_source(cop, - ["describe Some::Class, '#pred?' do; end"], + "describe Some::Class, '#pred?' do; end", 'some/class/pred_spec.rb') expect(cop.offenses).to be_empty end it 'allows flexibility with predicates' do inspect_source(cop, - ["describe Some::Class, '#thing?' do; end"], + "describe Some::Class, '#thing?' do; end", 'some/class/thing_predicate_spec.rb') expect(cop.offenses).to be_empty end it 'allows flexibility with operators' do inspect_source(cop, - ["describe MyClass, '#<=>' do; end"], + "describe MyClass, '#<=>' do; end", 'my_class/spaceship_operator_spec.rb') expect(cop.offenses).to be_empty end it 'respects custom module name transformation' do inspect_source(cop, - ["describe FooFoo::Some::Class, '#bar' do; end"], + "describe FooFoo::Some::Class, '#bar' do; end", 'foofoo/some/class/bar_spec.rb') expect(cop.offenses).to be_empty end end