spec/rubocop/cop/rspec/instance_variable_spec.rb in rubocop-rspec-1.21.0 vs spec/rubocop/cop/rspec/instance_variable_spec.rb in rubocop-rspec-1.22.0
- old
+ new
@@ -34,9 +34,27 @@
@foo = []
@foo.empty?
RUBY
end
+ it 'ignores an instance variable inside a dynamic class' do
+ expect_no_offenses(<<-RUBY)
+ describe MyClass do
+ let(:object) do
+ Class.new(OtherClass) do
+ def initialize(resource)
+ @resource = resource
+ end
+
+ def serialize
+ @resource.to_json
+ end
+ end
+ end
+ end
+ RUBY
+ end
+
# Regression test for nevir/rubocop-rspec#115
it 'ignores instance variables outside of specs' do
expect_no_offenses(<<-RUBY, 'lib/source_code.rb')
feature do
@foo = bar