Sha256: 5ed6cc8ca5ac688fe2f616f08b9d4ebb512d30e8d3577710eb76a08bc3effa99
Contents?: true
Size: 955 Bytes
Versions: 2
Compression:
Stored size: 955 Bytes
Contents
describe RuboCop::Cop::RSpec::InstanceVariable do subject(:cop) { described_class.new } it 'finds an instance variable inside a describe' do expect_violation(<<-RUBY) describe MyClass do before { @foo = [] } it { expect(@foo).to be_empty } ^^^^ Use `let` instead of an instance variable end RUBY end it 'ignores non-spec blocks' do expect_no_violations(<<-RUBY) not_rspec do before { @foo = [] } it { expect(@foo).to be_empty } end RUBY end it 'finds an instance variable inside a shared example' do expect_violation(<<-RUBY) shared_examples 'shared example' do it { expect(@foo).to be_empty } ^^^^ Use `let` instead of an instance variable end RUBY end it 'ignores an instance variable without describe' do expect_no_violations(<<-RUBY) @foo = [] @foo.empty? RUBY end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-rspec-1.6.0 | spec/rubocop/cop/rspec/instance_variable_spec.rb |
rubocop-rspec-1.5.3 | spec/rubocop/cop/rspec/instance_variable_spec.rb |