spec/rubocop/cop/rspec/overwriting_setup_spec.rb in rubocop-rspec-1.25.1 vs spec/rubocop/cop/rspec/overwriting_setup_spec.rb in rubocop-rspec-1.26.0
- old
+ new
@@ -20,10 +20,21 @@
^^^^^^^^^^^^^ `a` is already defined.
end
RUBY
end
+ it 'works with `subject!` and `let!`' do
+ expect_offense(<<-RUBY)
+ RSpec.describe User do
+ subject!(:a) { a }
+
+ let!(:a) { b }
+ ^^^^^^^^^^^^^^ `a` is already defined.
+ end
+ RUBY
+ end
+
it 'finds `let!` overwriting `let`' do
expect_offense(<<-RUBY)
RSpec.describe User do
let(:a) { b }
let!(:a) { b }
@@ -38,9 +49,20 @@
let(:a) { a }
context `different` do
let(:a) { b }
end
+ end
+ RUBY
+ end
+
+ it 'handles unnamed subjects' do
+ expect_offense(<<-RUBY)
+ RSpec.describe User do
+ subject { a }
+
+ let(:subject) { b }
+ ^^^^^^^^^^^^^^^^^^^ `subject` is already defined.
end
RUBY
end
it 'does not encounter an error when handling an empty describe' do