diff --git a/lib/rubocop/cop/rspec/named_subject.rb b/lib/rubocop/cop/rspec/named_subject.rb index ed12f133a..ac93b7124 100644 --- a/lib/rubocop/cop/rspec/named_subject.rb +++ b/lib/rubocop/cop/rspec/named_subject.rb @@ -6,11 +6,11 @@ module RSpec # Checks for explicitly referenced test subjects. # # RSpec lets you declare an "implicit subject" using `subject { ... }` - # which allows for tests like `it { should be_valid }`. If you need to - # reference your test subject you should explicitly name it using - # `subject(:your_subject_name) { ... }`. Your test subjects should be - # the most important object in your tests so they deserve a descriptive - # name. + # which allows for tests like `it { is_expected.to be_valid }`. + # If you need to reference your test subject you should explicitly + # name it using `subject(:your_subject_name) { ... }`. Your test subjects + # should be the most important object in your tests so they deserve + # a descriptive name. # # This cop can be configured in your configuration using the # `IgnoreSharedExamples` which will not report offenses for implicit @@ -39,7 +39,7 @@ module RSpec # RSpec.describe Foo do # subject(:user) { described_class.new } # - # it { should be_valid } + # it { is_expected.to be_valid } # end class NamedSubject < Cop MSG = 'Name your test subject if you need '\ diff --git a/manual/cops_rspec.md b/manual/cops_rspec.md index 78f371f1c..ca6524bee 100644 --- a/manual/cops_rspec.md +++ b/manual/cops_rspec.md @@ -2120,11 +2120,11 @@ Enabled | No Checks for explicitly referenced test subjects. RSpec lets you declare an "implicit subject" using `subject { ... }` -which allows for tests like `it { should be_valid }`. If you need to -reference your test subject you should explicitly name it using -`subject(:your_subject_name) { ... }`. Your test subjects should be -the most important object in your tests so they deserve a descriptive -name. +which allows for tests like `it { is_expected.to be_valid }`. +If you need to reference your test subject you should explicitly +name it using `subject(:your_subject_name) { ... }`. Your test subjects +should be the most important object in your tests so they deserve +a descriptive name. This cop can be configured in your configuration using the `IgnoreSharedExamples` which will not report offenses for implicit @@ -2155,7 +2155,7 @@ end RSpec.describe Foo do subject(:user) { described_class.new } - it { should be_valid } + it { is_expected.to be_valid } end ```