spec/rubocop/cop/rspec/multiple_subjects_spec.rb in rubocop-rspec-1.32.0 vs spec/rubocop/cop/rspec/multiple_subjects_spec.rb in rubocop-rspec-1.33.0

- old
+ new

@@ -17,21 +17,35 @@ describe 'baz' do subject(:norf) { 1 } end end RUBY + + expect_correction(<<-RUBY) + describe 'hello there' do + let(:foo) { 1 } + let(:bar) { 2 } + subject(:baz) { 4 } + + describe 'baz' do + subject(:norf) { 1 } + end + end + RUBY end it 'does not try to autocorrect subject!' do source = <<-RUBY describe Foo do subject! { a } + ^^^^^^^^^^^^^^ Do not set more than one subject per example group subject! { b } end RUBY - expect(autocorrect_source(source, 'example_spec.rb')).to eql(source) + expect_offense(source) + expect_no_corrections end it 'does not flag shared example groups' do expect_no_offenses(<<-RUBY) describe Foo do @@ -48,49 +62,22 @@ end end RUBY end - include_examples( - 'autocorrect', - <<-RUBY, + it 'autocorrects' do + expect_offense(<<-RUBY) describe 'hello there' do - subject(:foo) { 1 } - subject(:bar) { 2 } - subject(:baz) { 3 } - - describe 'baz' do - subject(:norf) { 1 } - end + subject { 1 } + ^^^^^^^^^^^^^ Do not set more than one subject per example group + subject { 2 } + ^^^^^^^^^^^^^ Do not set more than one subject per example group + subject { 3 } end RUBY - <<-RUBY + expect_correction(<<-RUBY) describe 'hello there' do - let(:foo) { 1 } - let(:bar) { 2 } - subject(:baz) { 3 } - - describe 'baz' do - subject(:norf) { 1 } - end - end - RUBY - ) - - include_examples( - 'autocorrect', - <<-RUBY.strip_indent.chomp, - describe 'hello there' do - subject { 1 } - subject { 2 } subject { 3 } end RUBY - [ - "describe 'hello there' do", - ' ', - ' ', - ' subject { 3 }', - 'end' - ].join("\n") - ) + end end