Sha256: fe1a3b9d402a7c705a1ad8476a1edb8c038740bed0f74c10c50a12bef997f621
Contents?: true
Size: 1.35 KB
Versions: 7
Compression:
Stored size: 1.35 KB
Contents
# frozen_string_literal: true describe RuboCop::Cop::RSpec::LetSetup do subject(:cop) { described_class.new } it 'complains when let! is used and not referenced' do expect_violation(<<-RUBY) describe Foo do let!(:foo) { bar } ^^^^^^^^^^ Do not use `let!` for test setup. it 'does not use foo' do expect(baz).to eq(qux) end end RUBY end it 'ignores let! when used in `before`' do expect_no_violations(<<-RUBY) describe Foo do let!(:foo) { bar } before do foo end it 'does not use foo' do expect(baz).to eq(qux) end end RUBY end it 'ignores let! when used in example' do expect_no_violations(<<-RUBY) describe Foo do let!(:foo) { bar } it 'uses foo' do foo expect(baz).to eq(qux) end end RUBY end it 'complains when let! is used and not referenced within nested group' do expect_violation(<<-RUBY) describe Foo do context 'when something special happens' do let!(:foo) { bar } ^^^^^^^^^^ Do not use `let!` for test setup. it 'does not use foo' do expect(baz).to eq(qux) end end it 'references some other foo' do foo end end RUBY end end
Version data entries
7 entries across 7 versions & 1 rubygems