spec/rubocop/cop/rspec/example_wording_spec.rb in rubocop-rspec-1.5.2 vs spec/rubocop/cop/rspec/example_wording_spec.rb in rubocop-rspec-1.5.3

- old
+ new

@@ -8,50 +8,41 @@ 'IgnoredWords' => %w(only really) } end it 'ignores non-example blocks' do - inspect_source(cop, 'foo "should do something" do; end') - expect(cop.offenses).to be_empty + expect_no_violations('foo "should do something" do; end') end it 'finds description with `should` at the beginning' do - inspect_source(cop, ["it 'should do something' do", 'end']) - expect(cop.offenses.size).to eq(1) - expect(cop.offenses.map(&:line).sort).to eq([1]) - expect(cop.messages) - .to eq(['Do not use should when describing your tests.']) - expect(cop.highlights).to eq(['should do something']) + expect_violation(<<-RUBY) + it 'should do something' do + ^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests. + end + RUBY end it 'finds description with `Should` at the beginning' do - inspect_source(cop, ["it 'Should do something' do", 'end']) - expect(cop.offenses.size).to eq(1) - expect(cop.offenses.map(&:line).sort).to eq([1]) - expect(cop.messages) - .to eq(['Do not use should when describing your tests.']) - expect(cop.highlights).to eq(['Should do something']) + expect_violation(<<-RUBY) + it 'Should do something' do + ^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests. + end + RUBY end it 'finds description with `shouldn\'t` at the beginning' do - inspect_source(cop, ['it "shouldn\'t do something" do', 'end']) - expect(cop.offenses.size).to eq(1) - expect(cop.offenses.map(&:line).sort).to eq([1]) - expect(cop.messages) - .to eq(['Do not use should when describing your tests.']) - expect(cop.highlights).to eq(['shouldn\'t do something']) + expect_violation(<<-RUBY) + it "shouldn't do something" do + ^^^^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests. + end + RUBY end it 'skips descriptions without `should` at the beginning' do - inspect_source( - cop, - [ - "it 'finds no should ' \\", - " 'here' do", - 'end' - ] - ) - expect(cop.offenses).to be_empty + expect_no_violations(<<-RUBY) + it 'finds no should here' do + end + RUBY end it 'corrects `it "should only have"` to it "only has"' do corrected = autocorrect_source(cop, 'it "should only have trait" do end') expect(corrected).to eql('it "only has trait" do end')