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

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + RSpec.describe RuboCop::Cop::RSpec::ExampleWording, :config do subject(:cop) { described_class.new(config) } context 'with configuration' do let(:cop_config) do @@ -17,50 +19,93 @@ expect_offense(<<-RUBY) it 'should do something' do ^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests. end RUBY + + expect_correction(<<-RUBY) + it 'does something' do + end + RUBY end it 'finds description with `Should` at the beginning' do expect_offense(<<-RUBY) it 'Should do something' do ^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests. end RUBY + + expect_correction(<<-RUBY) + it 'does something' do + end + RUBY end it 'finds description with `shouldn\'t` at the beginning' do expect_offense(<<-RUBY) it "shouldn't do something" do ^^^^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests. end RUBY + + expect_correction(<<-RUBY) + it "does not do something" do + end + RUBY end + it 'finds description with `SHOULDN\'T` at the beginning' do + expect_offense(<<-RUBY) + it "SHOULDN'T do something" do + ^^^^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests. + end + RUBY + + expect_correction(<<-RUBY) + it "DOES NOT do something" do + end + RUBY + end + it 'flags a lone should' do expect_offense(<<-RUBY) it 'should' do ^^^^^^ Do not use should when describing your tests. end RUBY + + expect_correction(<<-RUBY) + it '' do + end + RUBY end it 'flags a lone should not' do expect_offense(<<-RUBY) it 'should not' do ^^^^^^^^^^ Do not use should when describing your tests. end RUBY + + expect_correction(<<-RUBY) + it 'does not' do + end + RUBY end it 'finds leading its' do expect_offense(<<-RUBY) it "it does something" do ^^^^^^^^^^^^^^^^^ Do not repeat 'it' when describing your tests. end RUBY + + expect_correction(<<-RUBY) + it "does something" do + end + RUBY end it "skips words beginning with 'it'" do expect_no_offenses(<<-RUBY) it 'itemizes items' do @@ -79,33 +124,9 @@ expect_no_offenses(<<-RUBY) it 'shoulders the burden' do end RUBY end - - include_examples 'autocorrect', - 'it "should only have trait" do end', - 'it "only has trait" do end' - - include_examples 'autocorrect', - 'it "SHOULDN\'T only have trait" do end', - 'it "DOES NOT only have trait" do end' - - include_examples 'autocorrect', - 'it "it does something" do end', - 'it "does something" do end' - - include_examples 'autocorrect', - 'it "It does something" do end', - 'it "does something" do end' - - include_examples 'autocorrect', - 'it "should" do end', - 'it "" do end' - - include_examples 'autocorrect', - 'it "should not" do end', - 'it "does not" do end' end context 'when configuration is empty' do include_examples 'autocorrect', 'it "should have trait" do end',