spec/rubocop/cop/rspec/example_wording_spec.rb in rubocop-rspec-1.33.0 vs spec/rubocop/cop/rspec/example_wording_spec.rb in rubocop-rspec-1.34.0
- old
+ new
@@ -26,10 +26,23 @@
it 'does something' do
end
RUBY
end
+ it 'finds interpolated description with `should` at the beginning' do
+ expect_offense(<<-'RUBY')
+ it "should do #{:stuff}" do
+ ^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
+ end
+ RUBY
+
+ expect_correction(<<-'RUBY')
+ it "does #{:stuff}" 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
@@ -104,10 +117,23 @@
it "does something" do
end
RUBY
end
+ it 'finds leading it in interpolated description' do
+ expect_offense(<<-'RUBY')
+ it "it does #{action}" do
+ ^^^^^^^^^^^^^^^^^ Do not repeat 'it' when describing your tests.
+ end
+ RUBY
+
+ expect_correction(<<-'RUBY')
+ it "does #{action}" do
+ end
+ RUBY
+ end
+
it "skips words beginning with 'it'" do
expect_no_offenses(<<-RUBY)
it 'itemizes items' do
end
RUBY
@@ -121,9 +147,16 @@
end
it 'skips descriptions starting with words that begin with `should`' do
expect_no_offenses(<<-RUBY)
it 'shoulders the burden' do
+ end
+ RUBY
+ end
+
+ it 'skips interpolated description without literal `should` at the start' do
+ expect_no_offenses(<<-'RUBY')
+ it "#{should} not be here" do
end
RUBY
end
end